mirror of
https://github.com/lrnselfreliance/wrolpi.git
synced 2026-11-29 03:16:22 -05:00
Delaying map startup because it prevents the API from starting.
This commit is contained in:
parent
af8bd7ba34
commit
2ad363281f
17 changed files with 207 additions and 139 deletions
|
|
@ -286,7 +286,7 @@ class Archive(Base, ModelHelper):
|
|||
return archive
|
||||
|
||||
def add_tag(self, tag_or_tag_name: Union[Tag, str]) -> TagFile:
|
||||
tag = Tag.find_by_name(tag_or_tag_name) if isinstance(tag_or_tag_name, str) else tag_or_tag_name
|
||||
tag = Tag.get_by_name(tag_or_tag_name) if isinstance(tag_or_tag_name, str) else tag_or_tag_name
|
||||
return self.file_group.add_tag(tag)
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ from wrolpi.dates import Seconds, from_timestamp
|
|||
from wrolpi.db import get_db_curs, get_db_session, optional_session
|
||||
from wrolpi.downloader import Download
|
||||
from wrolpi.errors import UnknownDirectory
|
||||
from wrolpi.files.lib import split_path_stem_and_suffix
|
||||
from wrolpi.vars import PYTEST, YTDLP_CACHE_DIR
|
||||
from .common import is_valid_poster, convert_image, \
|
||||
generate_video_poster, logger, REQUIRED_OPTIONS, ConfigError, \
|
||||
|
|
@ -593,7 +594,7 @@ async def get_statistics():
|
|||
return ret
|
||||
|
||||
|
||||
NAME_PARSER = re.compile(r'(.*?)_((?:\d+?)|(?:NA))_(?:(.{5,15})_)?(.*)\.'
|
||||
NAME_PARSER = re.compile(r'(.*?)_((?:\d+?)|(?:NA))_(?:(.{5,25})_)?(.*)\.'
|
||||
r'(jpg|webp|flv|mp4|part|info\.json|description|webm|..\.srt|..\.vtt)')
|
||||
|
||||
|
||||
|
|
@ -618,7 +619,7 @@ def parse_video_file_name(video_path: pathlib.Path) -> \
|
|||
return channel, date, source_id, title
|
||||
|
||||
# Return the stem as a last resort
|
||||
title = pathlib.Path(video_path).stem.strip()
|
||||
title = split_path_stem_and_suffix(video_path)[0].strip()
|
||||
return None, None, None, title
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -339,10 +339,9 @@ class Video(ModelHelper, Base):
|
|||
raise UnknownVideo(f'Cannot find Video with id {id_}')
|
||||
return video
|
||||
|
||||
def add_tag(self, tag_or_tag_name: Union[Tag, str], session: Session = None) -> TagFile:
|
||||
def add_tag(self, tag_id: int, session: Session = None) -> TagFile:
|
||||
session = session or Session.object_session(self)
|
||||
tag = Tag.find_by_name(tag_or_tag_name) if isinstance(tag_or_tag_name, str) else tag_or_tag_name
|
||||
return self.file_group.add_tag(tag, session=session)
|
||||
return self.file_group.add_tag(tag_id, session=session)
|
||||
|
||||
async def get_ffprobe_json(self) -> dict:
|
||||
"""Return the ffprobe json object if previously stored.
|
||||
|
|
@ -420,8 +419,8 @@ class Video(ModelHelper, Base):
|
|||
def delete_video(video_: Video):
|
||||
"""Delete a Video with any of its tags."""
|
||||
for tag_name_ in video_.file_group.tag_names:
|
||||
tag_ = Tag.find_by_name(tag_name_)
|
||||
video_.file_group.remove_tag(tag_, session)
|
||||
tag_ = Tag.get_by_name(tag_name_)
|
||||
video_.file_group.untag(tag_, session)
|
||||
video_.delete()
|
||||
|
||||
changes = False
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ from wrolpi.vars import PROJECT_DIR
|
|||
('20000101foo.mp4', (None, None, None, '20000101foo')),
|
||||
('something 20000101 foo.mp4', (None, None, None, 'something 20000101 foo')),
|
||||
('something_20000101_foo.mp4', ('something', '20000101', None, 'foo')),
|
||||
('foo .mp4', (None, None, None, 'foo')),
|
||||
('foo .mp4', (None, None, None, 'foo')), # Has trailing whitespace.
|
||||
('NA_20000303_vp91w5_Bob's Pancakes.mp4', (None, '20000303', 'vp91w5', 'Bob's Pancakes')),
|
||||
('NA_NA_vp91w5_Bob's Pancakes.mp4', (None, None, 'vp91w5', 'Bob's Pancakes')),
|
||||
('Learning Self-Reliance_20170529_p_MzsCFkUPU_Beekeeping 2017 Part 6 - Merging Hives.mp4',
|
||||
|
|
@ -29,6 +29,8 @@ from wrolpi.vars import PROJECT_DIR
|
|||
('Learning Self-Reliance', '20170529', 'p_Mzs', 'Beekeeping 2017 Part 6 - Merging Hives')),
|
||||
('Learning Self-Reliance_20170529_p_Beekeeping 2017 Part 6 - Merging Hives.mp4',
|
||||
('Learning Self-Reliance', '20170529', None, 'p_Beekeeping 2017 Part 6 - Merging Hives')),
|
||||
('Learning Self-Reliance_20240722_clyx8ark92qk70860vtl997n5_Long Source Id File with _.mp4',
|
||||
('Learning Self-Reliance', '20240722', 'clyx8ark92qk70860vtl997n5', 'Long Source Id File with _'))
|
||||
])
|
||||
def test_parse_video_file_name(file_name, expected):
|
||||
"""
|
||||
|
|
|
|||
|
|
@ -189,7 +189,7 @@ class Zim(Base):
|
|||
def tag_entry(self, tag_name: str, zim_entry: str) -> 'TagZimEntry':
|
||||
"""Create a TagZimEntry for this Zim at the provided entry (path) for the provided Tag."""
|
||||
session = Session.object_session(self)
|
||||
tag = Tag.find_by_name(tag_name, session=session)
|
||||
tag = Tag.get_by_name(tag_name, session=session)
|
||||
tag_zim_entry = TagZimEntry(tag=tag, zim=self, zim_entry=zim_entry)
|
||||
session.add(tag_zim_entry)
|
||||
tags.schedule_save()
|
||||
|
|
@ -200,7 +200,7 @@ class Zim(Base):
|
|||
|
||||
@raise UnknownZimTagEntry: No entry exists to remove."""
|
||||
session = Session.object_session(self)
|
||||
tag = Tag.find_by_name(tag_name, session=session)
|
||||
tag = Tag.get_by_name(tag_name, session=session)
|
||||
tag_zim_entry = session.query(TagZimEntry).filter_by(
|
||||
tag_id=tag.id,
|
||||
zim_id=self.id,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue