match VideoTypeEnum with yt channel paths

This commit is contained in:
simon 2023-01-06 10:11:52 +07:00
parent eccad8968b
commit e299308711
No known key found for this signature in database
GPG Key ID: 2C15AA5E89985DD4
9 changed files with 25 additions and 25 deletions

View File

@ -134,7 +134,7 @@ class StartupCheck:
"query": {
"bool": {"must_not": [{"exists": {"field": "vid_type"}}]}
},
"script": {"source": "ctx._source['vid_type'] = 'video'"},
"script": {"source": "ctx._source['vid_type'] = 'videos'"},
}
for index_name in index_list:

View File

@ -163,7 +163,7 @@ class PendingList(PendingIndex):
def _process_entry(self, entry):
"""process single entry from url list"""
if entry["type"] == "video":
vid_type = entry.get("vid_type", VideoTypeEnum.VIDEO)
vid_type = entry.get("vid_type", VideoTypeEnum.VIDEOS)
self._add_video(entry["url"], vid_type)
elif entry["type"] == "channel":
self._parse_channel(entry["url"])
@ -173,7 +173,7 @@ class PendingList(PendingIndex):
else:
raise ValueError(f"invalid url_type: {entry}")
def _add_video(self, url, vid_type=VideoTypeEnum.VIDEO):
def _add_video(self, url, vid_type=VideoTypeEnum.VIDEOS):
"""add video to list"""
if url not in self.missing_videos and url not in self.to_skip:
self.missing_videos.append((url, vid_type))
@ -197,7 +197,7 @@ class PendingList(PendingIndex):
for video_id in youtube_ids:
# FIXME: This will need to be adjusted to support Live/Shorts
# from playlists
self._add_video(video_id, VideoTypeEnum.VIDEO)
self._add_video(video_id, VideoTypeEnum.VIDEOS)
def add_to_pending(self, status="pending"):
"""add missing videos to pending list"""
@ -244,7 +244,7 @@ class PendingList(PendingIndex):
if idx + 1 % 25 == 0:
print("adding to queue progress: " + progress)
def get_youtube_details(self, youtube_id, vid_type=VideoTypeEnum.VIDEO):
def get_youtube_details(self, youtube_id, vid_type=VideoTypeEnum.VIDEOS):
"""get details from youtubedl for single pending video"""
vid = YtWrap(self.yt_obs, self.config).extract(youtube_id)
if not vid:
@ -260,7 +260,7 @@ class PendingList(PendingIndex):
return self._parse_youtube_details(vid, vid_type)
def _parse_youtube_details(self, vid, vid_type=VideoTypeEnum.VIDEO):
def _parse_youtube_details(self, vid, vid_type=VideoTypeEnum.VIDEOS):
"""parse response"""
vid_id = vid.get("id")
duration_str = DurationConverter.get_str(vid["duration"])

View File

@ -41,18 +41,18 @@ class ChannelSubscription:
queries = [
(
VideoTypeEnum.VIDEO,
"videos",
VideoTypeEnum.VIDEOS,
VideoTypeEnum.VIDEOS.value,
self.config["subscriptions"]["channel_size"],
),
(
VideoTypeEnum.LIVE,
"streams",
VideoTypeEnum.STREAMS,
VideoTypeEnum.STREAMS.value,
self.config["subscriptions"]["live_channel_size"],
),
(
VideoTypeEnum.SHORT,
"shorts",
VideoTypeEnum.SHORTS,
VideoTypeEnum.SHORTS.value,
self.config["subscriptions"]["shorts_channel_size"],
),
]

View File

@ -189,7 +189,7 @@ class VideoDownloader:
youtube_id = youtube_data.get("youtube_id")
tmp_vid_type = youtube_data.get(
"vid_type", VideoTypeEnum.VIDEO.value
"vid_type", VideoTypeEnum.VIDEOS.value
)
video_type = VideoTypeEnum(tmp_vid_type)
print(f"Downloading type: {video_type}")
@ -269,7 +269,7 @@ class VideoDownloader:
"youtube_id": i["youtube_id"],
# Using .value in default val to match what would be
# decoded when parsing json if not set
"vid_type": i.get("vid_type", VideoTypeEnum.VIDEO.value),
"vid_type": i.get("vid_type", VideoTypeEnum.VIDEOS.value),
}
)
for i in pending.all_pending

View File

@ -128,7 +128,7 @@ class YoutubeVideo(YouTubeItem, YoutubeSubtitle):
self,
youtube_id,
video_overwrites=False,
video_type=VideoTypeEnum.VIDEO,
video_type=VideoTypeEnum.VIDEOS,
):
super().__init__(youtube_id)
self.channel_id = False
@ -406,7 +406,7 @@ class YoutubeVideo(YouTubeItem, YoutubeSubtitle):
def index_new_video(
youtube_id, video_overwrites=False, video_type=VideoTypeEnum.VIDEO
youtube_id, video_overwrites=False, video_type=VideoTypeEnum.VIDEOS
):
"""combined classes to create new video in index"""
video = YoutubeVideo(

View File

@ -6,7 +6,7 @@ import enum
class VideoTypeEnum(enum.Enum):
"""all vid_type fields"""
VIDEO = "video"
LIVE = "live"
SHORT = "short"
VIDEOS = "videos"
STREAMS = "streams"
SHORTS = "shorts"
UNKNOWN = "unknown"

View File

@ -68,7 +68,7 @@ def update_subscribed():
playlist_videos = [
{
"type": "video",
"vid_type": VideoTypeEnum.VIDEO,
"vid_type": VideoTypeEnum.VIDEOS,
"url": i,
}
for i in missing_from_playlists

View File

@ -47,7 +47,7 @@ urlpatterns = [
name="channel_id",
),
path(
"channel/<slug:channel_id>/live/",
"channel/<slug:channel_id>/streams/",
login_required(ChannelIdLiveView.as_view()),
name="channel_id_live",
),

View File

@ -514,7 +514,7 @@ class ChannelIdView(ChannelIdBaseView):
view_origin = "home"
es_search = "ta_video/_search"
video_types = [VideoTypeEnum.VIDEO]
video_types = [VideoTypeEnum.VIDEOS]
def get(self, request, channel_id):
"""get request"""
@ -584,11 +584,11 @@ class ChannelIdView(ChannelIdBaseView):
class ChannelIdLiveView(ChannelIdView):
"""resolves to /channel/<channel-id>/live/
"""resolves to /channel/<channel-id>/streams/
display single channel page from channel_id
"""
video_types = [VideoTypeEnum.LIVE]
video_types = [VideoTypeEnum.STREAMS]
class ChannelIdShortsView(ChannelIdView):
@ -596,7 +596,7 @@ class ChannelIdShortsView(ChannelIdView):
display single channel page from channel_id
"""
video_types = [VideoTypeEnum.SHORT]
video_types = [VideoTypeEnum.SHORTS]
class ChannelIdAboutView(ChannelIdBaseView):