Reformat code

master
Felix Stupp 2 years ago
parent 1e748c4f1a
commit 203a9abaaa
Signed by: zocker
GPG Key ID: 93E1BD26F6B02FB7

@ -45,13 +45,13 @@ from pony import orm
from entertainment_decider import common
from entertainment_decider.models import (
MediaCollection,
MediaCollectionLink,
MediaElement,
Query,
Tag,
are_multiple_considered,
db,
MediaCollection,
MediaCollectionLink,
MediaElement,
get_all_considered,
setup_custom_tables,
update_element_lookup_cache,

@ -1,6 +1,15 @@
from __future__ import annotations
from typing import Any, Dict, List, Literal, Optional, TypeVar, TypedDict, Union
from typing import (
Any,
Dict,
List,
Literal,
Optional,
TypeVar,
TypedDict,
Union,
)
Weekdays = Union[
@ -19,11 +28,13 @@ class TvmazeCountry(TypedDict):
code: str
timezone: str
class TvmazeEmbeddings(TypedDict, total=False):
show: TvmazeShow
seasons: List[TvmazeSeason]
episodes: List[TvmazeEpisode]
class TvmazeEpisode(TypedDict):
id: int
url: str
@ -39,18 +50,22 @@ class TvmazeEpisode(TypedDict):
image: TvmazeImage
summary: str
class TvmazeEpisodeEmbedded(TvmazeEpisode):
_embedded: TvmazeEmbeddings
class TvmazeExternalIds(TypedDict):
tvrage: Optional[int]
thetvdb: Optional[int]
imdb: Optional[str]
class TvmazeImage(TypedDict):
medium: Optional[str]
original: str
def select_best_image(*image_list: TvmazeImage) -> Optional[str]:
for image in image_list:
if image is not None:
@ -59,6 +74,7 @@ def select_best_image(*image_list: TvmazeImage) -> Optional[str]:
return found
return None
class TvmazeNetwork(TypedDict):
id: int
name: str
@ -66,13 +82,16 @@ class TvmazeNetwork(TypedDict):
webChannel: Optional[Any]
dvdCountry: Optional[TvmazeCountry]
class TvmazeRating(TypedDict):
average: int
class TvmazeSchedule(TypedDict):
time: str
days: List[Weekdays]
class TvmazeSeason(TypedDict):
id: int
url: str
@ -86,6 +105,7 @@ class TvmazeSeason(TypedDict):
image: TvmazeImage
summary: str
class TvmazeShow(TypedDict):
id: int
url: str
@ -107,11 +127,14 @@ class TvmazeShow(TypedDict):
summary: str
updated: int
class TvmazeShowEmbedded(TvmazeShow):
_embedded: TvmazeEmbeddings
T = TypeVar("T", bound=Dict)
def add_embedding(object: T, key: str, value: Any, parent_key: str = "_embedded") -> T:
if parent_key not in object:
object[parent_key] = {}

@ -19,7 +19,6 @@ DataType: TypeAlias = List[List[MediaElement]]
class AggregatedCollectionExtractor(CollectionExtractor[DataType]):
__uri_regex = re.compile(r"^aggregated:///(?P<id>\d+(,\d+)*)")
@classmethod

@ -3,7 +3,13 @@ from __future__ import annotations
from datetime import datetime, timedelta
import logging
import math
from typing import Any, Callable, Mapping, Optional, TypeVar
from typing import (
Any,
Callable,
Mapping,
Optional,
TypeVar,
)
from pony import orm

@ -25,7 +25,6 @@ T = TypeVar("T")
class TmdbBaseExtractor(CollectionExtractor[T]):
TMDB_CLASS: ClassVar[str]
SUPPORTED_PATTERN = re.compile(
@ -72,7 +71,6 @@ class TmdbBaseExtractor(CollectionExtractor[T]):
class TmdbCollectionExtractor(TmdbBaseExtractor[TmdbCollectionData]):
TMDB_CLASS = "collection"
def _extract_online(self, uri: str) -> ExtractedDataOnline[TmdbCollectionData]:
@ -112,7 +110,6 @@ class TmdbCollectionExtractor(TmdbBaseExtractor[TmdbCollectionData]):
class TmdbKeywordExtractor(TmdbBaseExtractor[TmdbKeywordData]):
TMDB_CLASS = "keyword"
def _extract_online(self, uri: str) -> ExtractedDataOnline[TmdbKeywordData]:

@ -18,7 +18,6 @@ from .base import CollectionExtractor
class TtRssCollectionExtractor(CollectionExtractor[HeadlineList]):
__params: TtRssConnectionParameter
__label_filter: Optional[int]
__mark_as_read: bool

@ -8,8 +8,15 @@ from typing import List, Optional
from pony import orm # TODO remove
import requests
from ...models import MediaCollection, Tag
from ..all.tvmaze import TvmazeEpisodeEmbedded, TvmazeShowEmbedded, add_embedding
from ...models import (
MediaCollection,
Tag,
)
from ..all.tvmaze import (
TvmazeEpisodeEmbedded,
TvmazeShowEmbedded,
add_embedding,
)
from ..generic import (
ChangedReport,
ExtractedDataOnline,
@ -20,7 +27,6 @@ from .base import CollectionExtractor
class TvmazeCollectionExtractor(CollectionExtractor[TvmazeShowEmbedded]):
SUPPORTED_PATTERN = re.compile(
r"""^
(

@ -8,7 +8,10 @@ from enum import Enum
import logging
from typing import Generic, Optional, TypeVar
from ..models import MediaCollection, MediaElement
from ..models import (
MediaCollection,
MediaElement,
)
T = TypeVar("T")
@ -33,7 +36,6 @@ class ChangedReport(Enum):
class SuitableLevel(Enum):
NO = (False, False)
FALLBACK = (True, False)
ALWAYS = (True, True)
@ -142,10 +144,14 @@ E = TypeVar("E", MediaElement, MediaCollection)
class GeneralExtractor(Generic[E, T]):
name: str
def __init__(self, name: str):
def __init__(
self,
name: str,
):
self.key = key
self.long_name = long_name
self.name = name
# abstract (for media & collection base classes)

@ -6,8 +6,16 @@ from typing import List, Optional
from pony import orm
from ...models import MediaElement, MediaThumbnail, Query, Tag
from ..all.tmdb import TmdbMovieData, TMDB_REGEX_URI
from ...models import (
MediaElement,
MediaThumbnail,
Query,
Tag,
)
from ..all.tmdb import (
TMDB_REGEX_URI,
TmdbMovieData,
)
from ..generic import (
ChangedReport,
ExtractedDataOnline,
@ -19,7 +27,6 @@ from .base import MediaExtractor
class TmdbMovieMediaExtractor(MediaExtractor[TmdbMovieData]):
SUPPORTED_PATTERN = re.compile(
rf"""^
{TMDB_REGEX_URI}

@ -7,7 +7,11 @@ from typing import Optional
import requests
from ...models import MediaElement, MediaThumbnail
from ..all.tvmaze import TvmazeEpisodeEmbedded, TvmazeShowEmbedded, select_best_image
from ..all.tvmaze import (
TvmazeEpisodeEmbedded,
TvmazeShowEmbedded,
select_best_image,
)
from ..generic import (
ChangedReport,
ExtractedDataOnline,
@ -19,7 +23,6 @@ from .base import MediaExtractor
class TvmazeMediaExtractor(MediaExtractor[TvmazeEpisodeEmbedded]):
SUPPORTED_PATTERN = re.compile(
r"""^
(

@ -5,7 +5,10 @@ import logging
import re
from typing import Optional
from youtubesearchpython import ResultMode, Video
from youtubesearchpython import (
ResultMode,
Video,
)
from ...models import (
MediaElement,

@ -23,7 +23,6 @@ from .base import MediaExtractor
class YtdlMediaExtractor(MediaExtractor[Dict]):
SUPPORTED_PATTERN = re.compile(
r"""^
https?://

Loading…
Cancel
Save