Handling if multiple videos exist at start of video download.

This commit is contained in:
Roland 2024-02-22 13:12:26 -07:00
parent 2aa30e1674
commit b705e08e48
No known key found for this signature in database
GPG key ID: 9D6DBD3ACF11AB93
2 changed files with 3 additions and 1 deletions

View file

@ -211,7 +211,8 @@ class VideoDownloader(Downloader, ABC):
# Video may have been downloaded previously, get its location for error reporting.
location = None
with get_db_session() as session:
video = Video.get_by_url(url, session=session)
videos = session.query(Video).join(FileGroup).filter_by(url=url).all()
video = videos[0] if videos else None
if video and video.channel_id:
location = f'/videos/channel/{video.channel_id}/video/{video.id}'
elif video:

View file

@ -12,6 +12,7 @@ from sqlalchemy.orm.collections import InstrumentedList
from wrolpi.common import Base, ModelHelper, tsvector, logger, recursive_map, get_media_directory
from wrolpi.dates import TZDateTime, now, from_timestamp, strptime_ms, strftime
from wrolpi.db import optional_session
from wrolpi.downloader import download_manager
from wrolpi.errors import FileGroupIsTagged
from wrolpi.files import indexers
from wrolpi.media_path import MediaPathType