mirror of
https://github.com/lrnselfreliance/wrolpi.git
synced 2026-11-25 01:16:18 -05:00
Many fixes split out from the feature/unified-query branch. Installing diagnostic tools in the built images. Displaying video comment statistics. Echoing error when install.sh fails.
This commit is contained in:
parent
78806b6060
commit
ba2dd6dd11
12 changed files with 121 additions and 14 deletions
|
|
@ -229,7 +229,7 @@ export function RequiredAsterisk() {
|
|||
return <span style={{color: '#db2828'}}> *</span>
|
||||
}
|
||||
|
||||
export let defaultVideoOrder = '-published_datetime';
|
||||
export let defaultFileOrder = '-published_datetime';
|
||||
export let defaultSearchOrder = 'rank';
|
||||
|
||||
export const frequencyOptions = [{key: null, text: '', value: null}, {
|
||||
|
|
@ -580,7 +580,7 @@ export function textEllipsis(str, maxLength = 100, {side = "end", ellipsis = "..
|
|||
}
|
||||
|
||||
export function TabLinks({links}) {
|
||||
const [searchParams, setSearchParams] = useSearchParams();
|
||||
const [searchParams] = useSearchParams();
|
||||
|
||||
const getTo = (to) => {
|
||||
return `${to}?${searchParams.toString()}`;
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ import {
|
|||
CardLink,
|
||||
CardPoster,
|
||||
defaultSearchOrder,
|
||||
defaultVideoOrder,
|
||||
defaultFileOrder,
|
||||
Duration,
|
||||
encodeMediaPath,
|
||||
ErrorMessage,
|
||||
|
|
@ -65,7 +65,7 @@ function VideosPage() {
|
|||
const {searchParams} = React.useContext(QueryContext);
|
||||
const [selectedVideos, setSelectedVideos] = useState([]);
|
||||
|
||||
let searchOrder = defaultVideoOrder;
|
||||
let searchOrder = defaultFileOrder;
|
||||
if (searchParams.get('order')) {
|
||||
// Use whatever order the user specified.
|
||||
searchOrder = searchParams.get('order');
|
||||
|
|
@ -238,6 +238,9 @@ function VideosStatistics() {
|
|||
{key: 'month', label: 'Downloads Past Month'},
|
||||
{key: 'year', label: 'Downloads Past Year'},
|
||||
{key: 'sum_duration', label: 'Total Duration'},
|
||||
{key: 'have_comments', label: 'Have Comments'},
|
||||
{key: 'no_comments', label: 'Missing Comments'},
|
||||
{key: 'failed_comments', label: 'Failed Comments'},
|
||||
];
|
||||
const historicalNames = [
|
||||
{key: 'average_count', label: 'Average Monthly Downloads'},
|
||||
|
|
|
|||
|
|
@ -12,7 +12,9 @@ catdoc
|
|||
chromium
|
||||
cpufrequtils
|
||||
curl
|
||||
ethtool
|
||||
exfat-fuse
|
||||
fdupes
|
||||
ffmpeg
|
||||
firefox-esr
|
||||
fonts-noto-cjk
|
||||
|
|
@ -62,6 +64,7 @@ netcat-openbsd
|
|||
network-manager
|
||||
nginx-doc
|
||||
nginx-full
|
||||
nicstat
|
||||
nodejs
|
||||
npm
|
||||
osm2pgsql
|
||||
|
|
@ -86,6 +89,7 @@ rsync
|
|||
software-properties-common
|
||||
sudo
|
||||
tar
|
||||
tcpdump
|
||||
tmux
|
||||
unzip
|
||||
vim
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ services:
|
|||
- './main.py:/opt/wrolpi/main.py'
|
||||
- './wrolpi:/opt/wrolpi/wrolpi'
|
||||
- './modules:/opt/wrolpi/modules'
|
||||
- './scripts:/opt/wrolpi/scripts'
|
||||
- './test:/opt/wrolpi/test'
|
||||
- './test:/media/wrolpi'
|
||||
- './alembic:/opt/wrolpi/alembic'
|
||||
|
|
|
|||
|
|
@ -5,12 +5,17 @@ WORKDIR /app
|
|||
ENV PATH /app/node_modules/.bin:$PATH
|
||||
|
||||
# install and cache app dependencies
|
||||
USER root
|
||||
RUN npm install -g serve
|
||||
COPY app/public /app/public
|
||||
COPY app/src /app/src
|
||||
COPY app/package.json app/package-lock.json /app/
|
||||
RUN npm install
|
||||
RUN npm install -g serve
|
||||
# "node" user will run the app after build.
|
||||
RUN chown -R node:node /app
|
||||
|
||||
# Install dependencies as "node", this is to avoid changing ownership of many files.
|
||||
USER node
|
||||
RUN npm install
|
||||
|
||||
# Run the production build
|
||||
CMD ["serve", "-s", "build"]
|
||||
|
|
|
|||
|
|
@ -69,4 +69,9 @@ fi
|
|||
set +x
|
||||
|
||||
echo "Install end $(date '+%Y-%m-%d %H:%M:%S')" >>/opt/wrolpi/install.log
|
||||
|
||||
if [ "${install_code}" -ne 0 ]; then
|
||||
echo "Installation failed!"
|
||||
fi
|
||||
|
||||
exit "${install_code}"
|
||||
|
|
|
|||
|
|
@ -368,27 +368,23 @@ class VideoDownloader(Downloader, ABC):
|
|||
video.source_id = entry['id']
|
||||
video.channel_id = channel_id
|
||||
video_id, video_info_json_path = video.id, video.info_json_path
|
||||
session.commit()
|
||||
|
||||
if video_info_json_path:
|
||||
format_json_file(video_info_json_path)
|
||||
|
||||
with get_db_session() as session:
|
||||
with get_db_session(commit=True) as session:
|
||||
# Second session is started because SQLAlchemy will forget what we have done.
|
||||
need_commit = False
|
||||
video = Video.get_by_id(video_id, session)
|
||||
if download.settings and (tag_names := download.settings.get('tag_names')):
|
||||
existing_names = video.file_group.tag_names
|
||||
for name in tag_names:
|
||||
if name not in existing_names:
|
||||
video.add_tag(name)
|
||||
need_commit = True
|
||||
location = video.location
|
||||
|
||||
await video.get_ffprobe_json()
|
||||
|
||||
if need_commit:
|
||||
session.commit()
|
||||
|
||||
# Check that video has both audio and video streams.
|
||||
if not video.get_streams_by_codec_type('video'):
|
||||
return DownloadResult(
|
||||
|
|
|
|||
|
|
@ -482,7 +482,11 @@ async def get_statistics():
|
|||
-- sum of all video file sizes
|
||||
COALESCE(SUM(fg.size), 0)::BIGINT AS "sum_size",
|
||||
-- largest video
|
||||
COALESCE(MAX(fg.size), 0) AS "max_size"
|
||||
COALESCE(MAX(fg.size), 0) AS "max_size",
|
||||
-- Videos may or may not have comments.
|
||||
COUNT(v.id) FILTER ( WHERE v.have_comments = TRUE ) AS "have_comments",
|
||||
COUNT(v.id) FILTER ( WHERE v.have_comments = FALSE ) AS "no_comments",
|
||||
COUNT(v.id) FILTER ( WHERE v.comments_failed = TRUE ) AS "failed_comments"
|
||||
FROM
|
||||
video v
|
||||
LEFT JOIN file_group fg on v.file_group_id = fg.id
|
||||
|
|
|
|||
|
|
@ -13,7 +13,9 @@ chromium-browser
|
|||
chromium-chromedriver
|
||||
cpufrequtils
|
||||
curl
|
||||
ethtool
|
||||
exfat-fuse
|
||||
fdupes
|
||||
ffmpeg
|
||||
fonts-noto-cjk
|
||||
fonts-noto-hinted
|
||||
|
|
@ -60,6 +62,7 @@ netcat-openbsd
|
|||
network-manager
|
||||
nginx-doc
|
||||
nginx-full
|
||||
nicstat
|
||||
nodejs
|
||||
npm
|
||||
osm2pgsql
|
||||
|
|
@ -83,6 +86,7 @@ renderd
|
|||
rsync
|
||||
software-properties-common
|
||||
tar
|
||||
tcpdump
|
||||
tmux
|
||||
unzip
|
||||
vim
|
||||
|
|
|
|||
45
scripts/delete_downloads.py
Executable file
45
scripts/delete_downloads.py
Executable file
|
|
@ -0,0 +1,45 @@
|
|||
#! /usr/bin/env python3
|
||||
import asyncio
|
||||
|
||||
from wrolpi.db import get_db_curs
|
||||
from wrolpi.downloader import get_download_manager_config
|
||||
|
||||
|
||||
async def delete_once_downloads():
|
||||
"""Deletes all once-downloads."""
|
||||
with get_db_curs(commit=True) as curs:
|
||||
curs.execute('DELETE FROM download WHERE frequency IS NULL')
|
||||
|
||||
|
||||
async def delete_all_downloads():
|
||||
"""Deletes all downloads."""
|
||||
with get_db_curs(commit=True) as curs:
|
||||
curs.execute('DELETE FROM download') # noqa
|
||||
|
||||
|
||||
async def main():
|
||||
"""Asks the user which Downloads they want to delete. Saves the config if any downloads are deleted."""
|
||||
need_save = False
|
||||
|
||||
delete_once = input('Delete all once-downloads? (Downloads that will only occur once) [y/N]: ')
|
||||
delete_once = True if delete_once.lower() == 'y' else False
|
||||
|
||||
if delete_once:
|
||||
await delete_once_downloads()
|
||||
need_save = True
|
||||
|
||||
delete_all = input('Delete ALL downloads? [y/N]: ')
|
||||
delete_all = True if delete_all.lower() == 'y' else False
|
||||
|
||||
if delete_all:
|
||||
await delete_all_downloads()
|
||||
need_save = True
|
||||
|
||||
if need_save:
|
||||
# Save the config file.
|
||||
get_download_manager_config().save()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
loop = asyncio.new_event_loop()
|
||||
loop.run_until_complete(main())
|
||||
|
|
@ -1143,7 +1143,8 @@ def _move(destination: pathlib.Path, *sources: pathlib.Path) -> List[Tuple[pathl
|
|||
if source.is_dir():
|
||||
# Recursively move the directory's files.
|
||||
for path in walk(source):
|
||||
new_file = destination / path.relative_to(media_directory)
|
||||
# Preserve the directory structure that contains this file.
|
||||
new_file = destination / source.name / path.relative_to(source)
|
||||
if new_file.exists():
|
||||
raise FileConflict(f'Cannot move {path} to {new_file} because it already exists')
|
||||
if path not in unique_paths:
|
||||
|
|
|
|||
|
|
@ -798,6 +798,45 @@ async def test_move_files(test_session, test_directory, make_files_structure):
|
|||
assert (dest / 'two.txt').read_text() == 'two'
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_move_deep_directory(test_session, test_directory, make_files_structure):
|
||||
"""Moving files/directories from one deep directory to another is supported."""
|
||||
baz, foo, quuz_mp4, quuz_txt, quux = make_files_structure({
|
||||
'foo/foo.txt': 'foo',
|
||||
'foo/bar/baz.txt': 'baz',
|
||||
'foo/qux/quux.txt': 'quux',
|
||||
'foo/quuz.txt': 'quuz text', # this text file will be moved when it's MP4 is moved.
|
||||
'foo/quuz.mp4': 'quuz mp4',
|
||||
})
|
||||
assert foo.name == 'foo.txt' \
|
||||
and baz.name == 'baz.txt' \
|
||||
and quux.name == 'quux.txt' \
|
||||
and quuz_mp4.name == 'quuz.mp4' \
|
||||
and quuz_txt.name == 'quuz.txt', \
|
||||
'Test directory was not initiated correctly.'
|
||||
bar, qux = baz.parent, quux.parent
|
||||
dest = test_directory / 'deep/dest'
|
||||
|
||||
# mv foo/bar foo/qux foo/quuz.mp4 deep/dest
|
||||
await lib.move(dest, bar, qux, quuz_mp4)
|
||||
|
||||
# Unrelated files and directories are untouched.
|
||||
assert not (test_directory / 'deep/dest/foo').is_dir(), 'foo/ should not have been moved.'
|
||||
assert (test_directory / 'foo').is_dir(), 'foo/ should not be deleted.'
|
||||
assert (test_directory / 'foo/foo.txt').read_text() == 'foo', 'foo.txt should not be moved.'
|
||||
|
||||
# Files are moved, preserving the name of their directory.
|
||||
assert (test_directory / 'deep/dest/bar').is_dir(), 'foo/bar/ was not moved'
|
||||
assert (test_directory / 'deep/dest/bar/baz.txt').is_file(), 'foo/bar/baz.txt was not moved'
|
||||
assert (test_directory / 'deep/dest/bar/baz.txt').read_text() == 'baz', 'foo/bar/baz.txt has wrong contents.'
|
||||
assert (test_directory / 'deep/dest/qux/quux.txt').read_text() == 'quux', 'quux.txt has the wrong contents'
|
||||
assert (test_directory / 'deep/dest/quuz.txt').read_text() == 'quuz text', 'quuz.txt has the wrong contents'
|
||||
assert (test_directory / 'deep/dest/quuz.mp4').read_text() == 'quuz mp4', 'quuz.mp4 has the wrong contents'
|
||||
|
||||
# Old directory was removed.
|
||||
assert not (test_directory / 'foo/bar').is_dir(), 'bar directory was not moved'
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_move_directory(test_session, test_directory, make_files_structure, assert_directories):
|
||||
"""A Directory record is deleted when it's directory is deleted."""
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue