diff --git a/.circleci/config.yml b/.circleci/config.yml
index 68ab0799..70ad262c 100644
--- a/.circleci/config.yml
+++ b/.circleci/config.yml
@@ -76,6 +76,31 @@ jobs:
command: './venv/bin/pytest -svv --junitxml=test-results.xml'
- store_test_results:
path: test-results.xml
+ api-alembic-migrations:
+ docker:
+ - image: cimg/python:3.11
+ - image: cimg/postgres:15.6
+ environment:
+ POSTGRES_USER: wrolpi
+ POSTGRES_DB: wrolpi
+ POSTGRES_PASSWORD: "wrolpi"
+ resource_class: medium
+ steps:
+ - checkout
+ - restore_cache:
+ key: deps-3.11-{{ checksum "requirements.txt" }}-2
+ - run:
+ name: Install Requirements
+ command: |
+ python3 -m venv venv
+ . venv/bin/activate
+ pip install -r requirements.txt
+ - save_cache:
+ key: deps-3.11-{{ checksum "requirements.txt" }}-2
+ paths:
+ - "venv"
+ - run:
+ command: ./venv/bin/python ./main.py db upgrade
api-tests-3-12:
docker:
- image: cimg/python:3.12
@@ -172,6 +197,7 @@ workflows:
jobs:
- sanic-api-start
- api-tests-3-11
+ - api-alembic-migrations
# - api-tests-3-12 Sanic does not yet support 3.12.
wrolpi-app-test:
jobs:
diff --git a/alembic/versions/2bfb3b50b178_tag_names_migration.py b/alembic/versions/2bfb3b50b178_tag_names_migration.py
index eb54ddae..2e824098 100644
--- a/alembic/versions/2bfb3b50b178_tag_names_migration.py
+++ b/alembic/versions/2bfb3b50b178_tag_names_migration.py
@@ -6,6 +6,7 @@ Create Date: 2024-07-31 14:58:29.583029
"""
import os
+import sys
from alembic import op
from sqlalchemy.orm import Session
@@ -38,9 +39,12 @@ def upgrade():
if need_commit:
session.commit()
- config = get_tags_config()
- config.initialize()
- config.save_tags(session, ignore_lock=True)
+ try:
+ config = get_tags_config()
+ config.initialize()
+ config.save_tags(session, ignore_lock=True)
+ except FileNotFoundError:
+ print(f'Failed to save tags config probably because media directory does not exist', file=sys.stderr)
def downgrade():
diff --git a/alembic/versions/8d0d81bc9c34_channel_channel_downloads.py b/alembic/versions/8d0d81bc9c34_channel_channel_downloads.py
index 06393ac5..7a1aff01 100644
--- a/alembic/versions/8d0d81bc9c34_channel_channel_downloads.py
+++ b/alembic/versions/8d0d81bc9c34_channel_channel_downloads.py
@@ -6,12 +6,16 @@ Create Date: 2024-06-25 22:13:23.885687
"""
import os
+import pathlib
from alembic import op
+from sqlalchemy import Column, Integer, String, Boolean, JSON, Date
from sqlalchemy.ext.declarative import declarative_base
-from sqlalchemy.orm import Session
+from sqlalchemy.orm import Session, deferred
from modules.videos.lib import link_channel_and_downloads
+from wrolpi.common import ModelHelper
+from wrolpi.media_path import MediaPathType
# revision identifiers, used by Alembic.
revision = '8d0d81bc9c34'
@@ -24,6 +28,33 @@ DOCKERIZED = True if os.environ.get('DOCKER', '').lower().startswith('t') else F
Base = declarative_base()
+# The `Channel` model at the time of this migration.
+class MChannel(ModelHelper, Base):
+ __tablename__ = 'channel'
+ id = Column(Integer, primary_key=True)
+ name = Column(String)
+ url = Column(String, unique=True)
+ directory: pathlib.Path = Column(MediaPathType)
+ generate_posters = Column(Boolean, default=False)
+ calculate_duration = Column(Boolean, default=True)
+ source_id = Column(String)
+ refreshed = Column(Boolean, default=False)
+
+ info_json = deferred(Column(JSON))
+ info_date = Column(Date)
+
+ @staticmethod
+ def get_by_url(url: str, session: Session = None):
+ if not url:
+ raise RuntimeError('Must provide URL to get Channel')
+ channel = session.query(MChannel).filter_by(url=url).one_or_none()
+ return channel
+
+ def get_rss_url(self) -> str | None:
+ if self.url and self.source_id and 'youtube.com' in self.url:
+ return f'https://www.youtube.com/feeds/videos.xml?channel_id={self.source_id}'
+
+
def upgrade():
bind = op.get_bind()
session = Session(bind=bind)
@@ -31,7 +62,7 @@ def upgrade():
session.execute('ALTER TABLE download ADD CONSTRAINT download_url_unique UNIQUE (url)')
session.execute('ALTER TABLE download ADD COLUMN channel_id INTEGER REFERENCES channel(id)')
- link_channel_and_downloads(session)
+ link_channel_and_downloads(session, MChannel)
session.execute('ALTER TABLE channel DROP COLUMN IF EXISTS match_regex')
session.execute('ALTER TABLE channel DROP COLUMN IF EXISTS download_frequency')
diff --git a/app/src/DashboardPage.js b/app/src/DashboardPage.js
index b3a6ed07..6d9617ba 100644
--- a/app/src/DashboardPage.js
+++ b/app/src/DashboardPage.js
@@ -307,10 +307,10 @@ function DashboardStatus() {
let load = {};
let cores = 0;
let pending_downloads = '?';
- if (status && status['cpu_info']) {
- percent = status['cpu_info']['percent'];
- load = status['load'];
- cores = status['cpu_info']['cores'];
+ if (status && status['cpu_stats']) {
+ percent = status['cpu_stats']['percent'];
+ load = status['load_stats'];
+ cores = status['cpu_stats']['cores'];
}
const {downloads} = status;
@@ -319,8 +319,9 @@ function DashboardStatus() {
}
let bandwidths = ;
- if (status && status['bandwidth']) {
- bandwidths = status['bandwidth'].map(i => );
+ if (status && status['nic_bandwidth_stats']) {
+ bandwidths = Object.entries(status['nic_bandwidth_stats'])
+ .map(([name, bandwidth]) => );
}
return
diff --git a/app/src/components/Channels.js b/app/src/components/Channels.js
index 5eefbfca..89714053 100644
--- a/app/src/components/Channels.js
+++ b/app/src/components/Channels.js
@@ -271,7 +271,10 @@ function ChannelPage({create, header}) {
} catch (e) {
console.error('Failed to tag channel', e);
} finally {
- await fetchChannel();
+ setTimeout(async () => {
+ // Delay fetch because config needs to be written.
+ await fetchChannel();
+ }, 500);
}
}
diff --git a/app/src/components/Common.js b/app/src/components/Common.js
index c2db1130..270cdd40 100644
--- a/app/src/components/Common.js
+++ b/app/src/components/Common.js
@@ -1644,7 +1644,7 @@ export function HandPointMessage({children, size = null}) {
}
-export function WarningMessage({children, size = null, icon='exclamation'}) {
+export function WarningMessage({children, size = null, icon = 'exclamation'}) {
// Use color='yellow' because "warning" does not work.
return
@@ -1654,7 +1654,7 @@ export function WarningMessage({children, size = null, icon='exclamation'}) {
}
-export function ErrorMessage({children, size = null, icon='exclamation'}) {
+export function ErrorMessage({children, size = null, icon = 'exclamation'}) {
return
{children}
diff --git a/app/src/components/Nav.js b/app/src/components/Nav.js
index d7ac5ba4..b8396c44 100644
--- a/app/src/components/Nav.js
+++ b/app/src/components/Nav.js
@@ -1,12 +1,12 @@
import React from "react";
-import {NavLink} from "react-router-dom";
-import {Dropdown, Menu} from "semantic-ui-react";
-import {Media, SettingsContext, ThemeContext} from "../contexts/contexts";
-import Icon from "semantic-ui-react/dist/commonjs/elements/Icon";
+import {Link, NavLink} from "react-router-dom";
+import {Dropdown, Icon as SIcon, Menu} from "semantic-ui-react";
+import {Media, SettingsContext, StatusContext, ThemeContext} from "../contexts/contexts";
import {CPUTemperatureIcon, DarkModeToggle, HotspotStatusIcon, NAME, SystemLoadIcon} from "./Common";
import {ShareButton} from "./Share";
import {useWROLMode} from "../hooks/customHooks";
import {SearchIconButton} from "./Search";
+import {Icon} from "./Theme";
const links = [
{text: 'Videos', to: '/videos', key: 'videos'},
@@ -61,10 +61,11 @@ function NavIconWrapper(props) {
export function NavBar() {
const wrolModeEnabled = useWROLMode();
+ const {status} = React.useContext(StatusContext);
const {settings} = React.useContext(SettingsContext);
const wrolpiIcon =
;
const name = {NAME || wrolpiIcon};
- const topNavText = wrolModeEnabled ? <>{name} > : name;
+ const topNavText = wrolModeEnabled ? <>{name} > : name;
const {i} = React.useContext(ThemeContext);
const navColor = settings && settings.nav_color ? settings.nav_color : 'violet';
@@ -73,9 +74,14 @@ export function NavBar() {
;
// Display the temperature icon first because it can cause the system to throttle.
- const warningIcon = }/>
+ const warningIcon = }/>;
+
+ const refreshingIcon = status.flags && status.flags.refreshing ?
+
+ : null;
const icons =
+ {refreshingIcon}
{warningIcon}
diff --git a/app/src/components/admin/Status.js b/app/src/components/admin/Status.js
index 23dc5fae..0a1d1051 100644
--- a/app/src/components/admin/Status.js
+++ b/app/src/components/admin/Status.js
@@ -1,10 +1,20 @@
-import {Accordion, Header, Progress, Segment, Statistic, StatisticGroup} from "../Theme";
+import {Accordion, Header, Progress, Segment, Statistic, StatisticGroup, Table} from "../Theme";
import React, {useContext} from "react";
import {humanBandwidth, humanFileSize, LoadStatistic, useTitle} from "../Common";
import {ProgressPlaceholder} from "../Placeholder";
import Grid from "semantic-ui-react/dist/commonjs/collections/Grid";
import {Media, SettingsContext, StatusContext, ThemeContext} from "../../contexts/contexts";
-import {AccordionContent, AccordionTitle, SegmentGroup} from "semantic-ui-react";
+import {
+ AccordionContent,
+ AccordionTitle,
+ SegmentGroup,
+ TableBody,
+ TableCell,
+ TableHeader,
+ TableHeaderCell,
+ TableRow
+} from "semantic-ui-react";
+import _ from "lodash";
import Icon from "semantic-ui-react/dist/commonjs/elements/Icon";
function DriveInfo({used, size, percent, mount}) {
@@ -38,17 +48,17 @@ function DiskBandwidthProgress({bytes_ps, total, label, ...props}) {
return ;
}
-function DiskBandwidth({name, bytes_read_ps, bytes_write_ps, maximum_read_ps, maximum_write_ps}) {
+function DiskBandwidth({name, bytes_read_ps, bytes_write_ps, max_read_ps, max_write_ps}) {
const read = ;
const write = 70) {
props['color'] = 'yellow';
} else if (percent > 90) {
@@ -91,10 +101,10 @@ export function BandwidthProgress({label = '', bytes, maxBytes, ...props}) {
export function BandwidthProgressGroup({bandwidth, ...props}) {
// NIC speed to bytes.
- const maxBytes = bandwidth['speed'] * 125_000;
+ const maxBytes = bandwidth['speed'] * 1000 * 1000 / 8;
const recv = ;
const sent =
}
@@ -160,6 +170,15 @@ export function MemoryUsageProgress({percent, label}) {
return