From 92774dcfe686ced882e91988e1836aaccad514a3 Mon Sep 17 00:00:00 2001 From: rlaphoenix Date: Sat, 25 Feb 2023 12:54:37 +0000 Subject: [PATCH] Simplify str representation of Sorted title containers --- devine/core/titles/episode.py | 15 +-------------- devine/core/titles/movie.py | 19 ++----------------- devine/core/titles/song.py | 15 +-------------- 3 files changed, 4 insertions(+), 45 deletions(-) diff --git a/devine/core/titles/episode.py b/devine/core/titles/episode.py index 62cd6a8..37f36d5 100644 --- a/devine/core/titles/episode.py +++ b/devine/core/titles/episode.py @@ -1,6 +1,5 @@ import re from abc import ABC -from collections import Counter from typing import Any, Iterable, Optional, Union from langcodes import Language @@ -177,19 +176,7 @@ class Series(SortedKeyList, ABC): def __str__(self) -> str: if not self: return super().__str__() - - lines = [ - f"Series: {self[0].title} ({self[0].year or '?'})", - f"Episodes: ({len(self)})", - *[ - f"├─ S{season:02}: {episodes} episodes" - for season, episodes in Counter(x.season for x in self).items() - ] - ] - last_line = lines.pop(-1) - lines.append(last_line.replace("├", "└")) - - return "\n".join(lines) + return self[0].title + (f" ({self[0].year})" if self[0].year else "") __ALL__ = (Episode, Series) diff --git a/devine/core/titles/movie.py b/devine/core/titles/movie.py index 99f1639..f47ce24 100644 --- a/devine/core/titles/movie.py +++ b/devine/core/titles/movie.py @@ -133,23 +133,8 @@ class Movies(SortedKeyList, ABC): def __str__(self) -> str: if not self: return super().__str__() - - if len(self) > 1: - lines = [ - f"Movies: ({len(self)})", - *[ - f"├─ {movie.name} ({movie.year or '?'})" - for movie in self - ] - ] - last_line = lines.pop(-1) - lines.append(last_line.replace("├", "└")) - else: - lines = [ - f"Movie: {self[0].name} ({self[0].year or '?'})" - ] - - return "\n".join(lines) + # TODO: Assumes there's only one movie + return self[0].name + (f" ({self[0].year})" if self[0].year else "") __ALL__ = (Movie, Movies) diff --git a/devine/core/titles/song.py b/devine/core/titles/song.py index 4cb0b85..04f1652 100644 --- a/devine/core/titles/song.py +++ b/devine/core/titles/song.py @@ -129,20 +129,7 @@ class Album(SortedKeyList, ABC): def __str__(self) -> str: if not self: return super().__str__() - - lines = [ - f"Album: {self[0].album} ({self[0].year or '?'})", - f"Artist: {self[0].artist}", - f"Tracks: ({len(self)})", - *[ - f"├─ {song.track:02}. {song.name}" - for song in self - ] - ] - last_line = lines.pop(-1) - lines.append(last_line.replace("├", "└")) - - return "\n".join(lines) + return f"{self[0].artist} - {self[0].album} ({self[0].year or '?'})" __ALL__ = (Song, Album)