mirror of
https://github.com/Tautulli/Tautulli.git
synced 2025-07-13 00:32:58 -07:00
Add button to delete 3rd party API lookup info
This commit is contained in:
parent
7d31079897
commit
3380e39de2
5 changed files with 171 additions and 7 deletions
31
API.md
31
API.md
|
@ -113,6 +113,20 @@ Delete and recreate the image cache directory.
|
||||||
|
|
||||||
|
|
||||||
### delete_imgur_poster
|
### delete_imgur_poster
|
||||||
|
Delete the Imgur poster.
|
||||||
|
|
||||||
|
```
|
||||||
|
Required parameters:
|
||||||
|
rating_key (int): 1234
|
||||||
|
(Note: Must be the movie, show, season, artist, or album rating key)
|
||||||
|
Optional parameters:
|
||||||
|
None
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
json:
|
||||||
|
{"result": "success",
|
||||||
|
"message": "Deleted Imgur poster."}
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
### delete_library
|
### delete_library
|
||||||
|
@ -145,6 +159,23 @@ Returns:
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
### delete_lookup_info
|
||||||
|
Delete the 3rd party API lookup info.
|
||||||
|
|
||||||
|
```
|
||||||
|
Required parameters:
|
||||||
|
rating_key (int): 1234
|
||||||
|
(Note: Must be the movie, show, or artist rating key)
|
||||||
|
Optional parameters:
|
||||||
|
None
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
json:
|
||||||
|
{"result": "success",
|
||||||
|
"message": "Deleted lookup info."}
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
### delete_mobile_device
|
### delete_mobile_device
|
||||||
Remove a mobile device from the database.
|
Remove a mobile device from the database.
|
||||||
|
|
||||||
|
|
|
@ -388,6 +388,15 @@ DOCUMENTATION :: END
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
% endif
|
% endif
|
||||||
|
% if data.get('tvmaze_id') or data.get('themoviedb_id'):
|
||||||
|
<div class="btn-group">
|
||||||
|
<button class="btn btn-danger btn-edit" data-toggle="modal" aria-pressed="false" autocomplete="off" id="delete-lookup-info"
|
||||||
|
data-id="${data['grandparent_rating_key'] if data['media_type'] in ('episode', 'track') else data['parent_rating_key'] if data['media_type'] in ('season', 'album') else data['rating_key']}"
|
||||||
|
data-title="${data['grandparent_title'] if data['media_type'] in ('episode', 'track') else data['parent_title'] if data['media_type'] in ('season', 'album') else data['title']}">
|
||||||
|
<i class="fa fa-search"></i> Delete Lookup Info
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
% endif
|
||||||
% if data.get('poster_url'):
|
% if data.get('poster_url'):
|
||||||
<div class="btn-group">
|
<div class="btn-group">
|
||||||
% if data['media_type'] == 'artist' or data['media_type'] == 'album' or data['media_type'] == 'track':
|
% if data['media_type'] == 'artist' or data['media_type'] == 'album' or data['media_type'] == 'track':
|
||||||
|
@ -396,7 +405,8 @@ DOCUMENTATION :: END
|
||||||
<span class="imgur-poster-tooltip" data-toggle="popover" data-img="${data['poster_url']}" data-height="120" data-width="80" style="display: inline-flex;">
|
<span class="imgur-poster-tooltip" data-toggle="popover" data-img="${data['poster_url']}" data-height="120" data-width="80" style="display: inline-flex;">
|
||||||
% endif
|
% endif
|
||||||
<button class="btn btn-danger btn-edit" data-toggle="modal" aria-pressed="false" autocomplete="off" id="delete-imgur-poster"
|
<button class="btn btn-danger btn-edit" data-toggle="modal" aria-pressed="false" autocomplete="off" id="delete-imgur-poster"
|
||||||
data-id="${data['parent_rating_key'] if data['media_type'] in ('episode', 'track') else data['rating_key']}">
|
data-id="${data['parent_rating_key'] if data['media_type'] in ('episode', 'track') else data['rating_key']}"
|
||||||
|
data-title="${data["poster_title"]}">
|
||||||
<i class="fa fa-picture-o"></i> Delete Imgur Poster
|
<i class="fa fa-picture-o"></i> Delete Imgur Poster
|
||||||
</button>
|
</button>
|
||||||
</span>
|
</span>
|
||||||
|
@ -706,13 +716,27 @@ DOCUMENTATION :: END
|
||||||
});
|
});
|
||||||
|
|
||||||
$('#delete-imgur-poster').on('click', function () {
|
$('#delete-imgur-poster').on('click', function () {
|
||||||
var msg = 'Are you sure you want to delete the Imgur poster for <strong>${data["poster_title"]}</strong>?<br><br>' +
|
var msg = 'Are you sure you want to delete the Imgur poster for <strong>' + $(this).data('title') + '</strong>?<br><br>' +
|
||||||
'All previous links to this image will no longer work.';
|
'All previous links to this image will no longer work.';
|
||||||
var url = 'delete_imgur_poster';
|
var url = 'delete_imgur_poster';
|
||||||
var data = { rating_key: $(this).data('id') };
|
var data = { rating_key: $(this).data('id') };
|
||||||
var callback = function () {
|
var callback = function () {
|
||||||
$('.imgur-poster-tooltip').popover('destroy');
|
$('.imgur-poster-tooltip').popover('destroy');
|
||||||
$('#delete-imgur-poster').closest('span').remove();
|
$('#delete-imgur-poster').closest('.btn-group').remove();
|
||||||
|
};
|
||||||
|
confirmAjaxCall(url, msg, data, false, callback);
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
% endif
|
||||||
|
% if data.get('tvmaze_id') or data.get('themoviedb_id'):
|
||||||
|
<script>
|
||||||
|
$('#delete-lookup-info').on('click', function () {
|
||||||
|
var msg = 'Are you sure you want to delete the 3rd party API lookup for <strong>' + $(this).data('title') + '</strong>?<br><br>' +
|
||||||
|
'The info will be looked up again the next time a notification is sent.';
|
||||||
|
var url = 'delete_lookup_info';
|
||||||
|
var data = { rating_key: $(this).data('id'), title: $(this).data('title') };
|
||||||
|
var callback = function () {
|
||||||
|
$('#delete-lookup-info').closest('.btn-group').remove();
|
||||||
};
|
};
|
||||||
confirmAjaxCall(url, msg, data, false, callback);
|
confirmAjaxCall(url, msg, data, false, callback);
|
||||||
});
|
});
|
||||||
|
|
|
@ -1107,6 +1107,7 @@ class DataFactory(object):
|
||||||
def get_poster_info(self, rating_key='', metadata=None):
|
def get_poster_info(self, rating_key='', metadata=None):
|
||||||
monitor_db = database.MonitorDatabase()
|
monitor_db = database.MonitorDatabase()
|
||||||
|
|
||||||
|
poster_key = ''
|
||||||
if str(rating_key).isdigit():
|
if str(rating_key).isdigit():
|
||||||
poster_key = rating_key
|
poster_key = rating_key
|
||||||
elif metadata:
|
elif metadata:
|
||||||
|
@ -1118,6 +1119,7 @@ class DataFactory(object):
|
||||||
poster_key = metadata['parent_rating_key']
|
poster_key = metadata['parent_rating_key']
|
||||||
|
|
||||||
poster_info = {}
|
poster_info = {}
|
||||||
|
|
||||||
if poster_key:
|
if poster_key:
|
||||||
try:
|
try:
|
||||||
query = 'SELECT poster_title, poster_url FROM poster_urls ' \
|
query = 'SELECT poster_title, poster_url FROM poster_urls ' \
|
||||||
|
@ -1155,6 +1157,51 @@ class DataFactory(object):
|
||||||
result = monitor_db.action('DELETE FROM poster_urls WHERE rating_key = ?', [rating_key])
|
result = monitor_db.action('DELETE FROM poster_urls WHERE rating_key = ?', [rating_key])
|
||||||
return True if result else False
|
return True if result else False
|
||||||
|
|
||||||
|
def get_lookup_info(self, rating_key='', metadata=None):
|
||||||
|
monitor_db = database.MonitorDatabase()
|
||||||
|
|
||||||
|
lookup_key = ''
|
||||||
|
if str(rating_key).isdigit():
|
||||||
|
lookup_key = rating_key
|
||||||
|
elif metadata:
|
||||||
|
if metadata['media_type'] in ('movie', 'show', 'artist'):
|
||||||
|
lookup_key = metadata['rating_key']
|
||||||
|
elif metadata['media_type'] in ('season', 'album'):
|
||||||
|
lookup_key = metadata['parent_rating_key']
|
||||||
|
elif metadata['media_type'] in ('episode', 'track'):
|
||||||
|
lookup_key = metadata['grandparent_rating_key']
|
||||||
|
|
||||||
|
lookup_info = {'tvmaze_id': '',
|
||||||
|
'themoviedb_id': ''}
|
||||||
|
|
||||||
|
if lookup_key:
|
||||||
|
try:
|
||||||
|
query = 'SELECT tvmaze_id FROM tvmaze_lookup ' \
|
||||||
|
'WHERE rating_key = ?'
|
||||||
|
tvmaze_info = monitor_db.select_single(query, args=[lookup_key])
|
||||||
|
if tvmaze_info:
|
||||||
|
lookup_info['tvmaze_id'] = tvmaze_info['tvmaze_id']
|
||||||
|
|
||||||
|
query = 'SELECT themoviedb_id FROM themoviedb_lookup ' \
|
||||||
|
'WHERE rating_key = ?'
|
||||||
|
themoviedb_info = monitor_db.select_single(query, args=[lookup_key])
|
||||||
|
if themoviedb_info:
|
||||||
|
lookup_info['themoviedb_id'] = themoviedb_info['themoviedb_id']
|
||||||
|
except Exception as e:
|
||||||
|
logger.warn(u"Tautulli DataFactory :: Unable to execute database query for get_lookup_info: %s." % e)
|
||||||
|
|
||||||
|
return lookup_info
|
||||||
|
|
||||||
|
def delete_lookup_info(self, rating_key='', title=''):
|
||||||
|
monitor_db = database.MonitorDatabase()
|
||||||
|
|
||||||
|
if rating_key:
|
||||||
|
logger.info(u"Tautulli DataFactory :: Deleting lookup info for '%s' (rating_key %s) from the database."
|
||||||
|
% (title, rating_key))
|
||||||
|
result_tvmaze = monitor_db.action('DELETE FROM tvmaze_lookup WHERE rating_key = ?', [rating_key])
|
||||||
|
result_themoviedb = monitor_db.action('DELETE FROM themoviedb_lookup WHERE rating_key = ?', [rating_key])
|
||||||
|
return True if (result_tvmaze or result_themoviedb) else False
|
||||||
|
|
||||||
def get_search_query(self, rating_key=''):
|
def get_search_query(self, rating_key=''):
|
||||||
monitor_db = database.MonitorDatabase()
|
monitor_db = database.MonitorDatabase()
|
||||||
|
|
||||||
|
|
|
@ -562,7 +562,14 @@ def build_media_notify_params(notify_action=None, session=None, timeline=None, m
|
||||||
notify_params['imdb_url'] = 'https://www.imdb.com/title/' + themoveidb_json['imdb_id']
|
notify_params['imdb_url'] = 'https://www.imdb.com/title/' + themoveidb_json['imdb_id']
|
||||||
|
|
||||||
elif notify_params.get('thetvdb_id') or notify_params.get('imdb_id'):
|
elif notify_params.get('thetvdb_id') or notify_params.get('imdb_id'):
|
||||||
themoviedb_info = lookup_themoviedb_by_id(rating_key=rating_key,
|
if notify_params['media_type'] in ('episode', 'track'):
|
||||||
|
lookup_key = notify_params['grandparent_rating_key']
|
||||||
|
elif notify_params['media_type'] in ('season', 'album'):
|
||||||
|
lookup_key = notify_params['parent_rating_key']
|
||||||
|
else:
|
||||||
|
lookup_key = rating_key
|
||||||
|
|
||||||
|
themoviedb_info = lookup_themoviedb_by_id(rating_key=lookup_key,
|
||||||
thetvdb_id=notify_params.get('thetvdb_id'),
|
thetvdb_id=notify_params.get('thetvdb_id'),
|
||||||
imdb_id=notify_params.get('imdb_id'))
|
imdb_id=notify_params.get('imdb_id'))
|
||||||
notify_params.update(themoviedb_info)
|
notify_params.update(themoviedb_info)
|
||||||
|
@ -570,7 +577,14 @@ def build_media_notify_params(notify_action=None, session=None, timeline=None, m
|
||||||
# Get TVmaze info (for tv shows only)
|
# Get TVmaze info (for tv shows only)
|
||||||
if plexpy.CONFIG.TVMAZE_LOOKUP:
|
if plexpy.CONFIG.TVMAZE_LOOKUP:
|
||||||
if notify_params['media_type'] in ('show', 'season', 'episode') and (notify_params.get('thetvdb_id') or notify_params.get('imdb_id')):
|
if notify_params['media_type'] in ('show', 'season', 'episode') and (notify_params.get('thetvdb_id') or notify_params.get('imdb_id')):
|
||||||
tvmaze_info = lookup_tvmaze_by_id(rating_key=rating_key,
|
if notify_params['media_type'] in ('episode', 'track'):
|
||||||
|
lookup_key = notify_params['grandparent_rating_key']
|
||||||
|
elif notify_params['media_type'] in ('season', 'album'):
|
||||||
|
lookup_key = notify_params['parent_rating_key']
|
||||||
|
else:
|
||||||
|
lookup_key = rating_key
|
||||||
|
|
||||||
|
tvmaze_info = lookup_tvmaze_by_id(rating_key=lookup_key,
|
||||||
thetvdb_id=notify_params.get('thetvdb_id'),
|
thetvdb_id=notify_params.get('thetvdb_id'),
|
||||||
imdb_id=notify_params.get('imdb_id'))
|
imdb_id=notify_params.get('imdb_id'))
|
||||||
notify_params.update(tvmaze_info)
|
notify_params.update(tvmaze_info)
|
||||||
|
|
|
@ -3591,6 +3591,8 @@ class WebInterface(object):
|
||||||
if metadata:
|
if metadata:
|
||||||
poster_info = data_factory.get_poster_info(metadata=metadata)
|
poster_info = data_factory.get_poster_info(metadata=metadata)
|
||||||
metadata.update(poster_info)
|
metadata.update(poster_info)
|
||||||
|
lookup_info = data_factory.get_lookup_info(metadata=metadata)
|
||||||
|
metadata.update(lookup_info)
|
||||||
else:
|
else:
|
||||||
pms_connect = pmsconnect.PmsConnect()
|
pms_connect = pmsconnect.PmsConnect()
|
||||||
metadata = pms_connect.get_metadata_details(rating_key=rating_key)
|
metadata = pms_connect.get_metadata_details(rating_key=rating_key)
|
||||||
|
@ -3598,6 +3600,8 @@ class WebInterface(object):
|
||||||
data_factory = datafactory.DataFactory()
|
data_factory = datafactory.DataFactory()
|
||||||
poster_info = data_factory.get_poster_info(metadata=metadata)
|
poster_info = data_factory.get_poster_info(metadata=metadata)
|
||||||
metadata.update(poster_info)
|
metadata.update(poster_info)
|
||||||
|
lookup_info = data_factory.get_lookup_info(metadata=metadata)
|
||||||
|
metadata.update(lookup_info)
|
||||||
|
|
||||||
if metadata:
|
if metadata:
|
||||||
if metadata['section_id'] and not allow_session_library(metadata['section_id']):
|
if metadata['section_id'] and not allow_session_library(metadata['section_id']):
|
||||||
|
@ -3884,14 +3888,58 @@ class WebInterface(object):
|
||||||
@requireAuth(member_of("admin"))
|
@requireAuth(member_of("admin"))
|
||||||
@addtoapi()
|
@addtoapi()
|
||||||
def delete_imgur_poster(self, rating_key='', **kwargs):
|
def delete_imgur_poster(self, rating_key='', **kwargs):
|
||||||
|
""" Delete the Imgur poster.
|
||||||
|
|
||||||
|
```
|
||||||
|
Required parameters:
|
||||||
|
rating_key (int): 1234
|
||||||
|
(Note: Must be the movie, show, season, artist, or album rating key)
|
||||||
|
Optional parameters:
|
||||||
|
None
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
json:
|
||||||
|
{"result": "success",
|
||||||
|
"message": "Deleted Imgur poster."}
|
||||||
|
```
|
||||||
|
"""
|
||||||
|
|
||||||
data_factory = datafactory.DataFactory()
|
data_factory = datafactory.DataFactory()
|
||||||
result = data_factory.delete_poster_url(rating_key=rating_key)
|
result = data_factory.delete_poster_url(rating_key=rating_key)
|
||||||
|
|
||||||
if result:
|
if result:
|
||||||
return {'result': 'success', 'message': 'Deleted Imgur poster url.'}
|
return {'result': 'success', 'message': 'Deleted Imgur poster.'}
|
||||||
else:
|
else:
|
||||||
return {'result': 'error', 'message': 'Failed to delete Imgur poster url.'}
|
return {'result': 'error', 'message': 'Failed to delete Imgur poster.'}
|
||||||
|
|
||||||
|
@cherrypy.expose
|
||||||
|
@cherrypy.tools.json_out()
|
||||||
|
@requireAuth(member_of("admin"))
|
||||||
|
@addtoapi()
|
||||||
|
def delete_lookup_info(self, rating_key='', title='', **kwargs):
|
||||||
|
""" Delete the 3rd party API lookup info.
|
||||||
|
|
||||||
|
```
|
||||||
|
Required parameters:
|
||||||
|
rating_key (int): 1234
|
||||||
|
(Note: Must be the movie, show, or artist rating key)
|
||||||
|
Optional parameters:
|
||||||
|
None
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
json:
|
||||||
|
{"result": "success",
|
||||||
|
"message": "Deleted lookup info."}
|
||||||
|
```
|
||||||
|
"""
|
||||||
|
|
||||||
|
data_factory = datafactory.DataFactory()
|
||||||
|
result = data_factory.delete_lookup_info(rating_key=rating_key, title=title)
|
||||||
|
|
||||||
|
if result:
|
||||||
|
return {'result': 'success', 'message': 'Deleted lookup info.'}
|
||||||
|
else:
|
||||||
|
return {'result': 'error', 'message': 'Failed to delete lookup info.'}
|
||||||
|
|
||||||
|
|
||||||
##### Search #####
|
##### Search #####
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue