Skip to content

Commit

Permalink
Add optional metadata grabber for television: tvmaze
Browse files Browse the repository at this point in the history
See
https://www.tvmaze.com/
https://www.tvmaze.com/api

This commit adds an alternative metadata grabber for TV-Series.
The tvmaze metadata grabber follows the defintions in
https://www.mythtv.org/wiki/MythTV_Universal_Metadata_Format

To enable this grabber, run in mythtv frontend
"Setup" -> "Artwork and Data Sources"
and select 'TVMaze.com' for the default TelevisionGrabber.

Once done, you can check this global setting with mysql:

[mythconverg]> select * from settings where value like '%grabber%';
+--------------------+-------------------------------+----------+
| value              | data                          | hostname |
+--------------------+-------------------------------+----------+
| TelevisionGrabber  | metadata/Television/tvmaze.py | NULL     |
| MovieGrabber       | metadata/Movie/tmdb3.py       | NULL     |
+--------------------+-------------------------------+----------+

Any further metadata update will then use these grabbers.

Note: The tvmaze grabber is compatible to python 2.7 and 3.6+.
  • Loading branch information
rcrdnalor committed Jan 18, 2021
1 parent 82c3d10 commit eb1c377
Show file tree
Hide file tree
Showing 13 changed files with 2,170 additions and 2 deletions.
4 changes: 2 additions & 2 deletions mythtv/bindings/python/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,10 @@ def run(self):
version='32.0.-1',
description='MythTV Python bindings.',
long_description='Provides canned database and protocol access to the MythTV database, mythproto, mythxml, services_api and frontend remote control.',
packages=['MythTV', 'MythTV/tmdb3', 'MythTV/ttvdb',
packages=['MythTV', 'MythTV/tmdb3', 'MythTV/ttvdb', 'MythTV/tvmaze',
'MythTV/wikiscripts', 'MythTV/utility',
'MythTV/services_api'],
package_dir={'MythTV/tmdb3':'./tmdb3/tmdb3'},
package_dir={'MythTV/tmdb3':'./tmdb3/tmdb3', 'MythTV/tvmaze':'./tvmaze'},
data_files=[('MythTV/ttvdb/XSLT', glob.glob('MythTV/ttvdb/XSLT/*'))],
url=['http://www.mythtv.org/'],
scripts=SCRIPTS,
Expand Down
Empty file.
54 changes: 54 additions & 0 deletions mythtv/bindings/python/tvmaze/embed.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# -*- coding: UTF-8 -*-

# Copyright (c) 2020 Lachlan Mackenzie
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.


# ---------------------------------------------------
# Roland Ernst
# Changes implemented for MythTV:
# - added python2 compatibility
#
# ---------------------------------------------------


from __future__ import unicode_literals

# python 3 doesn't have a unicode type
try:
unicode
except:
unicode = str


class Embed(object):
def __init__(self, data):
self.key = 'embed'
self.value = None
if isinstance(data, unicode):
self.key = 'embed'
self.value = data
if isinstance(data, list) and len(data) > 0:
if all(isinstance(item, unicode) for item in data):
self.key = 'embed[]'
self.value = data

def __str__(self):
return self.key + ': ' + self.value
40 changes: 40 additions & 0 deletions mythtv/bindings/python/tvmaze/endpoints.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# -*- coding: UTF-8 -*-

# Copyright (c) 2020 Lachlan Mackenzie
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.


from __future__ import unicode_literals


API_URL = 'https://api.tvmaze.com'
search_show_name = 'https://api.tvmaze.com/search/shows?'
search_show_best_match = 'https://api.tvmaze.com/singlesearch/shows?'
search_external_show_id = 'https://api.tvmaze.com/lookup/shows?'
show_information = 'https://api.tvmaze.com/shows/{0}'
show_episode_list = 'https://api.tvmaze.com/shows/{0}/episodes?'
show_episode = 'http://api.tvmaze.com/shows/{0}/episodebynumber?'
show_episodes_on_date = 'http://api.tvmaze.com/shows/{0}/episodesbydate?'
show_season_list = 'http://api.tvmaze.com/shows/{0}/seasons'
season_episode_list = 'http://api.tvmaze.com/seasons/{0}/episodes'
show_alias_list = 'http://api.tvmaze.com/shows/{0}/akas'
episode_information = 'http://api.tvmaze.com/episodes/{0}?'
show_cast = 'http://api.tvmaze.com/shows/{0}/cast'
show_crew = 'http://api.tvmaze.com/shows/{0}/crew'
55 changes: 55 additions & 0 deletions mythtv/bindings/python/tvmaze/episode.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# -*- coding: UTF-8 -*-

# Copyright (c) 2020 Lachlan Mackenzie
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.


# ---------------------------------------------------
# Roland Ernst
# Changes implemented for MythTV:
# - added method utils.convert_date
#
# ---------------------------------------------------


from __future__ import unicode_literals

from . import utils


class Episode(object):
def __init__(self, data):
self.id = data.get('id')
self.url = data.get('url')
self.name = data.get('name')
self.season = data.get('season')
self.number = data.get('number')
self.airdate = utils.convert_date(data.get('airdate'))
self.airtime = data.get('airtime')
self.timestamp = data.get('airstamp')
self.duration = data.get('runtime')
self.images = data.get('image')
self.summary = utils.strip_tags(data.get('summary'))
self.links = data.get('_links')
self.special = self.number == 0

def __str__(self):
return 'S{}E{} {}'.format(self.season, self.number, self.name)
# return f'S{self.season}E{self.number} {self.name}' if not self.special else f'Special: {self.name}'
Loading

0 comments on commit eb1c377

Please sign in to comment.