mirror of
https://github.com/Tautulli/Tautulli.git
synced 2025-07-14 01:02:59 -07:00
Add custom fields for collections and playlists
This commit is contained in:
parent
54433c43e6
commit
97775e2a3b
4 changed files with 37 additions and 21 deletions
|
@ -27,6 +27,7 @@ DOCUMENTATION :: END
|
||||||
<input type="hidden" id="export_section_id" name="export_section_id" value="${section_id or ''}" />
|
<input type="hidden" id="export_section_id" name="export_section_id" value="${section_id or ''}" />
|
||||||
<input type="hidden" id="export_rating_key" name="export_rating_key" value="${rating_key or ''}" />
|
<input type="hidden" id="export_rating_key" name="export_rating_key" value="${rating_key or ''}" />
|
||||||
<input type="hidden" id="export_media_type" name="export_media_type" value="${media_type or ''}" />
|
<input type="hidden" id="export_media_type" name="export_media_type" value="${media_type or ''}" />
|
||||||
|
<input type="hidden" id="export_sub_media_type" name="export_sub_media_type" value="${sub_media_type or ''}" />
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="metadata_export_level_select">Metadata Export Level</label>
|
<label for="metadata_export_level_select">Metadata Export Level</label>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
|
@ -168,7 +169,8 @@ DOCUMENTATION :: END
|
||||||
url: 'get_export_fields',
|
url: 'get_export_fields',
|
||||||
async: true,
|
async: true,
|
||||||
data: {
|
data: {
|
||||||
media_type: $('#export_media_type').val()
|
media_type: $('#export_media_type').val(),
|
||||||
|
sub_media_type: $('#export_sub_media_type').val()
|
||||||
},
|
},
|
||||||
success: function (result) {
|
success: function (result) {
|
||||||
if (result) {
|
if (result) {
|
||||||
|
|
|
@ -550,7 +550,8 @@ DOCUMENTATION :: END
|
||||||
<div class="button-bar">
|
<div class="button-bar">
|
||||||
<div class="btn-group">
|
<div class="btn-group">
|
||||||
<button class="btn btn-dark export-button" id="toggle-export-modal" data-toggle="modal" data-target="#export-modal"
|
<button class="btn btn-dark export-button" id="toggle-export-modal" data-toggle="modal" data-target="#export-modal"
|
||||||
data-section_id="${data['section_id']}" data-rating_key="${data['rating_key']}" data-media_type="${data['media_type']}">
|
data-section_id="${data['section_id']}" data-rating_key="${data['rating_key']}"
|
||||||
|
data-media_type="${data['media_type']}" data-sub_media_type="${data['sub_media_type'] or ''}">
|
||||||
<i class="fa fa-file-export"></i> Export Metadata
|
<i class="fa fa-file-export"></i> Export Metadata
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
@ -884,7 +885,8 @@ DOCUMENTATION :: END
|
||||||
data: {
|
data: {
|
||||||
section_id: $(this).data('section_id'),
|
section_id: $(this).data('section_id'),
|
||||||
rating_key: $(this).data('rating_key'),
|
rating_key: $(this).data('rating_key'),
|
||||||
media_type: $(this).data('media_type')
|
media_type: $(this).data('media_type'),
|
||||||
|
sub_media_type: $(this).data('sub_media_type')
|
||||||
},
|
},
|
||||||
cache: false,
|
cache: false,
|
||||||
async: true,
|
async: true,
|
||||||
|
|
|
@ -83,8 +83,9 @@ class Export(object):
|
||||||
'album': 'track',
|
'album': 'track',
|
||||||
'track': '',
|
'track': '',
|
||||||
'photoalbum': 'photo',
|
'photoalbum': 'photo',
|
||||||
|
'photo': '',
|
||||||
'collection': 'children',
|
'collection': 'children',
|
||||||
'playlist': 'items'
|
'playlist': 'item'
|
||||||
}
|
}
|
||||||
METADATA_LEVELS = (0, 1, 2, 3, 9)
|
METADATA_LEVELS = (0, 1, 2, 3, 9)
|
||||||
MEDIA_INFO_LEVELS = (0, 1, 2, 3, 9)
|
MEDIA_INFO_LEVELS = (0, 1, 2, 3, 9)
|
||||||
|
@ -1889,11 +1890,18 @@ def check_export_exists(filename):
|
||||||
return os.path.isfile(get_export_filepath(filename))
|
return os.path.isfile(get_export_filepath(filename))
|
||||||
|
|
||||||
|
|
||||||
def get_custom_fields(media_type):
|
def get_custom_fields(media_type, sub_media_type=None):
|
||||||
|
custom_fields = {
|
||||||
|
'metadata_fields': [],
|
||||||
|
'media_info_fields': []
|
||||||
|
}
|
||||||
|
|
||||||
export = Export()
|
export = Export()
|
||||||
|
|
||||||
if media_type not in export.MEDIA_TYPES:
|
if media_type not in export.MEDIA_TYPES:
|
||||||
return {'metadata_fields': [], 'media_info_fields': []}
|
return custom_fields
|
||||||
|
elif media_type in ('collection', 'playlist') and sub_media_type not in export.MEDIA_TYPES:
|
||||||
|
return custom_fields
|
||||||
|
|
||||||
metadata_levels_map, media_info_levels_map = export.return_attrs_level_map(media_type)
|
metadata_levels_map, media_info_levels_map = export.return_attrs_level_map(media_type)
|
||||||
|
|
||||||
|
@ -1901,23 +1909,24 @@ def get_custom_fields(media_type):
|
||||||
child_media_type = export.CHILD_MEDIA_TYPES[media_type]
|
child_media_type = export.CHILD_MEDIA_TYPES[media_type]
|
||||||
|
|
||||||
while child_media_type:
|
while child_media_type:
|
||||||
|
if child_media_type in ('children', 'item'):
|
||||||
|
fields_child_media_type = sub_media_type
|
||||||
|
else:
|
||||||
|
fields_child_media_type = child_media_type
|
||||||
|
|
||||||
prefix = prefix + export.PLURAL_MEDIA_TYPES[child_media_type] + '.'
|
prefix = prefix + export.PLURAL_MEDIA_TYPES[child_media_type] + '.'
|
||||||
|
|
||||||
child_metadata_levels_map, child_media_info_levels_map = export.return_attrs_level_map(
|
child_metadata_levels_map, child_media_info_levels_map = export.return_attrs_level_map(
|
||||||
child_media_type, prefix=prefix)
|
fields_child_media_type, prefix=prefix)
|
||||||
|
|
||||||
metadata_levels_map.update(child_metadata_levels_map)
|
metadata_levels_map.update(child_metadata_levels_map)
|
||||||
media_info_levels_map.update(child_media_info_levels_map)
|
media_info_levels_map.update(child_media_info_levels_map)
|
||||||
|
|
||||||
child_media_type = export.CHILD_MEDIA_TYPES[child_media_type]
|
child_media_type = export.CHILD_MEDIA_TYPES.get(fields_child_media_type)
|
||||||
|
|
||||||
custom_metadata_fields = [{'field': attr, 'level': level}
|
custom_fields['metadata_fields'] = [{'field': attr, 'level': level}
|
||||||
for attr, level in sorted(metadata_levels_map.items()) if level]
|
for attr, level in sorted(metadata_levels_map.items()) if level]
|
||||||
custom_media_info_fields = [{'field': attr, 'level': level}
|
custom_fields['media_info_fields'] = [{'field': attr, 'level': level}
|
||||||
for attr, level in sorted(media_info_levels_map.items()) if level]
|
for attr, level in sorted(media_info_levels_map.items()) if level]
|
||||||
|
|
||||||
custom_fields = {
|
|
||||||
'metadata_fields': custom_metadata_fields,
|
|
||||||
'media_info_fields': custom_media_info_fields
|
|
||||||
}
|
|
||||||
return custom_fields
|
return custom_fields
|
||||||
|
|
|
@ -6482,16 +6482,18 @@ class WebInterface(object):
|
||||||
|
|
||||||
@cherrypy.expose
|
@cherrypy.expose
|
||||||
@requireAuth(member_of("admin"))
|
@requireAuth(member_of("admin"))
|
||||||
def export_metadata_modal(self, section_id=None, rating_key=None, media_type=None, **kwargs):
|
def export_metadata_modal(self, section_id=None, rating_key=None,
|
||||||
|
media_type=None, sub_media_type=None, **kwargs):
|
||||||
|
|
||||||
return serve_template(templatename="export_modal.html", title="Export Metadata",
|
return serve_template(templatename="export_modal.html", title="Export Metadata",
|
||||||
section_id=section_id, rating_key=rating_key, media_type=media_type)
|
section_id=section_id, rating_key=rating_key,
|
||||||
|
media_type=media_type, sub_media_type=sub_media_type)
|
||||||
|
|
||||||
@cherrypy.expose
|
@cherrypy.expose
|
||||||
@cherrypy.tools.json_out()
|
@cherrypy.tools.json_out()
|
||||||
@requireAuth(member_of("admin"))
|
@requireAuth(member_of("admin"))
|
||||||
@addtoapi()
|
@addtoapi()
|
||||||
def get_export_fields(self, media_type=None, **kwargs):
|
def get_export_fields(self, media_type=None, sub_media_type=None, **kwargs):
|
||||||
""" Get a list of available custom export fields.
|
""" Get a list of available custom export fields.
|
||||||
|
|
||||||
```
|
```
|
||||||
|
@ -6499,7 +6501,7 @@ class WebInterface(object):
|
||||||
media_type (str): The media type of the fields to return
|
media_type (str): The media type of the fields to return
|
||||||
|
|
||||||
Optional parameters:
|
Optional parameters:
|
||||||
None
|
sub_media_type (str): The child media type for collections or playlists
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
json:
|
json:
|
||||||
|
@ -6514,7 +6516,8 @@ class WebInterface(object):
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
"""
|
"""
|
||||||
custom_fields = exporter.get_custom_fields(media_type=media_type)
|
custom_fields = exporter.get_custom_fields(media_type=media_type,
|
||||||
|
sub_media_type=sub_media_type)
|
||||||
|
|
||||||
return custom_fields
|
return custom_fields
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue