浏览代码

Update all the places we need base_run_time_seconds now

Colin Powell 2 周之前
父节点
当前提交
a8747dfe77

+ 1 - 1
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,
     )
 
 

+ 2 - 2
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"),

+ 1 - 1
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()

+ 1 - 1
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
                 )
 

+ 2 - 2
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
         )
 

+ 1 - 1
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")

+ 3 - 3
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()

+ 2 - 2
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,

+ 1 - 1
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

+ 2 - 2
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
 

+ 2 - 2
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":

+ 3 - 3
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)

+ 1 - 1
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
         )
 

+ 2 - 2
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")),
     }

+ 1 - 1
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

+ 1 - 1
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 = (

+ 2 - 2
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()