validate expected video ID with remote ID to avoid redirect
This commit is contained in:
parent
4049a2a3c1
commit
65738ef52c
|
@ -177,6 +177,7 @@ class YoutubeVideo(YouTubeItem, YoutubeSubtitle):
|
||||||
|
|
||||||
def _process_youtube_meta(self):
|
def _process_youtube_meta(self):
|
||||||
"""extract relevant fields from youtube"""
|
"""extract relevant fields from youtube"""
|
||||||
|
self._validate_id()
|
||||||
# extract
|
# extract
|
||||||
self.channel_id = self.youtube_meta["channel_id"]
|
self.channel_id = self.youtube_meta["channel_id"]
|
||||||
upload_date = self.youtube_meta["upload_date"]
|
upload_date = self.youtube_meta["upload_date"]
|
||||||
|
@ -202,6 +203,19 @@ class YoutubeVideo(YouTubeItem, YoutubeSubtitle):
|
||||||
"active": True,
|
"active": True,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
def _validate_id(self):
|
||||||
|
"""validate expected video ID, raise value error on mismatch"""
|
||||||
|
remote_id = self.youtube_meta["id"]
|
||||||
|
|
||||||
|
if not self.youtube_id == remote_id:
|
||||||
|
# unexpected redirect
|
||||||
|
message = (
|
||||||
|
f"[reindex][{self.youtube_id}] got an unexpected redirect "
|
||||||
|
+ f"to {remote_id}, you are probably getting blocked by YT. "
|
||||||
|
"See FAQ for more details."
|
||||||
|
)
|
||||||
|
raise ValueError(message)
|
||||||
|
|
||||||
def _add_channel(self):
|
def _add_channel(self):
|
||||||
"""add channel dict to video json_data"""
|
"""add channel dict to video json_data"""
|
||||||
channel = ta_channel.YoutubeChannel(self.channel_id)
|
channel = ta_channel.YoutubeChannel(self.channel_id)
|
||||||
|
|
Loading…
Reference in New Issue