diff --git a/tests/scrobbles_tests/conftest.py b/tests/scrobbles_tests/conftest.py index 355aa17..97e4744 100644 --- a/tests/scrobbles_tests/conftest.py +++ b/tests/scrobbles_tests/conftest.py @@ -34,7 +34,7 @@ def test_track(): Track.objects.create( title="Emotion", artist=Artist.objects.create(name="Carly Rae Jepsen"), - run_time_seconds=60, + base_run_time_seconds=60, ) diff --git a/vrobbler/apps/boardgames/sources/lichess.py b/vrobbler/apps/boardgames/sources/lichess.py index d7d50c4..63aca95 100644 --- a/vrobbler/apps/boardgames/sources/lichess.py +++ b/vrobbler/apps/boardgames/sources/lichess.py @@ -18,9 +18,9 @@ def import_chess_games_for_user_id(user_id: int, commit: bool = False) -> dict: for game_dict in games: chess, created = BoardGame.objects.get_or_create(title="Chess") if created: - chess.run_time_seconds = 1800 + chess.base_run_time_seconds = 1800 chess.bggeek_id = 171 - chess.save(update_fields=["run_time_seconds", "bggeek_id"]) + chess.save(update_fields=["base_run_time_seconds", "bggeek_id"]) scrobble = Scrobble.objects.filter( user_id=user.id, timestamp=game_dict.get("createdAt"), diff --git a/vrobbler/apps/books/koreader.py b/vrobbler/apps/books/koreader.py index cbd456e..94e37a9 100644 --- a/vrobbler/apps/books/koreader.py +++ b/vrobbler/apps/books/koreader.py @@ -114,7 +114,7 @@ def create_book_from_row(row: list): "raw_row_data": clean_row, } }, - run_time_seconds=run_time, + base_run_time_seconds=run_time, ) # TODO Move these to async processes after importing # book.fix_metadata() diff --git a/vrobbler/apps/books/models.py b/vrobbler/apps/books/models.py index 9243450..6fd4b27 100644 --- a/vrobbler/apps/books/models.py +++ b/vrobbler/apps/books/models.py @@ -402,7 +402,7 @@ class Book(LongPlayScrobblableMixin): self.cover.save(fname, ContentFile(r.content), save=True) if self.pages: - self.run_time_seconds = int(self.pages) * int( + self.base_run_time_seconds = int(self.pages) * int( self.AVG_PAGE_READING_SECONDS ) diff --git a/vrobbler/apps/books/sources/google.py b/vrobbler/apps/books/sources/google.py index 2d7b87c..0b1cfc5 100644 --- a/vrobbler/apps/books/sources/google.py +++ b/vrobbler/apps/books/sources/google.py @@ -67,9 +67,9 @@ def lookup_book_from_google(title: str) -> dict: .replace("&edge=curl", "") ) - book_dict["run_time_seconds"] = 3600 + book_dict["base_run_time_seconds"] = 3600 if book_dict.get("pages"): - book_dict["run_time_seconds"] = book_dict.get("pages", 10) * getattr( + book_dict["base_run_time_seconds"] = book_dict.get("pages", 10) * getattr( settings, "AVERAGE_PAGE_READING_SECONDS", 60 ) diff --git a/vrobbler/apps/books/sources/semantic.py b/vrobbler/apps/books/sources/semantic.py index 8c5098b..2d26200 100644 --- a/vrobbler/apps/books/sources/semantic.py +++ b/vrobbler/apps/books/sources/semantic.py @@ -67,7 +67,7 @@ def lookup_paper_from_semantic(title: str) -> dict: paper_dict["openaccess_pdf_url"] = result.get("openAccessPdf", {}).get( "url" ) - paper_dict["run_time_seconds"] = paper_dict.get("pages", 10) * getattr( + paper_dict["base_run_time_seconds"] = paper_dict.get("pages", 10) * getattr( settings, "AVERAGE_PAGE_READING_SECONDS", 60 ) paper_dict["author_dicts"] = result.get("authors") diff --git a/vrobbler/apps/music/models.py b/vrobbler/apps/music/models.py index 1ab2087..c27d07c 100644 --- a/vrobbler/apps/music/models.py +++ b/vrobbler/apps/music/models.py @@ -677,7 +677,7 @@ class Track(ScrobblableMixin): lookup_keys = {"title": title, "artist": artist} if run_time_seconds: - lookup_keys["run_time_seconds"] = run_time_seconds + lookup_keys["base_run_time_seconds"] = run_time_seconds logger.info(f"Looking up track using: {lookup_keys}") track = cls.objects.filter(**lookup_keys).first() if track: @@ -699,7 +699,7 @@ class Track(ScrobblableMixin): if album: track.albums.add(album) - if enrich or not track.run_time_seconds: + if enrich or not track.base_run_time_seconds: logger.info( f"Enriching track {track}", extra={ @@ -715,7 +715,7 @@ class Track(ScrobblableMixin): except Exception: print("No musicbrainz result found, cannot enrich") return track - track.run_time_seconds = run_time_seconds or int(length / 1000) + track.base_run_time_seconds = run_time_seconds or int(length / 1000) track.musicbrainz_id = mbid if commit: track.save() diff --git a/vrobbler/apps/podcasts/models.py b/vrobbler/apps/podcasts/models.py index 1918a49..7363fa1 100644 --- a/vrobbler/apps/podcasts/models.py +++ b/vrobbler/apps/podcasts/models.py @@ -145,7 +145,7 @@ class PodcastEpisode(ScrobblableMixin): title: str, pub_date: str, episode_num: int = 0, - run_time_seconds: int = 1800, + base_run_time_seconds: int = 2400, mopidy_uri: str = "", podcast_name: str = "", podcast_producer: str = "", @@ -174,7 +174,7 @@ class PodcastEpisode(ScrobblableMixin): title=title, podcast=podcast, defaults={ - "run_time_seconds": run_time_seconds, + "base_run_time_seconds": base_run_time_seconds, "number": episode_num, "pub_date": pub_date, "mopidy_uri": mopidy_uri, diff --git a/vrobbler/apps/podcasts/utils.py b/vrobbler/apps/podcasts/utils.py index e30c0f9..eef4a34 100644 --- a/vrobbler/apps/podcasts/utils.py +++ b/vrobbler/apps/podcasts/utils.py @@ -62,7 +62,7 @@ def fetch_metadata_from_rss(uri: str) -> dict[str, Any]: podcast_data["title"] = entry.title podcast_data["episode_num"] = int(entry.get("itunes_episode", 0)) podcast_data["pub_date"] = parse(entry.get("published", None)) - podcast_data["run_time_seconds"] = parse_duration(entry.get("itunes_duration", None)) + podcast_data["base_run_time_seconds"] = parse_duration(entry.get("itunes_duration", None)) # podcast_data["description"] = entry.get("description", None) # podcast_data["episode_url"] = entry.enclosures[0].href if entry.get("enclosures") else None return podcast_data diff --git a/vrobbler/apps/tasks/models.py b/vrobbler/apps/tasks/models.py index b851f2e..19761d4 100644 --- a/vrobbler/apps/tasks/models.py +++ b/vrobbler/apps/tasks/models.py @@ -95,8 +95,8 @@ class Task(LongPlayScrobblableMixin): def find_or_create(cls, title: str) -> "Task": task, created = cls.objects.get_or_create(title=title) if created: - task.run_time_seconds = 1800 - task.save(update_fields=["run_time_seconds"]) + task.base_run_time_seconds = 1800 + task.save(update_fields=["base_run_time_seconds"]) return task diff --git a/vrobbler/apps/videogames/models.py b/vrobbler/apps/videogames/models.py index ebf45a5..9cda534 100644 --- a/vrobbler/apps/videogames/models.py +++ b/vrobbler/apps/videogames/models.py @@ -238,8 +238,8 @@ class VideoGame(LongPlayScrobblableMixin): load_game_data_from_igdb(self.id, self.igdb_id) if force_update and self.main_story_time: - self.run_time_seconds = self.main_story_time - self.save(update_fields=["run_time_seconds"]) + self.base_run_time_seconds = self.main_story_time + self.save(update_fields=["base_run_time_seconds"]) @classmethod def find_or_create(cls, data_dict: dict) -> "Game": diff --git a/vrobbler/apps/videos/metadata.py b/vrobbler/apps/videos/metadata.py index e836572..97b5f7c 100644 --- a/vrobbler/apps/videos/metadata.py +++ b/vrobbler/apps/videos/metadata.py @@ -21,7 +21,7 @@ class VideoType(Enum): class VideoMetadata: title: str video_type: VideoType = VideoType.UNKNOWN - run_time_seconds: int = ( + base_run_time_seconds: int = ( 60 # Silly default, but things break if this is 0 or null ) imdb_id: Optional[str] @@ -51,11 +51,11 @@ class VideoMetadata: self, imdb_id: Optional[str] = "", youtube_id: Optional[str] = "", - run_time_seconds: int = 900, + base_run_time_seconds: int = 900, ): self.imdb_id = imdb_id self.youtube_id = youtube_id - self.run_time_seconds = run_time_seconds + self.base_run_time_seconds = base_run_time_seconds def as_dict_with_cover_and_genres(self) -> tuple: video_dict = vars(self) diff --git a/vrobbler/apps/videos/sources/imdb.py b/vrobbler/apps/videos/sources/imdb.py index 333b401..30921e2 100644 --- a/vrobbler/apps/videos/sources/imdb.py +++ b/vrobbler/apps/videos/sources/imdb.py @@ -84,7 +84,7 @@ def lookup_video_from_imdb( video_metadata.tv_series_id = series.id if imdb_result.get("runtimes"): - video_metadata.run_time_seconds = ( + video_metadata.base_run_time_seconds = ( int(imdb_result.get("runtimes")[0]) * 60 ) diff --git a/vrobbler/apps/videos/sources/skatevideosite.py b/vrobbler/apps/videos/sources/skatevideosite.py index b840fa2..90a5d5b 100644 --- a/vrobbler/apps/videos/sources/skatevideosite.py +++ b/vrobbler/apps/videos/sources/skatevideosite.py @@ -108,7 +108,7 @@ def lookup_video_from_skatevideosite(title: str) -> Optional[dict]: .replace("(", "") .replace(")", "") ) - run_time_seconds = ( + base_run_time_seconds = ( int( detail_soup.find("div", class_="p-1") .contents[-1] @@ -123,6 +123,6 @@ def lookup_video_from_skatevideosite(title: str) -> Optional[dict]: "title": str(result.find("img").get("alt").replace(" cover", "")), "video_type": "S", "year": year, - "run_time_seconds": run_time_seconds, + "base_run_time_seconds": run_time_seconds, "cover_url": str(result.find("img").get("src")), } diff --git a/vrobbler/apps/videos/sources/tmdb.py b/vrobbler/apps/videos/sources/tmdb.py index 27fecb6..e2312e1 100644 --- a/vrobbler/apps/videos/sources/tmdb.py +++ b/vrobbler/apps/videos/sources/tmdb.py @@ -72,7 +72,7 @@ def lookup_video_from_tmdb( return video_metadata video_metadata.tmdb_id = media.id - video_metadata.run_time_seconds = media.runtime * 60 + video_metadata.base_run_time_seconds = media.runtime * 60 video_metadata.plot = media.overview video_metadata.overview = media.overview video_metadata.tmdb_rating = media.vote_average diff --git a/vrobbler/apps/videos/sources/youtube.py b/vrobbler/apps/videos/sources/youtube.py index d538b28..01f723d 100644 --- a/vrobbler/apps/videos/sources/youtube.py +++ b/vrobbler/apps/videos/sources/youtube.py @@ -65,7 +65,7 @@ def lookup_video_from_youtube(youtube_id: str) -> VideoMetadata: video_metadata.channel_id = channel.id video_metadata.title = yt_metadata.get("title", "") - video_metadata.run_time_seconds = duration + video_metadata.base_run_time_seconds = duration video_metadata.video_type = VideoType.YOUTUBE.value video_metadata.youtube_id = youtube_id video_metadata.cover_url = ( diff --git a/vrobbler/apps/webpages/models.py b/vrobbler/apps/webpages/models.py index 28fcbcf..c15ff98 100644 --- a/vrobbler/apps/webpages/models.py +++ b/vrobbler/apps/webpages/models.py @@ -220,8 +220,8 @@ class WebPage(ScrobblableMixin): if not self.domain or force: self._update_domain_from_url() - if not self.run_time_seconds or force: - self.run_time_seconds = self.estimated_time_to_read_in_seconds + if not self.base_run_time_seconds or force: + self.base_run_time_seconds = self.estimated_time_to_read_in_seconds if save: self.save()