Skip to content

Commit

Permalink
Use human readble names for release type
Browse files Browse the repository at this point in the history
  • Loading branch information
sarendsen committed Dec 16, 2022
1 parent e8bb38e commit 0e8416a
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
17 changes: 16 additions & 1 deletion flexget/components/tmdb/api_tmdb.py
Expand Up @@ -93,6 +93,15 @@ def upgrade(ver, session):
)
Base.register_table(genres_table)

RELEASE_DATE_TYPE_MAPPING = {
1: 'premiere',
2: 'theatrical_limited',
3: 'theatrical',
4: 'digital',
5: 'physical',
6: 'tv',
}


class TMDBMovie(Base):
__tablename__ = 'tmdb_movies'
Expand Down Expand Up @@ -193,7 +202,13 @@ def release_dates(self):
'release dates for movie {} not found in DB, fetching from TMDB', self.name
)
try:
self._release_dates = tmdb_request('movie/{}/release_dates'.format(self.id))
results = tmdb_request('movie/{}/release_dates'.format(self.id))['results']
for iso in results:
for release in iso['release_dates']:
release['type'] = RELEASE_DATE_TYPE_MAPPING[release['type']]

self._release_dates = results

except requests.RequestException as e:
raise LookupError('Error updating data from tmdb: %s' % e)
return self._release_dates
Expand Down
1 change: 1 addition & 0 deletions flexget/tests/test_tmdb.py
Expand Up @@ -25,6 +25,7 @@ def test_tmdb_lookup(self, execute_task):
tmdb_name='The Matrix Resurrections', tmdb_year=2021
), 'Didn\'t populate tmdb info for The Matrix Resurrections'


@pytest.mark.online
class TestTmdbUnicodeLookup:
config = """
Expand Down

0 comments on commit 0e8416a

Please sign in to comment.