[videos] Fix bad imdb_link format
This commit is contained in:
@ -27,7 +27,7 @@ from vrobbler.apps.scrobbles.dataclasses import BaseLogData, WithPeopleLogData
|
||||
|
||||
YOUTUBE_VIDEO_URL = "https://www.youtube.com/watch?v="
|
||||
YOUTUBE_CHANNEL_URL = "https://www.youtube.com/channel/"
|
||||
YOUTUBE_ID_PATTERN = re.compile(r'^[A-Za-z0-9_-]{11}$')
|
||||
YOUTUBE_ID_PATTERN = re.compile(r"^[A-Za-z0-9_-]{11}$")
|
||||
IMDB_VIDEO_URL = "https://www.imdb.com/title/"
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
@ -218,7 +218,6 @@ class Series(TimeStampedModel):
|
||||
return series
|
||||
|
||||
|
||||
|
||||
class Video(ScrobblableMixin):
|
||||
COMPLETION_PERCENT = getattr(settings, "VIDEO_COMPLETION_PERCENT", 90)
|
||||
SECONDS_TO_STALE = getattr(settings, "VIDEO_SECONDS_TO_STALE", 14400)
|
||||
@ -296,7 +295,10 @@ class Video(ScrobblableMixin):
|
||||
|
||||
@property
|
||||
def imdb_link(self):
|
||||
return f"https://www.imdb.com/title/tt{self.imdb_id}"
|
||||
prefix = ""
|
||||
if "tt" not in self.imdb_id:
|
||||
prefix = "tt"
|
||||
return f"https://www.imdb.com/title/{prefix}{self.imdb_id}"
|
||||
|
||||
@property
|
||||
def info_link(self):
|
||||
@ -369,7 +371,9 @@ class Video(ScrobblableMixin):
|
||||
setattr(video, k, v)
|
||||
|
||||
if series_id:
|
||||
video.tv_series = Series.find_or_create(imdb_id=series_id, overwrite=overwrite)
|
||||
video.tv_series = Series.find_or_create(
|
||||
imdb_id=series_id, overwrite=overwrite
|
||||
)
|
||||
|
||||
video.save()
|
||||
|
||||
@ -387,7 +391,7 @@ class Video(ScrobblableMixin):
|
||||
if bool(YOUTUBE_ID_PATTERN.match(source_id)):
|
||||
return cls.get_from_youtube_id(source_id, overwrite)
|
||||
|
||||
#TODO scrobble but without a video obj?
|
||||
# TODO scrobble but without a video obj?
|
||||
logger.warning("Video ID not recognized, not scrobbling")
|
||||
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user