Returned Video.censored when fetching video.

This commit is contained in:
Roland 2022-11-10 08:21:54 -07:00
parent a0ad941425
commit 83bd19d91f
No known key found for this signature in database
GPG key ID: 9D6DBD3ACF11AB93
4 changed files with 8 additions and 5 deletions

View file

@ -235,6 +235,7 @@ class Video(ModelHelper, Base):
d = dict(
caption_path=self.caption_path,
censored=self.censored,
channel=self.channel,
channel_id=self.channel_id,
modification_datetime=self.modification_datetime,

View file

@ -35,12 +35,14 @@ def test_search_censored_videos(test_session, simple_channel, video_factory):
set_entries(map(str, range(5, 50)))
videos, total = search_videos(filters=['censored'], order_by='id', limit=20)
assert [i['video']['source_id'] for i in videos] == [str(i) for i in range(5)]
assert all(i['video']['censored'] for i in videos)
assert total == 5
# First 25 are censored.
set_entries(map(str, range(25, 50)))
videos, total = search_videos(filters=['censored'], order_by='id', limit=20)
assert [i['video']['source_id'] for i in videos] == [str(i) for i in range(20)]
assert all(i['video']['censored'] for i in videos)
assert total == 25

View file

@ -84,6 +84,7 @@ def search_videos(
order_by: str = None,
filters: List[str] = None,
) -> Tuple[List[dict], int]:
filters = filters or []
wheres = ['v.video_path IS NOT NULL']
params = dict(search_str=search_str, offset=offset)
@ -91,11 +92,10 @@ def search_videos(
wheres.append('v.channel_id = %(channel_id)s')
params['channel_id'] = channel_id
# Filter for/against favorites, if it was provided
if isinstance(filters, list) and 'favorite' in filters:
# Apply filters.
if 'favorite' in filters:
wheres.append('v.favorite IS NOT NULL')
if isinstance(filters, list) and 'censored' in filters:
if 'censored' in filters:
wheres.append('v.censored = true')
if search_str:

View file

@ -43,7 +43,7 @@ class File(ModelHelper, Base):
setweight(to_tsvector('english'::regconfig, COALESCE(d_text, '')), 'D'::"char")
''')))
prefetched_model = None # This may be filled with record matching `model.
prefetched_model = None # This may be filled with record matching `model`.
def __repr__(self):
path = str(self.path.relative_to(get_media_directory()))