From 8423fb1933e6bfbf67bbf41f8fe98fde05f052e3 Mon Sep 17 00:00:00 2001 From: Chris Talkington Date: Sat, 4 Apr 2020 19:10:17 -0500 Subject: [PATCH 01/52] Update sonarr.py --- sonarr/sonarr.py | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/sonarr/sonarr.py b/sonarr/sonarr.py index 104b2b07..b2a8cb7a 100644 --- a/sonarr/sonarr.py +++ b/sonarr/sonarr.py @@ -10,7 +10,7 @@ from .__version__ import __version__ from .exceptions import SonarrAccessRestricted, SonarrConnectionError, SonarrError -from .models import Application +from .models import Application, Episode class Sonarr: @@ -137,6 +137,23 @@ async def update(self, full_update: bool = False) -> Application: self._application.update_from_dict({"diskspace": diskspace}) return self._application + async def calendar(self, start: int = None, end: int = None) -> List[Episode]: + """Gets upcoming episodes. + + If start/end are not supplied, episodes airing today and tomorrow will be returned. + """ + params = {} + + if start is not None: + params["start"] = start + + if end is not None: + params["end"] = end + + results = await self._request("calendar", params=params) + + rerurn [Episode.from_dict(result) for result in results] + async def close(self) -> None: """Close open client session.""" if self._session and self._close_session: From 9f2b3383837d06dc7edcefe1b87ade2ed0fbec16 Mon Sep 17 00:00:00 2001 From: Chris Talkington Date: Sat, 4 Apr 2020 19:29:42 -0500 Subject: [PATCH 02/52] Update models.py --- sonarr/models.py | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/sonarr/models.py b/sonarr/models.py index 8904b618..0307fe34 100644 --- a/sonarr/models.py +++ b/sonarr/models.py @@ -1,6 +1,7 @@ """Models for DirecTV.""" from dataclasses import dataclass +from datetime import datetime, timezone from typing import List from .exceptions import SonarrError @@ -26,6 +27,38 @@ def from_dict(data: dict): ) +@dataclass(frozen=True) +class Episode: + """Object holding episode information from Sonarr.""" + + tvdb_id: int + episode_id: int + episode_number: int + season_number: int + title: str + overview: str + aired: datetime + downloading: bool + + @staticmethod + def from_dict(data: dict): + """Return Episode object from Sonarr API response.""" + aired = data.get("airDateUtc", None) + if aired: + aired = datetime.strptime(aired) + + return Episode( + tvdb_id=data.get("tvDbEpisodeId", 0), + episode_id=data.get("id", 0), + episode_number=data.get("episodeNumber", 0), + season_number=data.get("seasonNumber",0), + title=data.get("title", ""), + overview=data.get("overview", ""), + aired=aired, + downloading=data.get("downloading", False", + ) + + @dataclass(frozen=True) class Info: """Object holding information from Sonarr.""" From 0770b2c6daf1874859f901f25af821751e264630 Mon Sep 17 00:00:00 2001 From: Chris Talkington Date: Sat, 4 Apr 2020 19:31:43 -0500 Subject: [PATCH 03/52] Update models.py --- sonarr/models.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sonarr/models.py b/sonarr/models.py index 0307fe34..34258be4 100644 --- a/sonarr/models.py +++ b/sonarr/models.py @@ -55,7 +55,7 @@ def from_dict(data: dict): title=data.get("title", ""), overview=data.get("overview", ""), aired=aired, - downloading=data.get("downloading", False", + downloading=data.get("downloading", False), ) From d674d3ce99812b9cdf6d18b20ef123d545f266dc Mon Sep 17 00:00:00 2001 From: Chris Talkington Date: Sat, 4 Apr 2020 19:45:09 -0500 Subject: [PATCH 04/52] Update models.py --- sonarr/models.py | 34 +++++++++++++++++++++++++++++++--- 1 file changed, 31 insertions(+), 3 deletions(-) diff --git a/sonarr/models.py b/sonarr/models.py index 34258be4..07c2ecd0 100644 --- a/sonarr/models.py +++ b/sonarr/models.py @@ -27,6 +27,32 @@ def from_dict(data: dict): ) +@dataclass(frozen=True) +class Series: + """Object holding series information from Sonarr.""" + + tvdb_id: int + series_id: int + status: str + title: str + network: str + runtime: int + timeslot: str + + @staticmethod + def from_dict(data: dict): + """Return Series object from Sonarr API response.""" + return Series( + tvdb_id=data.get("tvdbId", 0), + series_id=data.get("id", 0), + status=data.get("status", "unknown"), + title=data.get("title", ""), + network=data.get("network", "Unknown"), + runtime=data.get("runtime", 0), + timeslot=data.get("airTime", ""), + ) + + @dataclass(frozen=True) class Episode: """Object holding episode information from Sonarr.""" @@ -37,15 +63,16 @@ class Episode: season_number: int title: str overview: str - aired: datetime + airs: datetime downloading: bool + series: Series @staticmethod def from_dict(data: dict): """Return Episode object from Sonarr API response.""" aired = data.get("airDateUtc", None) - if aired: - aired = datetime.strptime(aired) + if aired is not None: + aired = datetime.strptime(aired, "%Y-%m-%dT%H:%M:%S%z") return Episode( tvdb_id=data.get("tvDbEpisodeId", 0), @@ -56,6 +83,7 @@ def from_dict(data: dict): overview=data.get("overview", ""), aired=aired, downloading=data.get("downloading", False), + series=Series.from_dict(data.get("series", {})), ) From 8aee2960112c548ce521ae69def0dbc44b91948b Mon Sep 17 00:00:00 2001 From: Chris Talkington Date: Sat, 4 Apr 2020 19:50:35 -0500 Subject: [PATCH 05/52] Update models.py --- sonarr/models.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/sonarr/models.py b/sonarr/models.py index 07c2ecd0..63f20f5d 100644 --- a/sonarr/models.py +++ b/sonarr/models.py @@ -42,6 +42,10 @@ class Series: @staticmethod def from_dict(data: dict): """Return Series object from Sonarr API response.""" + premiered = data.get("firstAired", None) + if premiered is not None: + premiered = datetime.strptime(premiered, "%Y-%m-%dT%H:%M:%S%z") + return Series( tvdb_id=data.get("tvdbId", 0), series_id=data.get("id", 0), @@ -50,6 +54,7 @@ def from_dict(data: dict): network=data.get("network", "Unknown"), runtime=data.get("runtime", 0), timeslot=data.get("airTime", ""), + premiered=premiered, ) @@ -73,7 +78,7 @@ def from_dict(data: dict): aired = data.get("airDateUtc", None) if aired is not None: aired = datetime.strptime(aired, "%Y-%m-%dT%H:%M:%S%z") - + return Episode( tvdb_id=data.get("tvDbEpisodeId", 0), episode_id=data.get("id", 0), @@ -91,13 +96,13 @@ def from_dict(data: dict): class Info: """Object holding information from Sonarr.""" - brand: str + app_name: str version: str @staticmethod def from_dict(data: dict): """Return Info object from Sonarr API response.""" - return Info(brand="Sonarr", version=data.get("version", "Unknown")) + return Info(app_name="Sonarr", version=data.get("version", "Unknown")) class Application: From 9efe1969a9c7f571d3f4ecaa78aa3ddd62e8ac8b Mon Sep 17 00:00:00 2001 From: Chris Talkington Date: Sat, 4 Apr 2020 20:04:01 -0500 Subject: [PATCH 06/52] Update test_models.py --- tests/test_models.py | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/tests/test_models.py b/tests/test_models.py index d41613eb..2564422e 100644 --- a/tests/test_models.py +++ b/tests/test_models.py @@ -1,4 +1,5 @@ """Tests for Sonarr Models.""" +from datetime import datetime, timezone import json import pytest @@ -8,6 +9,7 @@ from . import load_fixture INFO = json.loads(load_fixture("system-status.json")) +CALENDAR = json.loads(load_fixture("calendar.json")) DISKSPACE = json.loads(load_fixture("diskspace.json")) APPLICATION = {"info": INFO, "diskspace": DISKSPACE} @@ -37,7 +39,16 @@ def test_info() -> None: info = models.Info.from_dict(INFO) assert info - assert info.brand == "Sonarr" + assert info.app_name == "Sonarr" + assert info.version == "2.0.0.1121" + + +def test_episode() -> None: + """Test the Episode model.""" + info = models.Info.from_dict(CALENDAR[1]) + + assert info + assert info.app_name == "Sonarr" assert info.version == "2.0.0.1121" @@ -50,3 +61,18 @@ def test_disk() -> None: assert disk.label == "" assert disk.free == 282500067328 assert disk.total == 499738734592 + +def test_series() -> None: + """Test the Series model.""" + series = models.Series.from_dict(CALENDAR[1]["series"]) + + assert series + assert series.tvdb_id == 1 + assert series.series_id == 1 + assert series.slug == "bobs-burger" + assert series.title == "Bob's Burgers" + assert series.overview == "Bob's Burgers follows a third-generation restaurateur, Bob, as he runs Bob's Burgers with the help of his wife and their three kids. Bob and his quirky family have big ideas about burgers, but fall short on service and sophistication. Despite the greasy counters, lousy location and a dearth of customers, Bob and his family are determined to make Bob's Burgers \"grand re-re-re-opening\" a success." + assert series.network == "Fox" + assert series.runtime == 20 + assert series.timeslot == "5:30pm" + assert series.premiered == datetime(2010, 7, 5, 15, 0, 8, tzinfo=timezone.utc) From a991eff99c073ed9f03795ce1d336019ae812aba Mon Sep 17 00:00:00 2001 From: Chris Talkington Date: Sat, 4 Apr 2020 20:05:18 -0500 Subject: [PATCH 07/52] Create calendar.json --- tests/fixtures/calendar.json | 107 +++++++++++++++++++++++++++++++++++ 1 file changed, 107 insertions(+) create mode 100644 tests/fixtures/calendar.json diff --git a/tests/fixtures/calendar.json b/tests/fixtures/calendar.json new file mode 100644 index 00000000..dbf5a7c9 --- /dev/null +++ b/tests/fixtures/calendar.json @@ -0,0 +1,107 @@ +[ + { + "seriesId": 3, + "episodeFileId": 0, + "seasonNumber": 4, + "episodeNumber": 11, + "title": "Easy Com-mercial, Easy Go-mercial", + "airDate": "2014-01-26", + "airDateUtc": "2014-01-27T01:30:00Z", + "overview": "To compete with fellow “restaurateur,” Jimmy Pesto, and his blowout Super Bowl event, Bob is determined to create a Bob’s Burgers commercial to air during the “big game.” In an effort to outshine Pesto, the Belchers recruit Randy, a documentarian, to assist with the filmmaking and hire on former pro football star Connie Frye to be the celebrity endorser.", + "hasFile": false, + "monitored": true, + "sceneEpisodeNumber": 0, + "sceneSeasonNumber": 0, + "tvDbEpisodeId": 0, + "series": { + "tvdbId": 194031, + "tvRageId": 24607, + "imdbId": "tt1561755", + "title": "Bob's Burgers", + "cleanTitle": "bobsburgers", + "status": "continuing", + "overview": "Bob's Burgers follows a third-generation restaurateur, Bob, as he runs Bob's Burgers with the help of his wife and their three kids. Bob and his quirky family have big ideas about burgers, but fall short on service and sophistication. Despite the greasy counters, lousy location and a dearth of customers, Bob and his family are determined to make Bob's Burgers \"grand re-re-re-opening\" a success.", + "airTime": "5:30pm", + "monitored": true, + "qualityProfileId": 1, + "seasonFolder": true, + "lastInfoSync": "2014-01-26T19:25:55.4555946Z", + "runtime": 30, + "images": [ + { + "coverType": "banner", + "url": "http://slurm.trakt.us/images/banners/1387.6.jpg" + }, + { + "coverType": "poster", + "url": "http://slurm.trakt.us/images/posters/1387.6-300.jpg" + }, + { + "coverType": "fanart", + "url": "http://slurm.trakt.us/images/fanart/1387.6.jpg" + } + ], + "seriesType": "standard", + "network": "FOX", + "useSceneNumbering": false, + "titleSlug": "bobs-burgers", + "path": "T:\\Bob's Burgers", + "year": 0, + "firstAired": "2011-01-10T01:30:00Z", + "qualityProfile": { + "value": { + "name": "SD", + "allowed": [ + { + "id": 1, + "name": "SDTV", + "weight": 1 + }, + { + "id": 8, + "name": "WEBDL-480p", + "weight": 2 + }, + { + "id": 2, + "name": "DVD", + "weight": 3 + } + ], + "cutoff": { + "id": 1, + "name": "SDTV", + "weight": 1 + }, + "id": 1 + }, + "isLoaded": true + }, + "seasons": [ + { + "seasonNumber": 4, + "monitored": true + }, + { + "seasonNumber": 3, + "monitored": true + }, + { + "seasonNumber": 2, + "monitored": true + }, + { + "seasonNumber": 1, + "monitored": true + }, + { + "seasonNumber": 0, + "monitored": false + } + ], + "id": 66 + }, + "downloading": false, + "id": 14402 + } +] From b0a0fc9bf53f111348cbdb2a8cc40352673e38c9 Mon Sep 17 00:00:00 2001 From: Chris Talkington Date: Sat, 4 Apr 2020 20:09:53 -0500 Subject: [PATCH 08/52] Update test_models.py --- tests/test_models.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/tests/test_models.py b/tests/test_models.py index 2564422e..e46e818b 100644 --- a/tests/test_models.py +++ b/tests/test_models.py @@ -45,11 +45,17 @@ def test_info() -> None: def test_episode() -> None: """Test the Episode model.""" - info = models.Info.from_dict(CALENDAR[1]) - - assert info - assert info.app_name == "Sonarr" - assert info.version == "2.0.0.1121" + episode = models.Info.from_dict(CALENDAR[1]) + + assert episode + assert episode.tvdb_id == 1 + assert episode.episode_id == 1 + assert episode.episode_number == 1 + assert episode.season_number == 1 + assert isinstance(episode.series, Series) + assert episode.title == "" + assert episode.overview == "" + assert episode.airs == datetime(2010, 7, 5, 15, 0, 8, tzinfo=timezone.utc) def test_disk() -> None: From 295139d94bbf3513c638713030341007c5211e48 Mon Sep 17 00:00:00 2001 From: Chris Talkington Date: Sat, 4 Apr 2020 20:12:48 -0500 Subject: [PATCH 09/52] Update models.py --- sonarr/models.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sonarr/models.py b/sonarr/models.py index 63f20f5d..a6ea4be7 100644 --- a/sonarr/models.py +++ b/sonarr/models.py @@ -33,6 +33,7 @@ class Series: tvdb_id: int series_id: int + slug: str status: str title: str network: str @@ -49,6 +50,7 @@ def from_dict(data: dict): return Series( tvdb_id=data.get("tvdbId", 0), series_id=data.get("id", 0), + slug=data.get("titleSlug", ""), status=data.get("status", "unknown"), title=data.get("title", ""), network=data.get("network", "Unknown"), From b100e61d1b55aefc6b7f4bc0cf854cbcd05e28f1 Mon Sep 17 00:00:00 2001 From: Chris Talkington Date: Sat, 4 Apr 2020 20:13:56 -0500 Subject: [PATCH 10/52] Update test_models.py --- tests/test_models.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/test_models.py b/tests/test_models.py index e46e818b..32fe9b3b 100644 --- a/tests/test_models.py +++ b/tests/test_models.py @@ -75,6 +75,7 @@ def test_series() -> None: assert series assert series.tvdb_id == 1 assert series.series_id == 1 + assert series.status == "continuing" assert series.slug == "bobs-burger" assert series.title == "Bob's Burgers" assert series.overview == "Bob's Burgers follows a third-generation restaurateur, Bob, as he runs Bob's Burgers with the help of his wife and their three kids. Bob and his quirky family have big ideas about burgers, but fall short on service and sophistication. Despite the greasy counters, lousy location and a dearth of customers, Bob and his family are determined to make Bob's Burgers \"grand re-re-re-opening\" a success." From 352ba1b2cec780f28e008a4fa660d13b02b55fed Mon Sep 17 00:00:00 2001 From: Chris Talkington Date: Sat, 4 Apr 2020 20:24:41 -0500 Subject: [PATCH 11/52] Update test_models.py --- tests/test_models.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/test_models.py b/tests/test_models.py index 32fe9b3b..e0a52425 100644 --- a/tests/test_models.py +++ b/tests/test_models.py @@ -1,6 +1,6 @@ """Tests for Sonarr Models.""" -from datetime import datetime, timezone import json +from datetime import datetime, timezone import pytest import sonarr.models as models @@ -45,7 +45,7 @@ def test_info() -> None: def test_episode() -> None: """Test the Episode model.""" - episode = models.Info.from_dict(CALENDAR[1]) + episode = models.Episode.from_dict(CALENDAR[1]) assert episode assert episode.tvdb_id == 1 From 6c4c812542146022b51ee2037360d3a33ec63e18 Mon Sep 17 00:00:00 2001 From: Chris Talkington Date: Sat, 4 Apr 2020 20:26:46 -0500 Subject: [PATCH 12/52] Update sonarr.py --- sonarr/sonarr.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sonarr/sonarr.py b/sonarr/sonarr.py index b2a8cb7a..c060244f 100644 --- a/sonarr/sonarr.py +++ b/sonarr/sonarr.py @@ -152,7 +152,7 @@ async def calendar(self, start: int = None, end: int = None) -> List[Episode]: results = await self._request("calendar", params=params) - rerurn [Episode.from_dict(result) for result in results] + return [Episode.from_dict(result) for result in results] async def close(self) -> None: """Close open client session.""" From 78a6fa7d52dbaa9b59d0d78bcfd1d630b9804b49 Mon Sep 17 00:00:00 2001 From: Chris Talkington Date: Sat, 4 Apr 2020 20:33:18 -0500 Subject: [PATCH 13/52] Update models.py --- sonarr/models.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sonarr/models.py b/sonarr/models.py index a6ea4be7..eff2b232 100644 --- a/sonarr/models.py +++ b/sonarr/models.py @@ -85,7 +85,7 @@ def from_dict(data: dict): tvdb_id=data.get("tvDbEpisodeId", 0), episode_id=data.get("id", 0), episode_number=data.get("episodeNumber", 0), - season_number=data.get("seasonNumber",0), + season_number=data.get("seasonNumber", 0), title=data.get("title", ""), overview=data.get("overview", ""), aired=aired, From f3131da1ada5988b8107dc279583815c7f13cd4e Mon Sep 17 00:00:00 2001 From: Chris Talkington Date: Sat, 4 Apr 2020 20:34:43 -0500 Subject: [PATCH 14/52] Update test_models.py --- tests/test_models.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tests/test_models.py b/tests/test_models.py index e0a52425..83f46913 100644 --- a/tests/test_models.py +++ b/tests/test_models.py @@ -78,7 +78,10 @@ def test_series() -> None: assert series.status == "continuing" assert series.slug == "bobs-burger" assert series.title == "Bob's Burgers" - assert series.overview == "Bob's Burgers follows a third-generation restaurateur, Bob, as he runs Bob's Burgers with the help of his wife and their three kids. Bob and his quirky family have big ideas about burgers, but fall short on service and sophistication. Despite the greasy counters, lousy location and a dearth of customers, Bob and his family are determined to make Bob's Burgers \"grand re-re-re-opening\" a success." + assert ( + series.overview + == "Bob's Burgers follows a third-generation restaurateur, Bob, as he runs Bob's Burgers with the help of his wife and their three kids. Bob and his quirky family have big ideas about burgers, but fall short on service and sophistication. Despite the greasy counters, lousy location and a dearth of customers, Bob and his family are determined to make Bob's Burgers \"grand re-re-re-opening\" a success." + ) assert series.network == "Fox" assert series.runtime == 20 assert series.timeslot == "5:30pm" From a1f242e03c2964970c71776aba96d28ddc6990e8 Mon Sep 17 00:00:00 2001 From: Chris Talkington Date: Sat, 4 Apr 2020 20:35:22 -0500 Subject: [PATCH 15/52] Update test_models.py --- tests/test_models.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_models.py b/tests/test_models.py index 83f46913..959eee57 100644 --- a/tests/test_models.py +++ b/tests/test_models.py @@ -52,7 +52,7 @@ def test_episode() -> None: assert episode.episode_id == 1 assert episode.episode_number == 1 assert episode.season_number == 1 - assert isinstance(episode.series, Series) + assert isinstance(episode.series, models.Series) assert episode.title == "" assert episode.overview == "" assert episode.airs == datetime(2010, 7, 5, 15, 0, 8, tzinfo=timezone.utc) From 5bd43280c11348d7276a96a3d73e2d54c7326ea4 Mon Sep 17 00:00:00 2001 From: Chris Talkington Date: Sat, 4 Apr 2020 20:37:03 -0500 Subject: [PATCH 16/52] Update sonarr.py --- sonarr/sonarr.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/sonarr/sonarr.py b/sonarr/sonarr.py index c060244f..bc5bfeb3 100644 --- a/sonarr/sonarr.py +++ b/sonarr/sonarr.py @@ -2,7 +2,7 @@ import asyncio import json from socket import gaierror as SocketGIAError -from typing import Any, Mapping, Optional +from typing import Any, List, Mapping, Optional import aiohttp import async_timeout @@ -138,9 +138,10 @@ async def update(self, full_update: bool = False) -> Application: return self._application async def calendar(self, start: int = None, end: int = None) -> List[Episode]: - """Gets upcoming episodes. + """Get upcoming episodes. - If start/end are not supplied, episodes airing today and tomorrow will be returned. + If start/end are not supplied, episodes airing + today and tomorrow will be returned. """ params = {} From aba8aaeba58f496024ce2f51a3c0804d5d3a55de Mon Sep 17 00:00:00 2001 From: Chris Talkington Date: Sat, 4 Apr 2020 20:37:16 -0500 Subject: [PATCH 17/52] Update models.py --- sonarr/models.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sonarr/models.py b/sonarr/models.py index eff2b232..8c4da5bb 100644 --- a/sonarr/models.py +++ b/sonarr/models.py @@ -1,7 +1,7 @@ """Models for DirecTV.""" from dataclasses import dataclass -from datetime import datetime, timezone +from datetime import datetime from typing import List from .exceptions import SonarrError From eaec9fcacf787f48e21250ad12071866d5edbc09 Mon Sep 17 00:00:00 2001 From: Chris Talkington Date: Sat, 4 Apr 2020 20:43:23 -0500 Subject: [PATCH 18/52] Update models.py --- sonarr/models.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/sonarr/models.py b/sonarr/models.py index 8c4da5bb..d3f44368 100644 --- a/sonarr/models.py +++ b/sonarr/models.py @@ -36,6 +36,7 @@ class Series: slug: str status: str title: str + overview: str network: str runtime: int timeslot: str @@ -53,6 +54,7 @@ def from_dict(data: dict): slug=data.get("titleSlug", ""), status=data.get("status", "unknown"), title=data.get("title", ""), + overview=data.get("overview", ""), network=data.get("network", "Unknown"), runtime=data.get("runtime", 0), timeslot=data.get("airTime", ""), @@ -77,9 +79,9 @@ class Episode: @staticmethod def from_dict(data: dict): """Return Episode object from Sonarr API response.""" - aired = data.get("airDateUtc", None) - if aired is not None: - aired = datetime.strptime(aired, "%Y-%m-%dT%H:%M:%S%z") + airs = data.get("airDateUtc", None) + if airs is not None: + airs = datetime.strptime(airs, "%Y-%m-%dT%H:%M:%S%z") return Episode( tvdb_id=data.get("tvDbEpisodeId", 0), @@ -88,7 +90,7 @@ def from_dict(data: dict): season_number=data.get("seasonNumber", 0), title=data.get("title", ""), overview=data.get("overview", ""), - aired=aired, + airs=airs, downloading=data.get("downloading", False), series=Series.from_dict(data.get("series", {})), ) From 64bf2c2bde285b597b4b0bb686e61d0365e7a7ff Mon Sep 17 00:00:00 2001 From: Chris Talkington Date: Sat, 4 Apr 2020 20:44:52 -0500 Subject: [PATCH 19/52] Update models.py --- sonarr/models.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/sonarr/models.py b/sonarr/models.py index d3f44368..590b75bd 100644 --- a/sonarr/models.py +++ b/sonarr/models.py @@ -40,13 +40,14 @@ class Series: network: str runtime: int timeslot: str + premieres: datetime @staticmethod def from_dict(data: dict): """Return Series object from Sonarr API response.""" - premiered = data.get("firstAired", None) - if premiered is not None: - premiered = datetime.strptime(premiered, "%Y-%m-%dT%H:%M:%S%z") + premieres = data.get("firstAired", None) + if premieres is not None: + premieres = datetime.strptime(premieres, "%Y-%m-%dT%H:%M:%S%z") return Series( tvdb_id=data.get("tvdbId", 0), @@ -58,7 +59,7 @@ def from_dict(data: dict): network=data.get("network", "Unknown"), runtime=data.get("runtime", 0), timeslot=data.get("airTime", ""), - premiered=premiered, + premieres=premieres, ) From 54df55ae5083cb50cf33ebe249e15432917258e2 Mon Sep 17 00:00:00 2001 From: Chris Talkington Date: Sat, 4 Apr 2020 20:48:21 -0500 Subject: [PATCH 20/52] Update sonarr.py --- sonarr/sonarr.py | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/sonarr/sonarr.py b/sonarr/sonarr.py index bc5bfeb3..6b038bfd 100644 --- a/sonarr/sonarr.py +++ b/sonarr/sonarr.py @@ -143,13 +143,10 @@ async def calendar(self, start: int = None, end: int = None) -> List[Episode]: If start/end are not supplied, episodes airing today and tomorrow will be returned. """ - params = {} - - if start is not None: - params["start"] = start - - if end is not None: - params["end"] = end + params = { + "start": start if start is not None, + "end": end if end is not None + } results = await self._request("calendar", params=params) From 4babc29d91d5664e063de45e59b8e27fc14946f8 Mon Sep 17 00:00:00 2001 From: Chris Talkington Date: Sat, 4 Apr 2020 20:48:43 -0500 Subject: [PATCH 21/52] Update sonarr.py --- sonarr/sonarr.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sonarr/sonarr.py b/sonarr/sonarr.py index 6b038bfd..e162ccde 100644 --- a/sonarr/sonarr.py +++ b/sonarr/sonarr.py @@ -145,7 +145,7 @@ async def calendar(self, start: int = None, end: int = None) -> List[Episode]: """ params = { "start": start if start is not None, - "end": end if end is not None + "end": end if end is not None, } results = await self._request("calendar", params=params) From 6a27e1d0d9b29c44a7246e70510a72bbdc37e5e0 Mon Sep 17 00:00:00 2001 From: Chris Talkington Date: Sat, 4 Apr 2020 20:53:46 -0500 Subject: [PATCH 22/52] Update sonarr.py --- sonarr/sonarr.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/sonarr/sonarr.py b/sonarr/sonarr.py index e162ccde..a248e994 100644 --- a/sonarr/sonarr.py +++ b/sonarr/sonarr.py @@ -144,10 +144,16 @@ async def calendar(self, start: int = None, end: int = None) -> List[Episode]: today and tomorrow will be returned. """ params = { - "start": start if start is not None, - "end": end if end is not None, + "start": start, + "end": end, } + if start is None: + del params["start"] + + if end is None: + del params["end"] + results = await self._request("calendar", params=params) return [Episode.from_dict(result) for result in results] From 9e3eee0315b07b07a4a6cc41796f58b24f18403e Mon Sep 17 00:00:00 2001 From: Chris Talkington Date: Sat, 4 Apr 2020 20:56:49 -0500 Subject: [PATCH 23/52] Update test_models.py --- tests/test_models.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/test_models.py b/tests/test_models.py index 959eee57..c1de264a 100644 --- a/tests/test_models.py +++ b/tests/test_models.py @@ -79,8 +79,10 @@ def test_series() -> None: assert series.slug == "bobs-burger" assert series.title == "Bob's Burgers" assert ( - series.overview - == "Bob's Burgers follows a third-generation restaurateur, Bob, as he runs Bob's Burgers with the help of his wife and their three kids. Bob and his quirky family have big ideas about burgers, but fall short on service and sophistication. Despite the greasy counters, lousy location and a dearth of customers, Bob and his family are determined to make Bob's Burgers \"grand re-re-re-opening\" a success." + series.overview + == """Bob's Burgers follows a third-generation restaurateur, Bob, as he runs Bob's Burgers with the help of his wife and their three kids. + Bob and his quirky family have big ideas about burgers, but fall short on service and sophistication. + Despite the greasy counters, lousy location and a dearth of customers, Bob and his family are determined to make Bob's Burgers \"grand re-re-re-opening\" a success.""" ) assert series.network == "Fox" assert series.runtime == 20 From 2948bebfca18e1bda51651870b0a470cd4f5f75a Mon Sep 17 00:00:00 2001 From: Chris Talkington Date: Sat, 4 Apr 2020 20:57:11 -0500 Subject: [PATCH 24/52] Update test_models.py --- tests/test_models.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_models.py b/tests/test_models.py index c1de264a..57b8f9ab 100644 --- a/tests/test_models.py +++ b/tests/test_models.py @@ -87,4 +87,4 @@ def test_series() -> None: assert series.network == "Fox" assert series.runtime == 20 assert series.timeslot == "5:30pm" - assert series.premiered == datetime(2010, 7, 5, 15, 0, 8, tzinfo=timezone.utc) + assert series.premieres == datetime(2010, 7, 5, 15, 0, 8, tzinfo=timezone.utc) From a81e5448da6e9761d3b914dd815b4d6ee342a44b Mon Sep 17 00:00:00 2001 From: Chris Talkington Date: Sat, 4 Apr 2020 21:09:56 -0500 Subject: [PATCH 25/52] Update test_models.py --- tests/test_models.py | 33 ++++++++++++++++++++++----------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/tests/test_models.py b/tests/test_models.py index 57b8f9ab..fe8c727d 100644 --- a/tests/test_models.py +++ b/tests/test_models.py @@ -48,13 +48,21 @@ def test_episode() -> None: episode = models.Episode.from_dict(CALENDAR[1]) assert episode - assert episode.tvdb_id == 1 - assert episode.episode_id == 1 - assert episode.episode_number == 1 - assert episode.season_number == 1 + assert episode.tvdb_id == 0 + assert episode.episode_id == 14402 + assert episode.episode_number == 11 + assert episode.season_number == 4 assert isinstance(episode.series, models.Series) - assert episode.title == "" - assert episode.overview == "" + assert episode.title == "Easy Com-mercial, Easy Go-mercial", + assert ( + episode.overview + == """To compete with fellow \"restaurateur,\" Jimmy Pesto, + and his blowout Super Bowl event. Bob is determined to create a + Bob’s Burgers commercial to air during the \"big game.\" + In an effort to outshine Pesto, the Belchers recruit Randy, + a documentarian, to assist with the filmmaking and hire on + former pro football star Connie Frye to be the celebrity endorser.""", + ) assert episode.airs == datetime(2010, 7, 5, 15, 0, 8, tzinfo=timezone.utc) @@ -73,16 +81,19 @@ def test_series() -> None: series = models.Series.from_dict(CALENDAR[1]["series"]) assert series - assert series.tvdb_id == 1 - assert series.series_id == 1 + assert series.tvdb_id == 194031 + assert series.series_id == 3 assert series.status == "continuing" assert series.slug == "bobs-burger" assert series.title == "Bob's Burgers" assert ( series.overview - == """Bob's Burgers follows a third-generation restaurateur, Bob, as he runs Bob's Burgers with the help of his wife and their three kids. - Bob and his quirky family have big ideas about burgers, but fall short on service and sophistication. - Despite the greasy counters, lousy location and a dearth of customers, Bob and his family are determined to make Bob's Burgers \"grand re-re-re-opening\" a success.""" + == """Bob's Burgers follows a third-generation restaurateur, Bob, + as he runs Bob's Burgers with the help of his wife and their three kids. + Bob and his quirky family have big ideas about burgers, but fall short on service + and sophistication. Despite the greasy counters, lousy location and a dearth of + customers, Bob and his family are determined to make Bob's Burgers + \"grand re-re-re-opening\" a success.""" ) assert series.network == "Fox" assert series.runtime == 20 From 6bce46499f28d6e4c33b0cc4ca9e6e10a3c5087e Mon Sep 17 00:00:00 2001 From: Chris Talkington Date: Sat, 4 Apr 2020 21:11:46 -0500 Subject: [PATCH 26/52] Update sonarr.py --- sonarr/sonarr.py | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/sonarr/sonarr.py b/sonarr/sonarr.py index a248e994..bbbae2eb 100644 --- a/sonarr/sonarr.py +++ b/sonarr/sonarr.py @@ -143,16 +143,13 @@ async def calendar(self, start: int = None, end: int = None) -> List[Episode]: If start/end are not supplied, episodes airing today and tomorrow will be returned. """ - params = { - "start": start, - "end": end, - } + params = {} - if start is None: - del params["start"] + if start is not None: + params["start"] = str(start) - if end is None: - del params["end"] + if end is not None: + params["end"] = str(end) results = await self._request("calendar", params=params) From 02dfcc75c0ce2886594e2a0253ec44f5fe263606 Mon Sep 17 00:00:00 2001 From: Chris Talkington Date: Sat, 4 Apr 2020 21:14:40 -0500 Subject: [PATCH 27/52] Update test_models.py --- tests/test_models.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/test_models.py b/tests/test_models.py index fe8c727d..6c137c08 100644 --- a/tests/test_models.py +++ b/tests/test_models.py @@ -53,7 +53,7 @@ def test_episode() -> None: assert episode.episode_number == 11 assert episode.season_number == 4 assert isinstance(episode.series, models.Series) - assert episode.title == "Easy Com-mercial, Easy Go-mercial", + assert episode.title == "Easy Com-mercial, Easy Go-mercial" assert ( episode.overview == """To compete with fellow \"restaurateur,\" Jimmy Pesto, @@ -61,7 +61,7 @@ def test_episode() -> None: Bob’s Burgers commercial to air during the \"big game.\" In an effort to outshine Pesto, the Belchers recruit Randy, a documentarian, to assist with the filmmaking and hire on - former pro football star Connie Frye to be the celebrity endorser.""", + former pro football star Connie Frye to be the celebrity endorser.""" ) assert episode.airs == datetime(2010, 7, 5, 15, 0, 8, tzinfo=timezone.utc) From dbab77268be223aba4202d03700e531a7a4d6d49 Mon Sep 17 00:00:00 2001 From: Chris Talkington Date: Sat, 4 Apr 2020 21:19:25 -0500 Subject: [PATCH 28/52] Update test_models.py --- tests/test_models.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/test_models.py b/tests/test_models.py index 6c137c08..9363d6c8 100644 --- a/tests/test_models.py +++ b/tests/test_models.py @@ -58,7 +58,7 @@ def test_episode() -> None: episode.overview == """To compete with fellow \"restaurateur,\" Jimmy Pesto, and his blowout Super Bowl event. Bob is determined to create a - Bob’s Burgers commercial to air during the \"big game.\" + Bob’s Burgers commercial to air during the \"big game.\" In an effort to outshine Pesto, the Belchers recruit Randy, a documentarian, to assist with the filmmaking and hire on former pro football star Connie Frye to be the celebrity endorser.""" @@ -76,6 +76,7 @@ def test_disk() -> None: assert disk.free == 282500067328 assert disk.total == 499738734592 + def test_series() -> None: """Test the Series model.""" series = models.Series.from_dict(CALENDAR[1]["series"]) From 6763c0eb7c646765451dfcf99a471d8493f88e53 Mon Sep 17 00:00:00 2001 From: Chris Talkington Date: Sat, 4 Apr 2020 21:19:54 -0500 Subject: [PATCH 29/52] Update models.py --- sonarr/models.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sonarr/models.py b/sonarr/models.py index 590b75bd..d20ed8da 100644 --- a/sonarr/models.py +++ b/sonarr/models.py @@ -88,7 +88,7 @@ def from_dict(data: dict): tvdb_id=data.get("tvDbEpisodeId", 0), episode_id=data.get("id", 0), episode_number=data.get("episodeNumber", 0), - season_number=data.get("seasonNumber", 0), + season_number=data.get("seasonNumber", 0), title=data.get("title", ""), overview=data.get("overview", ""), airs=airs, From 07d6b3f95dc26cc240b7626955a9b8ef640c2836 Mon Sep 17 00:00:00 2001 From: Chris Talkington Date: Sat, 4 Apr 2020 21:23:07 -0500 Subject: [PATCH 30/52] Update test_models.py --- tests/test_models.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/tests/test_models.py b/tests/test_models.py index 9363d6c8..50aeff65 100644 --- a/tests/test_models.py +++ b/tests/test_models.py @@ -88,13 +88,12 @@ def test_series() -> None: assert series.slug == "bobs-burger" assert series.title == "Bob's Burgers" assert ( - series.overview - == """Bob's Burgers follows a third-generation restaurateur, Bob, - as he runs Bob's Burgers with the help of his wife and their three kids. - Bob and his quirky family have big ideas about burgers, but fall short on service - and sophistication. Despite the greasy counters, lousy location and a dearth of - customers, Bob and his family are determined to make Bob's Burgers - \"grand re-re-re-opening\" a success.""" + series.overview == """Bob's Burgers follows a third-generation restaurateur, + Bob, as he runs Bob's Burgers with the help of his wife and their three + kids. Bob and his quirky family have big ideas about burgers, but fall + short on service and sophistication. Despite the greasy counters, + lousy location and a dearth of customers, Bob and his family are + determined to make Bob's Burgers \"grand re-re-re-opening\" a success.""" ) assert series.network == "Fox" assert series.runtime == 20 From 8d50c9de2aa13eee5211a39b1645eb7e8370c5bd Mon Sep 17 00:00:00 2001 From: Chris Talkington Date: Sat, 4 Apr 2020 21:23:51 -0500 Subject: [PATCH 31/52] Update test_models.py --- tests/test_models.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/test_models.py b/tests/test_models.py index 50aeff65..30c317bd 100644 --- a/tests/test_models.py +++ b/tests/test_models.py @@ -89,11 +89,11 @@ def test_series() -> None: assert series.title == "Bob's Burgers" assert ( series.overview == """Bob's Burgers follows a third-generation restaurateur, - Bob, as he runs Bob's Burgers with the help of his wife and their three - kids. Bob and his quirky family have big ideas about burgers, but fall - short on service and sophistication. Despite the greasy counters, - lousy location and a dearth of customers, Bob and his family are - determined to make Bob's Burgers \"grand re-re-re-opening\" a success.""" + Bob, as he runs Bob's Burgers with the help of his wife and their three + kids. Bob and his quirky family have big ideas about burgers, but fall + short on service and sophistication. Despite the greasy counters, + lousy location and a dearth of customers, Bob and his family are + determined to make Bob's Burgers \"grand re-re-re-opening\" a success.""" ) assert series.network == "Fox" assert series.runtime == 20 From dfa4afcc907e23997fc1c99c11a74ce2ed0d41c0 Mon Sep 17 00:00:00 2001 From: Chris Talkington Date: Sat, 4 Apr 2020 21:27:16 -0500 Subject: [PATCH 32/52] Update test_models.py --- tests/test_models.py | 33 ++++++++++++++++----------------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/tests/test_models.py b/tests/test_models.py index 30c317bd..af153cc4 100644 --- a/tests/test_models.py +++ b/tests/test_models.py @@ -47,6 +47,13 @@ def test_episode() -> None: """Test the Episode model.""" episode = models.Episode.from_dict(CALENDAR[1]) + overview = ""To compete with fellow \"restaurateur,\" Jimmy Pesto, + and his blowout Super Bowl event. Bob is determined to create a + Bob’s Burgers commercial to air during the \"big game.\" + In an effort to outshine Pesto, the Belchers recruit Randy, + a documentarian, to assist with the filmmaking and hire on + former pro football star Connie Frye to be the celebrity endorser.""" + assert episode assert episode.tvdb_id == 0 assert episode.episode_id == 14402 @@ -54,15 +61,7 @@ def test_episode() -> None: assert episode.season_number == 4 assert isinstance(episode.series, models.Series) assert episode.title == "Easy Com-mercial, Easy Go-mercial" - assert ( - episode.overview - == """To compete with fellow \"restaurateur,\" Jimmy Pesto, - and his blowout Super Bowl event. Bob is determined to create a - Bob’s Burgers commercial to air during the \"big game.\" - In an effort to outshine Pesto, the Belchers recruit Randy, - a documentarian, to assist with the filmmaking and hire on - former pro football star Connie Frye to be the celebrity endorser.""" - ) + assert episode.overview == overview assert episode.airs == datetime(2010, 7, 5, 15, 0, 8, tzinfo=timezone.utc) @@ -81,20 +80,20 @@ def test_series() -> None: """Test the Series model.""" series = models.Series.from_dict(CALENDAR[1]["series"]) + overview = """Bob's Burgers follows a third-generation restaurateur, + Bob, as he runs Bob's Burgers with the help of his wife and their three + kids. Bob and his quirky family have big ideas about burgers, but fall + short on service and sophistication. Despite the greasy counters, + lousy location and a dearth of customers, Bob and his family are + determined to make Bob's Burgers \"grand re-re-re-opening\" a success.""" + assert series assert series.tvdb_id == 194031 assert series.series_id == 3 assert series.status == "continuing" assert series.slug == "bobs-burger" assert series.title == "Bob's Burgers" - assert ( - series.overview == """Bob's Burgers follows a third-generation restaurateur, - Bob, as he runs Bob's Burgers with the help of his wife and their three - kids. Bob and his quirky family have big ideas about burgers, but fall - short on service and sophistication. Despite the greasy counters, - lousy location and a dearth of customers, Bob and his family are - determined to make Bob's Burgers \"grand re-re-re-opening\" a success.""" - ) + assert series.overview == overview assert series.network == "Fox" assert series.runtime == 20 assert series.timeslot == "5:30pm" From e58f628c98287234fbf11ea308021c212ac9fefd Mon Sep 17 00:00:00 2001 From: Chris Talkington Date: Sat, 4 Apr 2020 21:39:57 -0500 Subject: [PATCH 33/52] Update test_models.py --- tests/test_models.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_models.py b/tests/test_models.py index af153cc4..18db205c 100644 --- a/tests/test_models.py +++ b/tests/test_models.py @@ -47,7 +47,7 @@ def test_episode() -> None: """Test the Episode model.""" episode = models.Episode.from_dict(CALENDAR[1]) - overview = ""To compete with fellow \"restaurateur,\" Jimmy Pesto, + overview = """To compete with fellow \"restaurateur,\" Jimmy Pesto, and his blowout Super Bowl event. Bob is determined to create a Bob’s Burgers commercial to air during the \"big game.\" In an effort to outshine Pesto, the Belchers recruit Randy, From 8c9dd97cacd82e79c34a8b75ebaa47562f42f7bc Mon Sep 17 00:00:00 2001 From: Chris Talkington Date: Sat, 4 Apr 2020 21:42:17 -0500 Subject: [PATCH 34/52] Update test_models.py --- tests/test_models.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_models.py b/tests/test_models.py index 18db205c..16a220db 100644 --- a/tests/test_models.py +++ b/tests/test_models.py @@ -86,7 +86,7 @@ def test_series() -> None: short on service and sophistication. Despite the greasy counters, lousy location and a dearth of customers, Bob and his family are determined to make Bob's Burgers \"grand re-re-re-opening\" a success.""" - + assert series assert series.tvdb_id == 194031 assert series.series_id == 3 From db5d4e186614441d8f458052ce5db686718be4b3 Mon Sep 17 00:00:00 2001 From: Chris Talkington Date: Sat, 4 Apr 2020 21:47:37 -0500 Subject: [PATCH 35/52] Update test_models.py --- tests/test_models.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/test_models.py b/tests/test_models.py index 16a220db..982dae7d 100644 --- a/tests/test_models.py +++ b/tests/test_models.py @@ -45,7 +45,7 @@ def test_info() -> None: def test_episode() -> None: """Test the Episode model.""" - episode = models.Episode.from_dict(CALENDAR[1]) + episode = models.Episode.from_dict(CALENDAR[0]) overview = """To compete with fellow \"restaurateur,\" Jimmy Pesto, and his blowout Super Bowl event. Bob is determined to create a @@ -78,7 +78,7 @@ def test_disk() -> None: def test_series() -> None: """Test the Series model.""" - series = models.Series.from_dict(CALENDAR[1]["series"]) + series = models.Series.from_dict(CALENDAR[0]["series"]) overview = """Bob's Burgers follows a third-generation restaurateur, Bob, as he runs Bob's Burgers with the help of his wife and their three From f32bf1d6c2d04ba2517b66c0a9143660ce18c411 Mon Sep 17 00:00:00 2001 From: Chris Talkington Date: Sat, 4 Apr 2020 21:55:07 -0500 Subject: [PATCH 36/52] Update test_models.py --- tests/test_models.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/test_models.py b/tests/test_models.py index 982dae7d..635ae634 100644 --- a/tests/test_models.py +++ b/tests/test_models.py @@ -81,15 +81,15 @@ def test_series() -> None: series = models.Series.from_dict(CALENDAR[0]["series"]) overview = """Bob's Burgers follows a third-generation restaurateur, - Bob, as he runs Bob's Burgers with the help of his wife and their three - kids. Bob and his quirky family have big ideas about burgers, but fall - short on service and sophistication. Despite the greasy counters, - lousy location and a dearth of customers, Bob and his family are - determined to make Bob's Burgers \"grand re-re-re-opening\" a success.""" + Bob, as he runs Bob's Burgers with the help of his wife and their three + kids. Bob and his quirky family have big ideas about burgers, but fall + short on service and sophistication. Despite the greasy counters, + lousy location and a dearth of customers, Bob and his family are + determined to make Bob's Burgers \"grand re-re-re-opening\" a success.""" assert series assert series.tvdb_id == 194031 - assert series.series_id == 3 + assert series.series_id == 66 assert series.status == "continuing" assert series.slug == "bobs-burger" assert series.title == "Bob's Burgers" From f4a868d929ca95619da29ce5d21d8b7ed60a32f5 Mon Sep 17 00:00:00 2001 From: Chris Talkington Date: Sat, 4 Apr 2020 21:58:57 -0500 Subject: [PATCH 37/52] Update test_models.py --- tests/test_models.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/test_models.py b/tests/test_models.py index 635ae634..5c5df023 100644 --- a/tests/test_models.py +++ b/tests/test_models.py @@ -48,11 +48,11 @@ def test_episode() -> None: episode = models.Episode.from_dict(CALENDAR[0]) overview = """To compete with fellow \"restaurateur,\" Jimmy Pesto, - and his blowout Super Bowl event. Bob is determined to create a - Bob’s Burgers commercial to air during the \"big game.\" - In an effort to outshine Pesto, the Belchers recruit Randy, - a documentarian, to assist with the filmmaking and hire on - former pro football star Connie Frye to be the celebrity endorser.""" + and his blowout Super Bowl event. Bob is determined to create a + Bob’s Burgers commercial to air during the \"big game.\" + In an effort to outshine Pesto, the Belchers recruit Randy, + a documentarian, to assist with the filmmaking and hire on + former pro football star Connie Frye to be the celebrity endorser.""" assert episode assert episode.tvdb_id == 0 @@ -91,7 +91,7 @@ def test_series() -> None: assert series.tvdb_id == 194031 assert series.series_id == 66 assert series.status == "continuing" - assert series.slug == "bobs-burger" + assert series.slug == "bobs-burgers" assert series.title == "Bob's Burgers" assert series.overview == overview assert series.network == "Fox" From 0b7c42436f54dc31643c2ece798807218b642c62 Mon Sep 17 00:00:00 2001 From: Chris Talkington Date: Sat, 4 Apr 2020 22:09:32 -0500 Subject: [PATCH 38/52] Update calendar.json --- tests/fixtures/calendar.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/fixtures/calendar.json b/tests/fixtures/calendar.json index dbf5a7c9..14b24a68 100644 --- a/tests/fixtures/calendar.json +++ b/tests/fixtures/calendar.json @@ -7,7 +7,7 @@ "title": "Easy Com-mercial, Easy Go-mercial", "airDate": "2014-01-26", "airDateUtc": "2014-01-27T01:30:00Z", - "overview": "To compete with fellow “restaurateur,” Jimmy Pesto, and his blowout Super Bowl event, Bob is determined to create a Bob’s Burgers commercial to air during the “big game.” In an effort to outshine Pesto, the Belchers recruit Randy, a documentarian, to assist with the filmmaking and hire on former pro football star Connie Frye to be the celebrity endorser.", + "overview": "To compete with fellow \"restaurateur,\" Jimmy Pesto, and his blowout Super Bowl event, Bob is determined to create a Bob's Burgers commercial to air during the \"big game.\" In an effort to outshine Pesto, the Belchers recruit Randy, a documentarian, to assist with the filmmaking and hire on former pro football star Connie Frye to be the celebrity endorser.", "hasFile": false, "monitored": true, "sceneEpisodeNumber": 0, From 96bb6d69c29e2bd252ecc6494fe28029e1a6dde5 Mon Sep 17 00:00:00 2001 From: Chris Talkington Date: Sat, 4 Apr 2020 22:16:41 -0500 Subject: [PATCH 39/52] Update test_models.py --- tests/test_models.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/tests/test_models.py b/tests/test_models.py index 5c5df023..6d469739 100644 --- a/tests/test_models.py +++ b/tests/test_models.py @@ -48,11 +48,11 @@ def test_episode() -> None: episode = models.Episode.from_dict(CALENDAR[0]) overview = """To compete with fellow \"restaurateur,\" Jimmy Pesto, - and his blowout Super Bowl event. Bob is determined to create a - Bob’s Burgers commercial to air during the \"big game.\" - In an effort to outshine Pesto, the Belchers recruit Randy, - a documentarian, to assist with the filmmaking and hire on - former pro football star Connie Frye to be the celebrity endorser.""" + and his blowout Super Bowl event. Bob is determined to create a + Bob’s Burgers commercial to air during the \"big game.\" + In an effort to outshine Pesto, the Belchers recruit Randy, + a documentarian, to assist with the filmmaking and hire on + former pro football star Connie Frye to be the celebrity endorser.""" assert episode assert episode.tvdb_id == 0 @@ -81,11 +81,11 @@ def test_series() -> None: series = models.Series.from_dict(CALENDAR[0]["series"]) overview = """Bob's Burgers follows a third-generation restaurateur, - Bob, as he runs Bob's Burgers with the help of his wife and their three - kids. Bob and his quirky family have big ideas about burgers, but fall - short on service and sophistication. Despite the greasy counters, - lousy location and a dearth of customers, Bob and his family are - determined to make Bob's Burgers \"grand re-re-re-opening\" a success.""" + Bob, as he runs Bob's Burgers with the help of his wife and their three + kids. Bob and his quirky family have big ideas about burgers, but fall + short on service and sophistication. Despite the greasy counters, + lousy location and a dearth of customers, Bob and his family are + determined to make Bob's Burgers \"grand re-re-re-opening\" a success.""" assert series assert series.tvdb_id == 194031 From 91d44129910a4e3266b48f74fbfe26c215659f17 Mon Sep 17 00:00:00 2001 From: Chris Talkington Date: Sat, 4 Apr 2020 22:27:38 -0500 Subject: [PATCH 40/52] Update test_models.py --- tests/test_models.py | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/tests/test_models.py b/tests/test_models.py index 6d469739..10749404 100644 --- a/tests/test_models.py +++ b/tests/test_models.py @@ -48,11 +48,10 @@ def test_episode() -> None: episode = models.Episode.from_dict(CALENDAR[0]) overview = """To compete with fellow \"restaurateur,\" Jimmy Pesto, - and his blowout Super Bowl event. Bob is determined to create a - Bob’s Burgers commercial to air during the \"big game.\" - In an effort to outshine Pesto, the Belchers recruit Randy, - a documentarian, to assist with the filmmaking and hire on - former pro football star Connie Frye to be the celebrity endorser.""" +and his blowout Super Bowl event. Bob is determined to create a +Bob’s Burgers commercial to air during the \"big game.\" +In an effort to outshine Pesto, the Belchers recruit Randy a documentarian, to assist with the filmmaking and hire on +former pro football star Connie Frye to be the celebrity endorser.""" assert episode assert episode.tvdb_id == 0 @@ -61,7 +60,7 @@ def test_episode() -> None: assert episode.season_number == 4 assert isinstance(episode.series, models.Series) assert episode.title == "Easy Com-mercial, Easy Go-mercial" - assert episode.overview == overview + assert episode.overview == overview.replace("\n", " ") assert episode.airs == datetime(2010, 7, 5, 15, 0, 8, tzinfo=timezone.utc) @@ -81,11 +80,11 @@ def test_series() -> None: series = models.Series.from_dict(CALENDAR[0]["series"]) overview = """Bob's Burgers follows a third-generation restaurateur, - Bob, as he runs Bob's Burgers with the help of his wife and their three - kids. Bob and his quirky family have big ideas about burgers, but fall - short on service and sophistication. Despite the greasy counters, - lousy location and a dearth of customers, Bob and his family are - determined to make Bob's Burgers \"grand re-re-re-opening\" a success.""" +Bob, as he runs Bob's Burgers with the help of his wife and their three +kids. Bob and his quirky family have big ideas about burgers, but fall +short on service and sophistication. Despite the greasy counters, +lousy location and a dearth of customers, Bob and his family are +determined to make Bob's Burgers \"grand re-re-re-opening\" a success.""" assert series assert series.tvdb_id == 194031 @@ -93,7 +92,7 @@ def test_series() -> None: assert series.status == "continuing" assert series.slug == "bobs-burgers" assert series.title == "Bob's Burgers" - assert series.overview == overview + assert series.overview == overview.replace("\n", " ") assert series.network == "Fox" assert series.runtime == 20 assert series.timeslot == "5:30pm" From 460ca3e3e426996ab2eea211dd0fe21829d050b2 Mon Sep 17 00:00:00 2001 From: Chris Talkington Date: Sat, 4 Apr 2020 22:30:05 -0500 Subject: [PATCH 41/52] Update test_models.py --- tests/test_models.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/test_models.py b/tests/test_models.py index 10749404..975d581d 100644 --- a/tests/test_models.py +++ b/tests/test_models.py @@ -50,7 +50,8 @@ def test_episode() -> None: overview = """To compete with fellow \"restaurateur,\" Jimmy Pesto, and his blowout Super Bowl event. Bob is determined to create a Bob’s Burgers commercial to air during the \"big game.\" -In an effort to outshine Pesto, the Belchers recruit Randy a documentarian, to assist with the filmmaking and hire on +In an effort to outshine Pesto, the Belchers recruit Randy +a documentarian, to assist with the filmmaking and hire on former pro football star Connie Frye to be the celebrity endorser.""" assert episode From 808db8992de1eafcb2a0c0a9e4cd41aae39bdeb0 Mon Sep 17 00:00:00 2001 From: Chris Talkington Date: Sat, 4 Apr 2020 22:41:20 -0500 Subject: [PATCH 42/52] Update test_models.py --- tests/test_models.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_models.py b/tests/test_models.py index 975d581d..66a68f6a 100644 --- a/tests/test_models.py +++ b/tests/test_models.py @@ -94,7 +94,7 @@ def test_series() -> None: assert series.slug == "bobs-burgers" assert series.title == "Bob's Burgers" assert series.overview == overview.replace("\n", " ") - assert series.network == "Fox" + assert series.network == "FOX" assert series.runtime == 20 assert series.timeslot == "5:30pm" assert series.premieres == datetime(2010, 7, 5, 15, 0, 8, tzinfo=timezone.utc) From 38d1e8011f5bc8a867aad2122bd0fb13585dae20 Mon Sep 17 00:00:00 2001 From: Chris Talkington Date: Sat, 4 Apr 2020 22:47:51 -0500 Subject: [PATCH 43/52] Update test_models.py --- tests/test_models.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_models.py b/tests/test_models.py index 66a68f6a..dbcb616d 100644 --- a/tests/test_models.py +++ b/tests/test_models.py @@ -48,7 +48,7 @@ def test_episode() -> None: episode = models.Episode.from_dict(CALENDAR[0]) overview = """To compete with fellow \"restaurateur,\" Jimmy Pesto, -and his blowout Super Bowl event. Bob is determined to create a +and his blowout Super Bowl event, Bob is determined to create a Bob’s Burgers commercial to air during the \"big game.\" In an effort to outshine Pesto, the Belchers recruit Randy a documentarian, to assist with the filmmaking and hire on From 769fdcf4c574c8c42cf39f3c87e3962a034d9818 Mon Sep 17 00:00:00 2001 From: Chris Talkington Date: Sat, 4 Apr 2020 22:52:24 -0500 Subject: [PATCH 44/52] Update test_models.py --- tests/test_models.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/test_models.py b/tests/test_models.py index dbcb616d..dda1c4cc 100644 --- a/tests/test_models.py +++ b/tests/test_models.py @@ -50,7 +50,7 @@ def test_episode() -> None: overview = """To compete with fellow \"restaurateur,\" Jimmy Pesto, and his blowout Super Bowl event, Bob is determined to create a Bob’s Burgers commercial to air during the \"big game.\" -In an effort to outshine Pesto, the Belchers recruit Randy +In an effort to outshine Pesto, the Belchers recruit Randy, a documentarian, to assist with the filmmaking and hire on former pro football star Connie Frye to be the celebrity endorser.""" @@ -95,6 +95,6 @@ def test_series() -> None: assert series.title == "Bob's Burgers" assert series.overview == overview.replace("\n", " ") assert series.network == "FOX" - assert series.runtime == 20 + assert series.runtime == 30 assert series.timeslot == "5:30pm" assert series.premieres == datetime(2010, 7, 5, 15, 0, 8, tzinfo=timezone.utc) From 412319e63bb32496eeebaa74d2958cf4603ca56a Mon Sep 17 00:00:00 2001 From: Chris Talkington Date: Sat, 4 Apr 2020 22:59:35 -0500 Subject: [PATCH 45/52] Update test_models.py --- tests/test_models.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_models.py b/tests/test_models.py index dda1c4cc..b47a4d26 100644 --- a/tests/test_models.py +++ b/tests/test_models.py @@ -49,7 +49,7 @@ def test_episode() -> None: overview = """To compete with fellow \"restaurateur,\" Jimmy Pesto, and his blowout Super Bowl event, Bob is determined to create a -Bob’s Burgers commercial to air during the \"big game.\" +Bob's Burgers commercial to air during the \"big game.\" In an effort to outshine Pesto, the Belchers recruit Randy, a documentarian, to assist with the filmmaking and hire on former pro football star Connie Frye to be the celebrity endorser.""" From 4a62bc5ccc6061a9648320a4f85c5b8be82d68ec Mon Sep 17 00:00:00 2001 From: Chris Talkington Date: Sat, 4 Apr 2020 23:00:25 -0500 Subject: [PATCH 46/52] Update test_models.py --- tests/test_models.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_models.py b/tests/test_models.py index b47a4d26..72d877b4 100644 --- a/tests/test_models.py +++ b/tests/test_models.py @@ -97,4 +97,4 @@ def test_series() -> None: assert series.network == "FOX" assert series.runtime == 30 assert series.timeslot == "5:30pm" - assert series.premieres == datetime(2010, 7, 5, 15, 0, 8, tzinfo=timezone.utc) + assert series.premieres == datetime(2011, 1, 10, 1, 30, tzinfo=timezone.utc) From 1a605323d12fc644c138b87049ac8b4ed3488392 Mon Sep 17 00:00:00 2001 From: Chris Talkington Date: Sat, 4 Apr 2020 23:04:49 -0500 Subject: [PATCH 47/52] Update test_models.py --- tests/test_models.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_models.py b/tests/test_models.py index 72d877b4..cca0aca8 100644 --- a/tests/test_models.py +++ b/tests/test_models.py @@ -62,7 +62,7 @@ def test_episode() -> None: assert isinstance(episode.series, models.Series) assert episode.title == "Easy Com-mercial, Easy Go-mercial" assert episode.overview == overview.replace("\n", " ") - assert episode.airs == datetime(2010, 7, 5, 15, 0, 8, tzinfo=timezone.utc) + assert episode.airs == datetime(2014, 1, 27, 1, 30, tzinfo=timezone.utc) def test_disk() -> None: From a0b3c5eda19cda46b0f9400bed8cc40c4c331feb Mon Sep 17 00:00:00 2001 From: Chris Talkington Date: Sat, 4 Apr 2020 23:15:03 -0500 Subject: [PATCH 48/52] Update models.py --- sonarr/models.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/sonarr/models.py b/sonarr/models.py index d20ed8da..dfc00d39 100644 --- a/sonarr/models.py +++ b/sonarr/models.py @@ -33,6 +33,7 @@ class Series: tvdb_id: int series_id: int + series_type: str slug: str status: str title: str @@ -41,6 +42,7 @@ class Series: runtime: int timeslot: str premieres: datetime + path: str @staticmethod def from_dict(data: dict): @@ -52,6 +54,7 @@ def from_dict(data: dict): return Series( tvdb_id=data.get("tvdbId", 0), series_id=data.get("id", 0), + series_type=data.get("seriesType", "unknown"), slug=data.get("titleSlug", ""), status=data.get("status", "unknown"), title=data.get("title", ""), @@ -60,6 +63,7 @@ def from_dict(data: dict): runtime=data.get("runtime", 0), timeslot=data.get("airTime", ""), premieres=premieres, + path=data.get("path", ""), ) From 67ee2369fc4a58dc73e604c422060103e1218759 Mon Sep 17 00:00:00 2001 From: Chris Talkington Date: Sat, 4 Apr 2020 23:17:07 -0500 Subject: [PATCH 49/52] Update test_models.py --- tests/test_models.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/test_models.py b/tests/test_models.py index cca0aca8..f42abf7b 100644 --- a/tests/test_models.py +++ b/tests/test_models.py @@ -90,6 +90,7 @@ def test_series() -> None: assert series assert series.tvdb_id == 194031 assert series.series_id == 66 + assert series.series_type == "standard" assert series.status == "continuing" assert series.slug == "bobs-burgers" assert series.title == "Bob's Burgers" @@ -98,3 +99,4 @@ def test_series() -> None: assert series.runtime == 30 assert series.timeslot == "5:30pm" assert series.premieres == datetime(2011, 1, 10, 1, 30, tzinfo=timezone.utc) + assert series path == "T:\\Bob's Burgers" From d6143ae0c0a01a6db98a70cfd2cd6386fe365db3 Mon Sep 17 00:00:00 2001 From: Chris Talkington Date: Sat, 4 Apr 2020 23:19:22 -0500 Subject: [PATCH 50/52] Update test_models.py --- tests/test_models.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_models.py b/tests/test_models.py index f42abf7b..bc85e60e 100644 --- a/tests/test_models.py +++ b/tests/test_models.py @@ -99,4 +99,4 @@ def test_series() -> None: assert series.runtime == 30 assert series.timeslot == "5:30pm" assert series.premieres == datetime(2011, 1, 10, 1, 30, tzinfo=timezone.utc) - assert series path == "T:\\Bob's Burgers" + assert series.path == "T:\\Bob's Burgers" From 204c2a17827bf61546d444f66f720dc4d2d20bd9 Mon Sep 17 00:00:00 2001 From: Chris Talkington Date: Sat, 4 Apr 2020 23:23:48 -0500 Subject: [PATCH 51/52] Update test_models.py --- tests/test_models.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/test_models.py b/tests/test_models.py index bc85e60e..f23f1485 100644 --- a/tests/test_models.py +++ b/tests/test_models.py @@ -88,6 +88,7 @@ def test_series() -> None: determined to make Bob's Burgers \"grand re-re-re-opening\" a success.""" assert series + assert series.monitored assert series.tvdb_id == 194031 assert series.series_id == 66 assert series.series_type == "standard" From 7158e50cd6caa5ce1da73c3942345d6d9ce54d82 Mon Sep 17 00:00:00 2001 From: Chris Talkington Date: Sat, 4 Apr 2020 23:25:34 -0500 Subject: [PATCH 52/52] Update models.py --- sonarr/models.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sonarr/models.py b/sonarr/models.py index dfc00d39..8b30b960 100644 --- a/sonarr/models.py +++ b/sonarr/models.py @@ -43,6 +43,7 @@ class Series: timeslot: str premieres: datetime path: str + monitored: bool @staticmethod def from_dict(data: dict): @@ -64,6 +65,7 @@ def from_dict(data: dict): timeslot=data.get("airTime", ""), premieres=premieres, path=data.get("path", ""), + monitored=data.get("monitored", False), )