mirror of
https://github.com/Tautulli/Tautulli.git
synced 2025-07-14 01:02:59 -07:00
Export art and thumb images
This commit is contained in:
parent
75cdc2c5e8
commit
b9f5251188
1 changed files with 35 additions and 7 deletions
|
@ -21,6 +21,7 @@ from backports import csv
|
||||||
|
|
||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
|
import requests
|
||||||
import threading
|
import threading
|
||||||
|
|
||||||
from functools import partial, reduce
|
from functools import partial, reduce
|
||||||
|
@ -57,7 +58,7 @@ class Export(object):
|
||||||
_movie_attrs = {
|
_movie_attrs = {
|
||||||
'addedAt': helpers.datetime_to_iso,
|
'addedAt': helpers.datetime_to_iso,
|
||||||
'art': None,
|
'art': None,
|
||||||
'artFile': lambda i: get_image(i, 'artUrl', self.filename),
|
'artFile': lambda i: get_image(i, 'art', self.filename),
|
||||||
'audienceRating': None,
|
'audienceRating': None,
|
||||||
'audienceRatingImage': None,
|
'audienceRatingImage': None,
|
||||||
'chapters': {
|
'chapters': {
|
||||||
|
@ -248,7 +249,7 @@ class Export(object):
|
||||||
'summary': None,
|
'summary': None,
|
||||||
'tagline': None,
|
'tagline': None,
|
||||||
'thumb': None,
|
'thumb': None,
|
||||||
'thumbFile': lambda i: get_image(i, 'thumbUrl', self.filename),
|
'thumbFile': lambda i: get_image(i, 'thumb', self.filename),
|
||||||
'title': None,
|
'title': None,
|
||||||
'titleSort': None,
|
'titleSort': None,
|
||||||
'type': None,
|
'type': None,
|
||||||
|
@ -267,6 +268,7 @@ class Export(object):
|
||||||
_show_attrs = {
|
_show_attrs = {
|
||||||
'addedAt': helpers.datetime_to_iso,
|
'addedAt': helpers.datetime_to_iso,
|
||||||
'art': None,
|
'art': None,
|
||||||
|
'artFile': lambda i: get_image(i, 'art', self.filename),
|
||||||
'banner': None,
|
'banner': None,
|
||||||
'childCount': None,
|
'childCount': None,
|
||||||
'collections': {
|
'collections': {
|
||||||
|
@ -310,6 +312,7 @@ class Export(object):
|
||||||
'summary': None,
|
'summary': None,
|
||||||
'theme': None,
|
'theme': None,
|
||||||
'thumb': None,
|
'thumb': None,
|
||||||
|
'thumbFile': lambda i: get_image(i, 'thumb', self.filename),
|
||||||
'title': None,
|
'title': None,
|
||||||
'titleSort': None,
|
'titleSort': None,
|
||||||
'type': None,
|
'type': None,
|
||||||
|
@ -349,6 +352,7 @@ class Export(object):
|
||||||
'ratingKey': None,
|
'ratingKey': None,
|
||||||
'summary': None,
|
'summary': None,
|
||||||
'thumb': None,
|
'thumb': None,
|
||||||
|
'thumbFile': lambda i: get_image(i, 'thumb', self.filename),
|
||||||
'title': None,
|
'title': None,
|
||||||
'titleSort': None,
|
'titleSort': None,
|
||||||
'type': None,
|
'type': None,
|
||||||
|
@ -547,6 +551,7 @@ class Export(object):
|
||||||
_artist_attrs = {
|
_artist_attrs = {
|
||||||
'addedAt': helpers.datetime_to_iso,
|
'addedAt': helpers.datetime_to_iso,
|
||||||
'art': None,
|
'art': None,
|
||||||
|
'artFile': lambda i: get_image(i, 'art', self.filename),
|
||||||
'collections': {
|
'collections': {
|
||||||
'id': None,
|
'id': None,
|
||||||
'tag': None
|
'tag': None
|
||||||
|
@ -583,6 +588,7 @@ class Export(object):
|
||||||
},
|
},
|
||||||
'summary': None,
|
'summary': None,
|
||||||
'thumb': None,
|
'thumb': None,
|
||||||
|
'thumbFile': lambda i: get_image(i, 'thumb', self.filename),
|
||||||
'title': None,
|
'title': None,
|
||||||
'titleSort': None,
|
'titleSort': None,
|
||||||
'type': None,
|
'type': None,
|
||||||
|
@ -598,6 +604,7 @@ class Export(object):
|
||||||
_album_attrs = {
|
_album_attrs = {
|
||||||
'addedAt': helpers.datetime_to_iso,
|
'addedAt': helpers.datetime_to_iso,
|
||||||
'art': None,
|
'art': None,
|
||||||
|
'artFile': lambda i: get_image(i, 'art', self.filename),
|
||||||
'collections': {
|
'collections': {
|
||||||
'id': None,
|
'id': None,
|
||||||
'tag': None
|
'tag': None
|
||||||
|
@ -641,6 +648,7 @@ class Export(object):
|
||||||
},
|
},
|
||||||
'summary': None,
|
'summary': None,
|
||||||
'thumb': None,
|
'thumb': None,
|
||||||
|
'thumbFile': lambda i: get_image(i, 'thumb', self.filename),
|
||||||
'title': None,
|
'title': None,
|
||||||
'titleSort': None,
|
'titleSort': None,
|
||||||
'type': None,
|
'type': None,
|
||||||
|
@ -852,6 +860,8 @@ class Export(object):
|
||||||
def collection_attrs():
|
def collection_attrs():
|
||||||
_collection_attrs = {
|
_collection_attrs = {
|
||||||
'addedAt': helpers.datetime_to_iso,
|
'addedAt': helpers.datetime_to_iso,
|
||||||
|
'art': None,
|
||||||
|
'artFile': lambda i: get_image(i, 'art', self.filename),
|
||||||
'childCount': None,
|
'childCount': None,
|
||||||
'collectionMode': None,
|
'collectionMode': None,
|
||||||
'collectionSort': None,
|
'collectionSort': None,
|
||||||
|
@ -872,6 +882,7 @@ class Export(object):
|
||||||
'subtype': None,
|
'subtype': None,
|
||||||
'summary': None,
|
'summary': None,
|
||||||
'thumb': None,
|
'thumb': None,
|
||||||
|
'thumbFile': lambda i: get_image(i, 'thumb', self.filename),
|
||||||
'title': None,
|
'title': None,
|
||||||
'type': None,
|
'type': None,
|
||||||
'updatedAt': helpers.datetime_to_iso,
|
'updatedAt': helpers.datetime_to_iso,
|
||||||
|
@ -1356,19 +1367,36 @@ def get_any_hdr(obj, root):
|
||||||
return any(vs.get('hdr') for p in media.get('parts', []) for vs in p.get('videoStreams', []))
|
return any(vs.get('hdr') for p in media.get('parts', []) for vs in p.get('videoStreams', []))
|
||||||
|
|
||||||
|
|
||||||
def get_image(item, prop, export_filename):
|
def get_image(item, image, export_filename):
|
||||||
url = getattr(item, prop)
|
|
||||||
media_type = item.type
|
media_type = item.type
|
||||||
|
rating_key = item.ratingKey
|
||||||
|
|
||||||
if media_type in ('season', 'episode', 'album', 'track'):
|
if media_type in ('season', 'episode', 'album', 'track'):
|
||||||
item_title = item._defaultSyncTitle()
|
item_title = item._defaultSyncTitle()
|
||||||
else:
|
else:
|
||||||
item_title = item.title
|
item_title = item.title
|
||||||
|
|
||||||
filename = os.path.join('{}.images'.format(export_filename), '{}.png'.format(item_title))
|
folder = get_export_filepath('{}.images'.format(export_filename))
|
||||||
|
filepath = os.path.join(folder, '{} [{}].{}.jpg'.format(item_title, rating_key, image))
|
||||||
|
if not os.path.exists(folder):
|
||||||
|
os.makedirs(folder)
|
||||||
|
|
||||||
file = get_export_filepath(filename)
|
image_url = None
|
||||||
return file
|
if image == 'art':
|
||||||
|
image_url = item.artUrl
|
||||||
|
elif image == 'thumb':
|
||||||
|
image_url = item.thumbUrl
|
||||||
|
|
||||||
|
if not image_url:
|
||||||
|
return
|
||||||
|
|
||||||
|
r = requests.get(image_url, stream=True)
|
||||||
|
if r.status_code == 200:
|
||||||
|
with open(filepath, 'wb') as outfile:
|
||||||
|
for chunk in r:
|
||||||
|
outfile.write(chunk)
|
||||||
|
|
||||||
|
return filepath
|
||||||
|
|
||||||
|
|
||||||
def get_export(export_id):
|
def get_export(export_id):
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue