detect any shorts before adding to queue
This commit is contained in:
parent
db4798754a
commit
d5885273ac
|
@ -17,7 +17,7 @@ from home.src.es.connect import ElasticWrap, IndexPaginate
|
||||||
from home.src.index.playlist import YoutubePlaylist
|
from home.src.index.playlist import YoutubePlaylist
|
||||||
from home.src.index.video_constants import VideoTypeEnum
|
from home.src.index.video_constants import VideoTypeEnum
|
||||||
from home.src.ta.config import AppConfig
|
from home.src.ta.config import AppConfig
|
||||||
from home.src.ta.helper import DurationConverter
|
from home.src.ta.helper import DurationConverter, is_shorts
|
||||||
from home.src.ta.ta_redis import RedisArchivist
|
from home.src.ta.ta_redis import RedisArchivist
|
||||||
|
|
||||||
|
|
||||||
|
@ -204,9 +204,8 @@ class PendingList(PendingIndex):
|
||||||
video_results = playlist.json_data.get("playlist_entries")
|
video_results = playlist.json_data.get("playlist_entries")
|
||||||
youtube_ids = [i["youtube_id"] for i in video_results]
|
youtube_ids = [i["youtube_id"] for i in video_results]
|
||||||
for video_id in youtube_ids:
|
for video_id in youtube_ids:
|
||||||
# FIXME: This will need to be adjusted to support Live/Shorts
|
# match vid_type later
|
||||||
# from playlists
|
self._add_video(video_id, VideoTypeEnum.UNKNOWN)
|
||||||
self._add_video(video_id, VideoTypeEnum.VIDEOS)
|
|
||||||
|
|
||||||
def add_to_pending(self, status="pending"):
|
def add_to_pending(self, status="pending"):
|
||||||
"""add missing videos to pending list"""
|
"""add missing videos to pending list"""
|
||||||
|
@ -269,9 +268,25 @@ class PendingList(PendingIndex):
|
||||||
|
|
||||||
if vid["live_status"] == "was_live":
|
if vid["live_status"] == "was_live":
|
||||||
vid_type = VideoTypeEnum.STREAMS
|
vid_type = VideoTypeEnum.STREAMS
|
||||||
|
else:
|
||||||
|
if self._check_shorts(vid):
|
||||||
|
vid_type = VideoTypeEnum.SHORTS
|
||||||
|
|
||||||
return self._parse_youtube_details(vid, vid_type)
|
return self._parse_youtube_details(vid, vid_type)
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def _check_shorts(vid):
|
||||||
|
"""check if vid is shorts video"""
|
||||||
|
if vid["width"] > vid["height"]:
|
||||||
|
return False
|
||||||
|
|
||||||
|
duration = vid.get("duration")
|
||||||
|
if duration and isinstance(duration, int):
|
||||||
|
if duration > 60:
|
||||||
|
return False
|
||||||
|
|
||||||
|
return is_shorts(vid["id"])
|
||||||
|
|
||||||
def _parse_youtube_details(self, vid, vid_type=VideoTypeEnum.VIDEOS):
|
def _parse_youtube_details(self, vid, vid_type=VideoTypeEnum.VIDEOS):
|
||||||
"""parse response"""
|
"""parse response"""
|
||||||
vid_id = vid.get("id")
|
vid_id = vid.get("id")
|
||||||
|
|
|
@ -135,7 +135,7 @@ def get_mapping():
|
||||||
return index_config
|
return index_config
|
||||||
|
|
||||||
|
|
||||||
def is_short(youtube_id):
|
def is_shorts(youtube_id):
|
||||||
"""check if youtube_id is a shorts video, bot not it it's not a shorts"""
|
"""check if youtube_id is a shorts video, bot not it it's not a shorts"""
|
||||||
shorts_url = f"https://www.youtube.com/shorts/{youtube_id}"
|
shorts_url = f"https://www.youtube.com/shorts/{youtube_id}"
|
||||||
response = requests.head(
|
response = requests.head(
|
||||||
|
|
Loading…
Reference in New Issue