Make TMDb and TVmaze lookup optional

This commit is contained in:
JonnyWong16 2017-10-01 12:04:29 -07:00
parent d207d4a508
commit 3c04b04b98
4 changed files with 43 additions and 24 deletions

View file

@ -754,7 +754,7 @@
<div role="tabpanel" class="tab-pane" id="tabs-notifications"> <div role="tabpanel" class="tab-pane" id="tabs-notifications">
<div class="padded-header"> <div class="padded-header">
<h3>Global Notification Settings</h3> <h3>3rd Party APIs</h3>
</div> </div>
<div class="checkbox"> <div class="checkbox">
@ -775,6 +775,18 @@
You can register a new application <a href="${anon_url('https://api.imgur.com/oauth2/addclient')}" target="_blank">here</a>.<br /> You can register a new application <a href="${anon_url('https://api.imgur.com/oauth2/addclient')}" target="_blank">here</a>.<br />
</div> </div>
</div> </div>
<div class="checkbox">
<label>
<input type="checkbox" name="themoviedb_lookup" id="themoviedb_lookup" value="1" ${config['themoviedb_lookup']}> Lookup TheMovieDB Links
</label>
<p class="help-block">Enable to lookup links to TheMovieDB for movies and TV shows when available.</p>
</div>
<div class="checkbox">
<label>
<input type="checkbox" name="tvmaze_lookup" id="tvmaze_lookup" value="1" ${config['tvmaze_lookup']}> Lookup TVmaze Links
</label>
<p class="help-block">Enable to lookup links to TVmaze for TV shows when available.</p>
</div>
<div class="padded-header"> <div class="padded-header">
<h3>Current Activity Notifications</h3> <h3>Current Activity Notifications</h3>

View file

