mirror of
https://github.com/lrnselfreliance/wrolpi.git
synced 2026-11-25 01:16:18 -05:00
Linking to uploaded file on download after a user uploads a file with the same URL.
Some checks failed
CodeQL / Analyze (push) Has been cancelled
Some checks failed
CodeQL / Analyze (push) Has been cancelled
This commit is contained in:
parent
db956faedf
commit
76a454ea34
7 changed files with 91 additions and 39 deletions
|
|
@ -107,6 +107,25 @@ archive_downloader = ArchiveDownloader()
|
|||
|
||||
|
||||
def model_archive(file_group: FileGroup, session: Session = None) -> Archive:
|
||||
"""
|
||||
Models an Archive from a given FileGroup.
|
||||
|
||||
This function takes in a FileGroup and attempts to create an Archive object.
|
||||
It does this by checking for the presence of HTML files within the FileGroup,
|
||||
determining if any of these are SingleFiles, and then extracting relevant data
|
||||
(title, contents) from either the JSON or text readability files.
|
||||
|
||||
Args:
|
||||
file_group: The FileGroup to model as an Archive.
|
||||
session: An optional database session for committing changes.
|
||||
|
||||
Returns:
|
||||
An Archive object representing the modeled archive.
|
||||
|
||||
Raises:
|
||||
InvalidArchive: If no HTML SingleFile is found in the FileGroup, or if
|
||||
any other error occurs during modeling.
|
||||
"""
|
||||
file_group_id = file_group.id
|
||||
if not file_group_id:
|
||||
session.flush([file_group])
|
||||
|
|
|
|||
|
|
@ -315,3 +315,14 @@ def test_browser_profile_to_yt_dlp_arg(file_name, expected):
|
|||
"""
|
||||
file_name = pathlib.Path(file_name)
|
||||
assert lib.browser_profile_to_yt_dlp_arg(file_name) == expected
|
||||
|
||||
|
||||
def test_video_location(test_session, video_factory, channel_factory):
|
||||
# Video location without a channel, it opens the preview.
|
||||
video1 = video_factory(title='vid1')
|
||||
assert video1.location == '/videos/video/1'
|
||||
|
||||
# Video location with a channel.
|
||||
channel = channel_factory(name='ChannelName')
|
||||
video2 = video_factory(title='vid2', channel_id=channel.id)
|
||||
assert video2.location == '/videos/channel/1/video/2'
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue