|
@@ -30,7 +30,7 @@ YOUTUBE_VIDEO_URL = "https://www.youtube.com/watch?v="
|
|
|
YOUTUBE_CHANNEL_URL = "https://www.youtube.com/channel/"
|
|
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/tt"
|
|
|
|
|
|
|
+IMDB_VIDEO_URL = "https://www.imdb.com/title/"
|
|
|
|
|
|
|
|
logger = logging.getLogger(__name__)
|
|
logger = logging.getLogger(__name__)
|
|
|
BNULL = {"blank": True, "null": True}
|
|
BNULL = {"blank": True, "null": True}
|
|
@@ -143,7 +143,7 @@ class Series(TimeStampedModel):
|
|
|
if not self.cover_image or (force_update and url):
|
|
if not self.cover_image or (force_update and url):
|
|
|
r = requests.get(url)
|
|
r = requests.get(url)
|
|
|
if r.status_code == 200:
|
|
if r.status_code == 200:
|
|
|
- fname = f"{self.title}_{self.uuid}.jpg"
|
|
|
|
|
|
|
+ fname = f"{self.name}_{self.uuid}.jpg"
|
|
|
self.cover_image.save(fname, ContentFile(r.content), save=True)
|
|
self.cover_image.save(fname, ContentFile(r.content), save=True)
|
|
|
|
|
|
|
|
def scrobbles_for_user(self, user_id: int, include_playing=False):
|
|
def scrobbles_for_user(self, user_id: int, include_playing=False):
|
|
@@ -198,7 +198,8 @@ class Series(TimeStampedModel):
|
|
|
def find_or_create(cls, imdb_id: str, overwrite: bool = True):
|
|
def find_or_create(cls, imdb_id: str, overwrite: bool = True):
|
|
|
series, created = cls.objects.get_or_create(imdb_id=imdb_id)
|
|
series, created = cls.objects.get_or_create(imdb_id=imdb_id)
|
|
|
|
|
|
|
|
- if not (created or overwrite):
|
|
|
|
|
|
|
+ if not created and not overwrite:
|
|
|
|
|
+ logger.info("Series not created and overwrite=False, returning")
|
|
|
return series
|
|
return series
|
|
|
|
|
|
|
|
vdict, _, cover, genres = lookup_video_from_imdb(
|
|
vdict, _, cover, genres = lookup_video_from_imdb(
|
|
@@ -382,9 +383,9 @@ class Video(ScrobblableMixin):
|
|
|
@classmethod
|
|
@classmethod
|
|
|
def find_or_create(cls, source_id: str, overwrite: bool = True) -> "Video":
|
|
def find_or_create(cls, source_id: str, overwrite: bool = True) -> "Video":
|
|
|
if "tt" in source_id:
|
|
if "tt" in source_id:
|
|
|
- return cls.get_from_imdb_id(source_id)
|
|
|
|
|
|
|
+ return cls.get_from_imdb_id(source_id, overwrite)
|
|
|
if bool(YOUTUBE_ID_PATTERN.match(source_id)):
|
|
if bool(YOUTUBE_ID_PATTERN.match(source_id)):
|
|
|
- return cls.get_from_youtube_id(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")
|
|
logger.warning("Video ID not recognized, not scrobbling")
|