@ -549,6 +549,8 @@ _CONFIG_DEFINITIONS = {
'TELEGRAM_ON_CONCURRENT': (int, 'Telegram', 0), 'TELEGRAM_ON_CONCURRENT': (int, 'Telegram', 0),
'TELEGRAM_ON_NEWDEVICE': (int, 'Telegram', 0), 'TELEGRAM_ON_NEWDEVICE': (int, 'Telegram', 0),
'THEMOVIEDB_APIKEY': (str, 'General', 'e9a6655bae34bf694a0f3e33338dc28e'), 'THEMOVIEDB_APIKEY': (str, 'General', 'e9a6655bae34bf694a0f3e33338dc28e'),
'THEMOVIEDB_LOOKUP': (int, 'General', 0),
'TVMAZE_LOOKUP': (int, 'General', 0),
'TV_LOGGING_ENABLE': (int, 'Monitoring', 1), 'TV_LOGGING_ENABLE': (int, 'Monitoring', 1),
'TV_NOTIFY_ENABLE': (int, 'Monitoring', 0), 'TV_NOTIFY_ENABLE': (int, 'Monitoring', 0),
'TV_NOTIFY_ON_START': (int, 'Monitoring', 1), 'TV_NOTIFY_ON_START': (int, 'Monitoring', 1),

View file

@ -535,32 +535,34 @@ def build_media_notify_params(notify_action=None, session=None, timeline=None, m
metadata['lastfm_url'] = 'https://www.last.fm/music/' + metadata['lastfm_id'] metadata['lastfm_url'] = 'https://www.last.fm/music/' + metadata['lastfm_id']
# Get TheMovieDB info # Get TheMovieDB info
if metadata.get('themoviedb_id'): if plexpy.CONFIG.THEMOVIEDB_LOOKUP:
themoveidb_json = get_themoviedb_info(rating_key=rating_key, if metadata.get('themoviedb_id'):
media_type=metadata['media_type'], themoveidb_json = get_themoviedb_info(rating_key=rating_key,
themoviedb_id=metadata['themoviedb_id']) media_type=metadata['media_type'],
themoviedb_id=metadata['themoviedb_id'])
if themoveidb_json.get('imdb_id'): if themoveidb_json.get('imdb_id'):
metadata['imdb_id'] = themoveidb_json['imdb_id'] metadata['imdb_id'] = themoveidb_json['imdb_id']
metadata['imdb_url'] = 'https://www.imdb.com/title/' + themoveidb_json['imdb_id'] metadata['imdb_url'] = 'https://www.imdb.com/title/' + themoveidb_json['imdb_id']
elif metadata.get('thetvdb_id') or metadata.get('imdb_id'): elif metadata.get('thetvdb_id') or metadata.get('imdb_id'):
themoviedb_info = lookup_themoviedb_by_id(rating_key=rating_key, themoviedb_info = lookup_themoviedb_by_id(rating_key=rating_key,
thetvdb_id=metadata.get('thetvdb_id'), thetvdb_id=metadata.get('thetvdb_id'),
imdb_id=metadata.get('imdb_id')) imdb_id=metadata.get('imdb_id'))
metadata.update(themoviedb_info) metadata.update(themoviedb_info)
# Get TVmaze info (for tv shows only) # Get TVmaze info (for tv shows only)
if metadata['media_type'] in ('show', 'season', 'episode') and (metadata.get('thetvdb_id') or metadata.get('imdb_id')): if plexpy.CONFIG.TVMAZE_LOOKUP:
tvmaze_info = lookup_tvmaze_by_id(rating_key=rating_key, if metadata['media_type'] in ('show', 'season', 'episode') and (metadata.get('thetvdb_id') or metadata.get('imdb_id')):
thetvdb_id=metadata.get('thetvdb_id'), tvmaze_info = lookup_tvmaze_by_id(rating_key=rating_key,
imdb_id=metadata.get('imdb_id')) thetvdb_id=metadata.get('thetvdb_id'),
metadata.update(tvmaze_info) imdb_id=metadata.get('imdb_id'))
metadata.update(tvmaze_info)
if tvmaze_info.get('thetvdb_id'): if tvmaze_info.get('thetvdb_id'):
metadata['thetvdb_url'] = 'https://thetvdb.com/?tab=series&id=' + str(tvmaze_info['thetvdb_id']) metadata['thetvdb_url'] = 'https://thetvdb.com/?tab=series&id=' + str(tvmaze_info['thetvdb_id'])
if tvmaze_info.get('imdb_id'): if tvmaze_info.get('imdb_id'):
metadata['imdb_url'] = 'https://www.imdb.com/title/' + tvmaze_info['imdb_id'] metadata['imdb_url'] = 'https://www.imdb.com/title/' + tvmaze_info['imdb_id']
if metadata['media_type'] in ('movie', 'show', 'artist'): if metadata['media_type'] in ('movie', 'show', 'artist'):
poster_thumb = metadata['thumb'] poster_thumb = metadata['thumb']

View file

@ -2648,7 +2648,9 @@ class WebInterface(object):
"git_remote": plexpy.CONFIG.GIT_REMOTE, "git_remote": plexpy.CONFIG.GIT_REMOTE,
"movie_watched_percent": plexpy.CONFIG.MOVIE_WATCHED_PERCENT, "movie_watched_percent": plexpy.CONFIG.MOVIE_WATCHED_PERCENT,
"tv_watched_percent": plexpy.CONFIG.TV_WATCHED_PERCENT, "tv_watched_percent": plexpy.CONFIG.TV_WATCHED_PERCENT,
"music_watched_percent": plexpy.CONFIG.MUSIC_WATCHED_PERCENT "music_watched_percent": plexpy.CONFIG.MUSIC_WATCHED_PERCENT,
"themoviedb_lookup": checked(plexpy.CONFIG.THEMOVIEDB_LOOKUP),
"tvmaze_lookup": checked(plexpy.CONFIG.TVMAZE_LOOKUP)
} }
return serve_template(templatename="settings.html", title="Settings", config=config, kwargs=kwargs) return serve_template(templatename="settings.html", title="Settings", config=config, kwargs=kwargs)
@ -2668,7 +2670,8 @@ class WebInterface(object):
"notify_group_recently_added_grandparent", "notify_group_recently_added_parent", "notify_group_recently_added_grandparent", "notify_group_recently_added_parent",
"monitor_pms_updates", "monitor_remote_access", "get_file_sizes", "log_blacklist", "http_hash_password", "monitor_pms_updates", "monitor_remote_access", "get_file_sizes", "log_blacklist", "http_hash_password",
"allow_guest_access", "cache_images", "http_basic_auth", "notify_concurrent_by_ip", "allow_guest_access", "cache_images", "http_basic_auth", "notify_concurrent_by_ip",
"history_table_activity", "plexpy_auto_update" "history_table_activity", "plexpy_auto_update",
"themoviedb_lookup", "tvmaze_lookup"
] ]
for checked_config in checked_configs: for checked_config in checked_configs:
if checked_config not in kwargs: if checked_config not in kwargs: