mirror of
https://github.com/Tautulli/Tautulli.git
synced 2025-07-15 01:32:57 -07:00
Change export m3u8 to m3u extension
* m3u files are still encoded using UTF-8
This commit is contained in:
parent
1cdb55a6a9
commit
100fdd1df1
3 changed files with 25 additions and 25 deletions
|
@ -226,7 +226,7 @@ DOCUMENTATION :: END
|
||||||
getExportFields();
|
getExportFields();
|
||||||
|
|
||||||
$('#export_file_format').on('change', function() {
|
$('#export_file_format').on('change', function() {
|
||||||
if ($(this).val() === 'm3u8') {
|
if ($(this).val() === 'm3u') {
|
||||||
$('#export_metadata_level').prop('disabled', true);
|
$('#export_metadata_level').prop('disabled', true);
|
||||||
$('#export_media_info_level').prop('disabled', true);
|
$('#export_media_info_level').prop('disabled', true);
|
||||||
$("#export_thumb_level").prop('disabled', true);
|
$("#export_thumb_level").prop('disabled', true);
|
||||||
|
|
|
@ -102,7 +102,7 @@ class Export(object):
|
||||||
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)
|
||||||
IMAGE_LEVELS = (0, 1, 2, 9)
|
IMAGE_LEVELS = (0, 1, 2, 9)
|
||||||
FILE_FORMATS = ('csv', 'json', 'xml', 'm3u8')
|
FILE_FORMATS = ('csv', 'json', 'xml', 'm3u')
|
||||||
EXPORT_TYPES = ('all', 'collection', 'playlist')
|
EXPORT_TYPES = ('all', 'collection', 'playlist')
|
||||||
|
|
||||||
def __init__(self, section_id=None, user_id=None, rating_key=None, file_format='csv',
|
def __init__(self, section_id=None, user_id=None, rating_key=None, file_format='csv',
|
||||||
|
@ -141,8 +141,8 @@ class Export(object):
|
||||||
self.exported_items = 0
|
self.exported_items = 0
|
||||||
self.success = False
|
self.success = False
|
||||||
|
|
||||||
# Reset export options for m3u8
|
# Reset export options for m3u
|
||||||
if self.file_format == 'm3u8':
|
if self.file_format == 'm3u':
|
||||||
self.metadata_level = 1
|
self.metadata_level = 1
|
||||||
self.media_info_level = 1
|
self.media_info_level = 1
|
||||||
self.thumb_level = 0
|
self.thumb_level = 0
|
||||||
|
@ -1960,10 +1960,10 @@ class Export(object):
|
||||||
with open(filepath, 'w', encoding='utf-8') as outfile:
|
with open(filepath, 'w', encoding='utf-8') as outfile:
|
||||||
outfile.write(xml_data)
|
outfile.write(xml_data)
|
||||||
|
|
||||||
elif self.file_format == 'm3u8':
|
elif self.file_format == 'm3u':
|
||||||
m3u8_data = self.data_to_m3u8(result, obj)
|
m3u_data = self.data_to_m3u(result, obj)
|
||||||
with open(filepath, 'w', encoding='utf-8') as outfile:
|
with open(filepath, 'w', encoding='utf-8') as outfile:
|
||||||
outfile.write(m3u8_data)
|
outfile.write(m3u_data)
|
||||||
|
|
||||||
self.file_size += os.path.getsize(filepath)
|
self.file_size += os.path.getsize(filepath)
|
||||||
|
|
||||||
|
@ -2119,36 +2119,36 @@ class Export(object):
|
||||||
|
|
||||||
return helpers.dict_to_xml(xml_metadata, root_node='export', indent=4)
|
return helpers.dict_to_xml(xml_metadata, root_node='export', indent=4)
|
||||||
|
|
||||||
def data_to_m3u8(self, data, obj):
|
def data_to_m3u(self, data, obj):
|
||||||
items = self._get_m3u8_items(data)
|
items = self._get_m3u_items(data)
|
||||||
|
|
||||||
m3u8_metadata = {'title': obj.title, 'type': obj.media_type}
|
m3u_metadata = {'title': obj.title, 'type': obj.media_type}
|
||||||
if obj.rating_key:
|
if obj.rating_key:
|
||||||
m3u8_metadata['ratingKey'] = obj.rating_key
|
m3u_metadata['ratingKey'] = obj.rating_key
|
||||||
if obj.user_id:
|
if obj.user_id:
|
||||||
m3u8_metadata['userID'] = obj.user_id
|
m3u_metadata['userID'] = obj.user_id
|
||||||
if obj.section_id:
|
if obj.section_id:
|
||||||
m3u8_metadata['sectionID'] = obj.section_id
|
m3u_metadata['sectionID'] = obj.section_id
|
||||||
|
|
||||||
m3u8 = '#EXTM3U\n'
|
m3u = '#EXTM3U\n'
|
||||||
m3u8 += '# Playlist: {title}\n# {metadata}\n\n'.format(title=obj.title, metadata=json.dumps(m3u8_metadata))
|
m3u += '# Playlist: {title}\n# {metadata}\n\n'.format(title=obj.title, metadata=json.dumps(m3u_metadata))
|
||||||
m3u8_item_template = '# {metadata}\n#EXTINF:{duration},{title}\n{location}\n'
|
m3u_item_template = '# {metadata}\n#EXTINF:{duration},{title}\n{location}\n'
|
||||||
m3u8_items = []
|
m3u_items = []
|
||||||
|
|
||||||
for item in items:
|
for item in items:
|
||||||
m3u8_values = {
|
m3u_values = {
|
||||||
'duration': item.pop('duration'),
|
'duration': item.pop('duration'),
|
||||||
'title': item.pop('title'),
|
'title': item.pop('title'),
|
||||||
'location': item.pop('location'),
|
'location': item.pop('location'),
|
||||||
'metadata': json.dumps(item)
|
'metadata': json.dumps(item)
|
||||||
}
|
}
|
||||||
m3u8_items.append(m3u8_item_template.format(**m3u8_values))
|
m3u_items.append(m3u_item_template.format(**m3u_values))
|
||||||
|
|
||||||
m3u8 = m3u8 + '\n'.join(m3u8_items)
|
m3u = m3u + '\n'.join(m3u_items)
|
||||||
|
|
||||||
return m3u8
|
return m3u
|
||||||
|
|
||||||
def _get_m3u8_items(self, data):
|
def _get_m3u_items(self, data):
|
||||||
items = []
|
items = []
|
||||||
|
|
||||||
for d in data:
|
for d in data:
|
||||||
|
@ -2167,7 +2167,7 @@ class Export(object):
|
||||||
items.append(metadata)
|
items.append(metadata)
|
||||||
|
|
||||||
for child_media_type in self.CHILD_MEDIA_TYPES[d['type']]:
|
for child_media_type in self.CHILD_MEDIA_TYPES[d['type']]:
|
||||||
child_locations = self._get_m3u8_items(d[self.PLURAL_MEDIA_TYPES[child_media_type]])
|
child_locations = self._get_m3u_items(d[self.PLURAL_MEDIA_TYPES[child_media_type]])
|
||||||
items.extend(child_locations)
|
items.extend(child_locations)
|
||||||
|
|
||||||
return items
|
return items
|
||||||
|
|
|
@ -7003,7 +7003,7 @@ class WebInterface(object):
|
||||||
rating_key (int): The rating key of the media item to export
|
rating_key (int): The rating key of the media item to export
|
||||||
|
|
||||||
Optional parameters:
|
Optional parameters:
|
||||||
file_format (str): csv (default), json, xml, or m3u8
|
file_format (str): csv (default), json, xml, or m3u
|
||||||
metadata_level (int): The level of metadata to export (default 1)
|
metadata_level (int): The level of metadata to export (default 1)
|
||||||
media_info_level (int): The level of media info to export (default 1)
|
media_info_level (int): The level of media info to export (default 1)
|
||||||
thumb_level (int): The level of poster/cover images to export (default 0)
|
thumb_level (int): The level of poster/cover images to export (default 0)
|
||||||
|
@ -7084,7 +7084,7 @@ class WebInterface(object):
|
||||||
elif result['file_format'] == 'xml':
|
elif result['file_format'] == 'xml':
|
||||||
return serve_file(filepath, name=result['filename'], content_type='application/xml;charset=UTF-8')
|
return serve_file(filepath, name=result['filename'], content_type='application/xml;charset=UTF-8')
|
||||||
|
|
||||||
elif result['file_format'] == 'm3u8':
|
elif result['file_format'] == 'm3u':
|
||||||
return serve_file(filepath, name=result['filename'], content_type='text/plain;charset=UTF-8')
|
return serve_file(filepath, name=result['filename'], content_type='text/plain;charset=UTF-8')
|
||||||
|
|
||||||
else:
|
else:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue