refactor codes
This commit is contained in:
+30
-5
@@ -1,13 +1,38 @@
|
|||||||
{
|
{
|
||||||
"id": "aniplay",
|
"id": "aniplay",
|
||||||
"name": "AniPlay",
|
"name": "AniPlay",
|
||||||
"language": ["ita"],
|
|
||||||
"active": true,
|
"active": true,
|
||||||
"thumbnail": "",
|
"language": ["ita", "sub-ita"],
|
||||||
"banner": "",
|
"thumbnail": "aniplay.png",
|
||||||
"categories": ["anime"],
|
"banner": "aniplay.png",
|
||||||
"not_active": ["include_in_newest"],
|
"categories": ["anime", "vos"],
|
||||||
"settings": [
|
"settings": [
|
||||||
|
{
|
||||||
|
"id": "sort",
|
||||||
|
"type": "list",
|
||||||
|
"label": "Ordine di Visualizzazione",
|
||||||
|
"default": 0,
|
||||||
|
"enabled": true,
|
||||||
|
"visible": true,
|
||||||
|
"lvalues": [ "Popolarità", "Titolo", "Numero Episodi", "Data di inizio", "Data di fine", "Data di aggiunta"]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "order",
|
||||||
|
"type": "bool",
|
||||||
|
"label": "Visualizza in ordine Discendente?",
|
||||||
|
"default": false,
|
||||||
|
"enabled": true,
|
||||||
|
"visible": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "perpage",
|
||||||
|
"type": "list",
|
||||||
|
"label": "Numero di elementi per pagina",
|
||||||
|
"default": 1,
|
||||||
|
"enabled": true,
|
||||||
|
"visible": true,
|
||||||
|
"lvalues": ["10", "20", "30", "40", "50", "60", "80", "90"]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"id": "include_in_global_search",
|
"id": "include_in_global_search",
|
||||||
"type": "bool",
|
"type": "bool",
|
||||||
|
|||||||
+237
-208
@@ -1,90 +1,78 @@
|
|||||||
from platformcode import config
|
from platformcode import config, logger, autorenumber
|
||||||
from core import httptools, scrapertools, support, tmdb
|
from core import httptools, scrapertools, support, tmdb
|
||||||
|
from inspect import stack
|
||||||
|
|
||||||
|
import sys
|
||||||
|
if sys.version_info[0] >= 3:
|
||||||
|
from concurrent import futures
|
||||||
|
else:
|
||||||
|
from concurrent_py2 import futures
|
||||||
|
|
||||||
|
host = config.get_channel_url()
|
||||||
|
sort = ['views', 'title', 'episodeNumber', 'startDate', 'endDate', 'createdDate'][config.get_setting('sort', 'aniplay')]
|
||||||
|
order = 'desc' if config.get_setting('order', 'aniplay') else 'asc'
|
||||||
|
perpage = [10, 20, 30 ,40, 50, 60, 70, 80, 90][config.get_setting('perpage', 'aniplay')]
|
||||||
|
|
||||||
host = 'https://aniplay.it'
|
|
||||||
|
|
||||||
@support.menu
|
@support.menu
|
||||||
def mainlist(item):
|
def mainlist(item):
|
||||||
anime=['/api/anime/advanced-search',
|
anime=['/api/anime/advanced-search',
|
||||||
('A-Z', ['/api/anime/advanced-search', 'alphabetical_strip', '']),
|
('A-Z', ['/api/anime/advanced-search', 'submenu_az', '']),
|
||||||
('Anno', ['', 'seasonal_by_year', '']),
|
('Anno', ['', 'submenu_year', '']),
|
||||||
('Top', ['', 'top_items', '']),
|
('Top', ['', 'submenu_top', '']),
|
||||||
('Ultimi aggiunti', ['', 'latest_added', '']),
|
('Ultimi aggiunti', ['', 'latest_added', ''])]
|
||||||
]
|
|
||||||
return locals()
|
return locals()
|
||||||
|
|
||||||
def alphabetical_strip(item):
|
|
||||||
|
def submenu_az(item):
|
||||||
itemlist = []
|
itemlist = []
|
||||||
alphabet = ("0-9, A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y, Z").split(', ')
|
if item.args == 'az':
|
||||||
for letter in alphabet:
|
for letter in ['0-9'] + list('ABCDEFGHIJKLMNOPQRSTUVWXYZ'):
|
||||||
itemlist.append(
|
itemlist.append(item.clone(title = support.typo(letter, 'bold'),
|
||||||
item.clone(title = support.typo(letter, 'bold'),
|
url= host + '/api/anime/find-by-char',
|
||||||
fulltitle= letter,
|
action= 'peliculas',
|
||||||
show= letter,
|
variable= '&character=' + letter,
|
||||||
url= host + '/api/anime/find-by-char',
|
thumbnail=support.thumb('az')))
|
||||||
action= 'peliculas',
|
|
||||||
videolibrary= False,
|
|
||||||
variable= '&character=' + letter,
|
|
||||||
thumbnail=support.thumb('az'))
|
|
||||||
)
|
|
||||||
return itemlist
|
return itemlist
|
||||||
|
|
||||||
def seasonal_by_year(item):
|
def submenu_year(item):
|
||||||
itemlist = []
|
itemlist = []
|
||||||
from datetime import date
|
from datetime import date
|
||||||
current = date.today().year
|
current = date.today().year
|
||||||
first = int(httptools.downloadpage('{}/api/anime/advanced-search?page=0&size=1&sort=startDate,asc&sort=id'.format(host)).json[0]['startDate'].split('-')[0]) -1
|
first = int(httptools.downloadpage('{}/api/anime/advanced-search?page=0&size=1&sort=startDate,asc&sort=id'.format(host)).json[0]['startDate'].split('-')[0]) -1
|
||||||
for year in range(current, first, -1):
|
for year in range(current, first, -1):
|
||||||
itemlist.append(
|
itemlist.append(item.clone(title = support.typo(year, 'bold'),
|
||||||
item.clone(title = support.typo(year, 'bold'),
|
action= 'submenu_season',
|
||||||
fulltitle= year,
|
variable= year,
|
||||||
show= year,
|
thumbnail=support.thumb('year')))
|
||||||
action= 'seasonal',
|
|
||||||
videolibrary= False,
|
|
||||||
variable= year,
|
|
||||||
thumbnail=support.thumb('az'))
|
|
||||||
)
|
|
||||||
|
|
||||||
return itemlist
|
return itemlist
|
||||||
|
|
||||||
|
def submenu_top(item):
|
||||||
def top_items(item):
|
|
||||||
itemlist = []
|
itemlist = []
|
||||||
links = {'Top del giorno':'daily-top', 'Top della settimana':'weekly-top', 'Top del mese':'monthly-top'}
|
links = {'Top del giorno':'daily-top', 'Top della settimana':'weekly-top', 'Top del mese':'monthly-top'}
|
||||||
for label in links:
|
for label in links:
|
||||||
link = links[ label ]
|
link = links[label]
|
||||||
itemlist.append(
|
itemlist.append(item.clone(title = support.typo(label, 'bold'),
|
||||||
item.clone(title = support.typo(label, 'bold'),
|
action= 'submenu_top_of',
|
||||||
fulltitle= label,
|
variable= link))
|
||||||
show= label,
|
|
||||||
action= 'top_of',
|
|
||||||
videolibrary= False,
|
|
||||||
variable= link,
|
|
||||||
)
|
|
||||||
)
|
|
||||||
return itemlist
|
return itemlist
|
||||||
|
|
||||||
|
def submenu_season(item):
|
||||||
def seasonal(item):
|
|
||||||
itemlist = []
|
itemlist = []
|
||||||
|
seasons = {'winter':'Inverno', 'spring':'Primavera', 'summer':'Estate', 'fall':'Autunno'}
|
||||||
url= '{}/api/seasonal-view?page=0&size=36&years={}'.format(host, item.variable)
|
url= '{}/api/seasonal-view?page=0&size=36&years={}'.format(host, item.variable)
|
||||||
js = httptools.downloadpage(url).json[0]['seasonalAnime']
|
js = httptools.downloadpage(url).json[0]['seasonalAnime']
|
||||||
for season in js:
|
for season in js:
|
||||||
seasons = {'winter':'Inverno', 'spring':'Primavera', 'summer':'Estate', 'fall':'Autunno'}
|
|
||||||
s = season['season'].split('.')[-1]
|
s = season['season'].split('.')[-1]
|
||||||
title = seasons[s]
|
title = seasons[s]
|
||||||
itemlist.append(
|
itemlist.append(item.clone(title=title,
|
||||||
item.clone(title=title,
|
url = '{}/api/seasonal-view/{}-{}'.format(host, s, item.variable),
|
||||||
url = '{}/api/seasonal-view/{}-{}'.format(host, s, item.variable),
|
thumbnail = support.thumb(s),
|
||||||
thumbnail = support.thumb(s),
|
action = 'peliculas',
|
||||||
action = 'peliculas',
|
variable=''))
|
||||||
variable=''
|
|
||||||
)
|
|
||||||
)
|
|
||||||
return itemlist
|
return itemlist
|
||||||
|
|
||||||
|
def submenu_top_of(item):
|
||||||
def top_of(item):
|
|
||||||
itemlist = []
|
itemlist = []
|
||||||
url= '{}/api/home/{}'.format(host, item.variable)
|
url= '{}/api/home/{}'.format(host, item.variable)
|
||||||
js = httptools.downloadpage(url).json
|
js = httptools.downloadpage(url).json
|
||||||
@@ -95,48 +83,204 @@ def top_of(item):
|
|||||||
lang = scrapedlang.upper() if scrapedlang else 'Sub-ITA'
|
lang = scrapedlang.upper() if scrapedlang else 'Sub-ITA'
|
||||||
long_title = support.typo(title, 'bold') + support.typo(lang, '_ [] color kod')
|
long_title = support.typo(title, 'bold') + support.typo(lang, '_ [] color kod')
|
||||||
|
|
||||||
itemlist.append(
|
itemlist.append(item.clone(title=long_title,
|
||||||
item.clone(title=long_title,
|
id=anime['animeId'],
|
||||||
id=anime['animeId'],
|
url = '{}/api/anime/{}'.format(host, anime['animeId']),
|
||||||
url = '{}/api/anime/{}'.format(host, anime['animeId']),
|
thumbnail = get_thumbnail(anime, 'animeHorizontalImages'),
|
||||||
thumbnail = get_thumbnail(anime, prop='animeHorizontalImages'),
|
action = 'episodios',
|
||||||
action = 'episodios',
|
variable=anime['animeId']))
|
||||||
variable=anime['animeId']
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
return itemlist
|
return itemlist
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
def search(item, texto):
|
||||||
|
support.info(texto)
|
||||||
|
item.url = host + '/api/anime/advanced-search'
|
||||||
|
item.variable = '&query=' + texto
|
||||||
|
|
||||||
|
try:
|
||||||
|
return peliculas(item)
|
||||||
|
# Continua la ricerca in caso di errore
|
||||||
|
except:
|
||||||
|
import sys
|
||||||
|
for line in sys.exc_info():
|
||||||
|
support.logger.error("%s" % line)
|
||||||
|
return []
|
||||||
|
|
||||||
|
|
||||||
|
def newest(categoria):
|
||||||
|
support.info(categoria)
|
||||||
|
item = support.Item()
|
||||||
|
try:
|
||||||
|
if categoria == "anime":
|
||||||
|
return latest_added(item)
|
||||||
|
# Continua la ricerca in caso di errore
|
||||||
|
except:
|
||||||
|
import sys
|
||||||
|
for line in sys.exc_info():
|
||||||
|
support.logger.error("{0}".format(line))
|
||||||
|
return []
|
||||||
|
|
||||||
|
|
||||||
def latest_added(item):
|
def latest_added(item):
|
||||||
itemlist = []
|
itemlist = []
|
||||||
page = item.page if item.page else 0
|
page = item.page if item.page else 0
|
||||||
url= '{}/api/home/latest-episodes?page={}'.format(host, page)
|
url= '{}/api/home/latest-episodes?page={}'.format(host, page)
|
||||||
js = httptools.downloadpage(url).json
|
js = httptools.downloadpage(url).json
|
||||||
|
|
||||||
for episode in js:
|
for episode in js:
|
||||||
fulltitle = episode['title']
|
title = episode['title']
|
||||||
title = fulltitle
|
animeTitle, lang = get_lang(episode['animeTitle'])
|
||||||
quality = episode['fullHd']
|
quality = 'Full HD' if episode['fullHd'] else 'HD'
|
||||||
lang = 'FHD' if quality else 'HD'
|
long_title = support.typo('{}. {}{}'.format(int(float(episode['episodeNumber'])), title + ' - ' if title else '', animeTitle), 'bold') + support.typo(lang, '_ [] color kod') + support.typo(quality, '_ [] color kod')
|
||||||
long_title = support.typo(title, 'bold') + support.typo(lang, '_ [] color kod')
|
image = get_thumbnail(episode, 'episodeImages')
|
||||||
itemlist.append(
|
|
||||||
item.clone(
|
itemlist.append(item.clone(title=long_title,
|
||||||
title=long_title,
|
fulltitle=title,
|
||||||
animeId = episode['animeId'],
|
animeId = episode['animeId'],
|
||||||
id=episode['id'],
|
id=episode['id'],
|
||||||
contentType = 'episode',
|
contentType = 'episode',
|
||||||
contentTitle = fulltitle,
|
contentTitle = title,
|
||||||
contentSerieName = episode['animeTitle'],
|
contentSerieName = animeTitle,
|
||||||
animeUrl = '{}/api/anime/{}'.format(host, episode['animeId']),
|
contentLanguage = lang,
|
||||||
thumbnail = get_thumbnail(episode, prop='episodeImages'),
|
quality = quality,
|
||||||
action = 'findvideos',
|
contentEpisodeNumber = int(float(episode['episodeNumber'])),
|
||||||
)
|
animeUrl = '{}/api/anime/{}'.format(host, episode['animeId']),
|
||||||
)
|
thumbnail = image,
|
||||||
support.nextPage(itemlist, item.clone(page = page + 1))
|
fanart = image,
|
||||||
|
action = 'findvideos'))
|
||||||
|
|
||||||
|
if stack()[1][3] not in ['newest']:
|
||||||
|
support.nextPage(itemlist, item.clone(page = page + 1))
|
||||||
|
|
||||||
return itemlist
|
return itemlist
|
||||||
|
|
||||||
|
|
||||||
def get_thumbnail(data, key = 'medium', prop = 'verticalImages'):
|
def peliculas(item):
|
||||||
|
logger.debug()
|
||||||
|
|
||||||
|
itemlist = []
|
||||||
|
page = item.page if item.page else 0
|
||||||
|
js = httptools.downloadpage('{}?page={}&size={}{}&sort={},{}&sort=id'.format(item.url, page, perpage, item.variable, sort, order)).json
|
||||||
|
|
||||||
|
for it in js:
|
||||||
|
title, lang = get_lang(it['title'])
|
||||||
|
active = False if it['status'] == 'Annunciato' or not it['episodeNumber'] else True
|
||||||
|
|
||||||
|
if active:
|
||||||
|
long_title = support.typo(title, 'bold') + support.typo(lang, '_ [] color kod')
|
||||||
|
else:
|
||||||
|
long_title = support.typo(title, 'italic') + support.typo('Annunciato', '_ [] color kod italic')
|
||||||
|
|
||||||
|
itemlist.append(item.clone(title = long_title,
|
||||||
|
fulltitle = title,
|
||||||
|
show = title,
|
||||||
|
contentLanguage = lang,
|
||||||
|
contentType = 'movie' if it['type'] == 'Movie' else 'tvshow',
|
||||||
|
contentTitle = title,
|
||||||
|
contentSerieName = title if it['type'] == 'Serie' else '',
|
||||||
|
action = '' if not active else 'findvideos' if it['type'] == 'Movie' else 'episodios',
|
||||||
|
plot = it['storyline'],
|
||||||
|
year = it['startDate'].split('-')[0],
|
||||||
|
id= it['id'],
|
||||||
|
thumbnail = get_thumbnail(it),
|
||||||
|
fanart = get_thumbnail(it, 'horizontalImages')))
|
||||||
|
|
||||||
|
autorenumber.start(itemlist)
|
||||||
|
tmdb.set_infoLabels_itemlist(itemlist, seekTmdb=True)
|
||||||
|
|
||||||
|
if len(itemlist) == perpage:
|
||||||
|
support.nextPage(itemlist, item.clone(page = page + 1))
|
||||||
|
return itemlist
|
||||||
|
|
||||||
|
|
||||||
|
def episodios(item):
|
||||||
|
logger.debug()
|
||||||
|
itemlist = []
|
||||||
|
|
||||||
|
url = '{}/api/anime/{}'.format(host, item.id)
|
||||||
|
json = httptools.downloadpage(url, CF=False ).json
|
||||||
|
|
||||||
|
if 'seasons' in json and len(json['seasons']) > 0:
|
||||||
|
seasons = json['seasons']
|
||||||
|
seasons.sort(key=lambda s: s['episodeStart'])
|
||||||
|
|
||||||
|
for i, it in enumerate(seasons):
|
||||||
|
title = it['name']
|
||||||
|
|
||||||
|
itemlist.append(item.clone(title = title,
|
||||||
|
id= '{}/season/{}'.format(it['animeId'], it['id']),
|
||||||
|
contentType = 'season',
|
||||||
|
contentSeason = i,
|
||||||
|
action = 'episodios',
|
||||||
|
plot = json['storyline'],
|
||||||
|
year = it['yearStart']))
|
||||||
|
|
||||||
|
if stack()[1][3] in ['add_tvshow', 'get_episodes', 'update', 'find_episodes']:
|
||||||
|
itlist = []
|
||||||
|
with futures.ThreadPoolExecutor() as executor:
|
||||||
|
eplist = [executor.submit(episodios, item) for item in itemlist]
|
||||||
|
for res in futures.as_completed(eplist):
|
||||||
|
if res.result():
|
||||||
|
itlist.extend(res.result())
|
||||||
|
itemlist = itlist
|
||||||
|
|
||||||
|
elif ('episodes' in json and len(json['episodes']) > 0) or len(json) > 0:
|
||||||
|
episodes = json['episodes'] if 'episodes' in json else json
|
||||||
|
|
||||||
|
episodes.sort(key=lambda ep: int(ep['episodeNumber']))
|
||||||
|
|
||||||
|
for it in episodes:
|
||||||
|
quality = 'Full HD' if it['fullHd'] else 'HD'
|
||||||
|
|
||||||
|
if item.contentSeason:
|
||||||
|
episode = '{}x{:02d}'.format(item.contentSeason, int(it['episodeNumber']))
|
||||||
|
else:
|
||||||
|
episode = '{:02d}'.format(int(it['episodeNumber']))
|
||||||
|
|
||||||
|
title = support.typo('{}. {}'.format(episode, it['title']), 'bold')
|
||||||
|
image = get_thumbnail(it, 'episodeImages')
|
||||||
|
|
||||||
|
itemlist.append(item.clone(title = title,
|
||||||
|
id= it['id'],
|
||||||
|
url= 'api/episode/{}'.format(it['id']),
|
||||||
|
contentType = 'episode',
|
||||||
|
contentEpisodeNumber = int(it['episodeNumber']),
|
||||||
|
contentSeason = item.contentSeason if item.contentSeason else '',
|
||||||
|
action = 'findvideos',
|
||||||
|
quality = quality,
|
||||||
|
thumbnail = image,
|
||||||
|
fanart= image,
|
||||||
|
year = it['airingDate'].split('-')[0]))
|
||||||
|
|
||||||
|
if not item.contentSeason and stack()[1][3] not in ['find_episodes']:
|
||||||
|
autorenumber.start(itemlist, item)
|
||||||
|
|
||||||
|
if stack()[1][3] not in ['add_tvshow', 'get_episodes', 'update', 'find_episodes']:
|
||||||
|
support.videolibrary(itemlist, item)
|
||||||
|
return itemlist
|
||||||
|
|
||||||
|
|
||||||
|
def findvideos(item):
|
||||||
|
logger.debug()
|
||||||
|
|
||||||
|
url = '{}/api/{}/{}'.format(host, 'episode' if item.contentType == 'episode' else 'anime', item.id)
|
||||||
|
|
||||||
|
json = httptools.downloadpage(url, CF=False ).json
|
||||||
|
|
||||||
|
if json.get('episodes', []):
|
||||||
|
json = httptools.downloadpage('{}/api/episode/{}'.format(host, json['episodes'][0]['id'])).json
|
||||||
|
|
||||||
|
videourl = json['episodeVideo']
|
||||||
|
|
||||||
|
itemlist = [item.clone(title=config.get_localized_string(30137),
|
||||||
|
url=videourl,
|
||||||
|
server='directo')]
|
||||||
|
|
||||||
|
return support.server(item, itemlist=itemlist)
|
||||||
|
|
||||||
|
|
||||||
|
def get_thumbnail(data, prop = 'verticalImages', key = 'full'):
|
||||||
"""
|
"""
|
||||||
" Returns the vertical image as per given key and prop
|
" Returns the vertical image as per given key and prop
|
||||||
" possibile key values are:
|
" possibile key values are:
|
||||||
@@ -152,131 +296,16 @@ def get_thumbnail(data, key = 'medium', prop = 'verticalImages'):
|
|||||||
" - episodeImages
|
" - episodeImages
|
||||||
"""
|
"""
|
||||||
value = None
|
value = None
|
||||||
verticalImages = data[prop]
|
verticalImages = data.get(prop, [])
|
||||||
if verticalImages:
|
if verticalImages:
|
||||||
first = verticalImages[0]
|
first = verticalImages[0]
|
||||||
if first:
|
if first:
|
||||||
value = first[ 'image' + key.capitalize() ]
|
value = first.get('image' + key.capitalize(), '')
|
||||||
return value
|
return value
|
||||||
|
|
||||||
|
|
||||||
def search(item, texto):
|
def get_lang(value):
|
||||||
support.info(texto)
|
title = value.split('(')[0] if value else ''
|
||||||
item.url = host + '/api/anime/advanced-similar-search'
|
scrapedlang = scrapertools.find_single_match(value, r'\(([^\)]+)')
|
||||||
item.variable = '&query=' + texto
|
lang = scrapedlang.upper() if scrapedlang else 'Sub-ITA'
|
||||||
|
return title, lang
|
||||||
try:
|
|
||||||
return peliculas(item)
|
|
||||||
# Continua la ricerca in caso di errore
|
|
||||||
except:
|
|
||||||
import sys
|
|
||||||
for line in sys.exc_info():
|
|
||||||
support.logger.error("%s" % line)
|
|
||||||
return []
|
|
||||||
|
|
||||||
def peliculas(item):
|
|
||||||
itemlist = []
|
|
||||||
page = item.page if item.page else 0
|
|
||||||
js = httptools.downloadpage('{}?page={}&size=36{}&sort=title,asc&sort=id'.format(item.url, page, item.variable)).json
|
|
||||||
for it in js:
|
|
||||||
title = it['title'].split('(')[0].strip()
|
|
||||||
scrapedlang = scrapertools.find_single_match(it['title'], r'\(([^\)]+)')
|
|
||||||
lang = scrapedlang.upper() if scrapedlang else 'Sub-ITA'
|
|
||||||
long_title = support.typo(title, 'bold') + support.typo(lang, '_ [] color kod')
|
|
||||||
itemlist.append(item.clone(title = long_title,
|
|
||||||
fulltitle = title,
|
|
||||||
show = title,
|
|
||||||
contentLanguage = lang,
|
|
||||||
contentType = 'tvshow' if it['type'] == 'Serie' else 'movie',
|
|
||||||
contentTitle = title,
|
|
||||||
contentSerieName = title if it['type'] == 'Serie' else '',
|
|
||||||
action = 'episodios' if it['type'] == 'Serie' else 'findvideos',
|
|
||||||
plot = it['storyline'],
|
|
||||||
year = it['startDate'].split('-')[0],
|
|
||||||
id= it['id']
|
|
||||||
))
|
|
||||||
tmdb.set_infoLabels_itemlist(itemlist, seekTmdb=True)
|
|
||||||
support.nextPage(itemlist, item.clone(page = page + 1))
|
|
||||||
return itemlist
|
|
||||||
|
|
||||||
def episodios(item):
|
|
||||||
support.info(item)
|
|
||||||
|
|
||||||
# support.dbg()
|
|
||||||
|
|
||||||
url = '{}/api/anime/{}'.format(host, item.id)
|
|
||||||
|
|
||||||
json = httptools.downloadpage(url, CF=False ).json
|
|
||||||
# json = jsontools.load( jsonDataStr )
|
|
||||||
|
|
||||||
itemlist = []
|
|
||||||
|
|
||||||
if 'seasons' in json and len(json['seasons']) > 0:
|
|
||||||
seasons = json['seasons']
|
|
||||||
|
|
||||||
seasons.sort(key=lambda s: s['episodeStart'])
|
|
||||||
|
|
||||||
for i, it in enumerate(seasons):
|
|
||||||
title = it['name'] # .split('(')[0].strip()
|
|
||||||
|
|
||||||
itemlist.append(
|
|
||||||
item.clone(title = title,
|
|
||||||
id= '{}/season/{}'.format(it['animeId'], it['id']),
|
|
||||||
contentType = 'season',
|
|
||||||
contentSeason = i,
|
|
||||||
action = 'episodios',
|
|
||||||
plot = json['storyline'],
|
|
||||||
year = it['yearStart']
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
elif ('episodes' in json and len(json['episodes']) > 0) or len(json) > 0:
|
|
||||||
episodes = json['episodes'] if 'episodes' in json else json
|
|
||||||
|
|
||||||
episodes.sort(key=lambda ep: int(ep['episodeNumber']))
|
|
||||||
|
|
||||||
itemlist = build_itemlist_by_episodes(episodes, item)
|
|
||||||
|
|
||||||
# tmdb.set_infoLabels_itemlist(itemlist, seekTmdb=True)
|
|
||||||
|
|
||||||
return itemlist
|
|
||||||
|
|
||||||
def build_itemlist_by_episodes(episodes, item):
|
|
||||||
itemlist = []
|
|
||||||
# support.dbg()
|
|
||||||
for it in episodes:
|
|
||||||
title = it['title'] # .split('(')[0].strip()
|
|
||||||
|
|
||||||
itemlist.append(
|
|
||||||
item.clone(title = '{}x{:02d}. {}'.format(item.contentSeason if item.contentSeason else 1, int(it['episodeNumber']), title),
|
|
||||||
id= it['id'],
|
|
||||||
url= 'api/episode/{}'.format(it['id']),
|
|
||||||
contentType = 'episode',
|
|
||||||
contentEpisodeNumber = int(it['episodeNumber']),
|
|
||||||
contentSeason = item.contentSeason if item.contentSeason else 1,
|
|
||||||
action = 'findvideos',
|
|
||||||
year = it['airingDate'].split('-')[0]
|
|
||||||
)
|
|
||||||
)
|
|
||||||
return itemlist
|
|
||||||
|
|
||||||
def findvideos(item):
|
|
||||||
support.info()
|
|
||||||
|
|
||||||
url = '{}/api/{}/{}'.format(host, 'episode' if item.contentType == 'episode' else 'anime', item.id)
|
|
||||||
|
|
||||||
json = httptools.downloadpage(url, CF=False ).json
|
|
||||||
|
|
||||||
if json.get('episodes', []):
|
|
||||||
json = httptools.downloadpage('{}/api/episode/{}'.format(host, json['episodes'][0]['id'])).json
|
|
||||||
|
|
||||||
videourl = json['episodeVideo']
|
|
||||||
|
|
||||||
itemlist = [
|
|
||||||
item.clone(
|
|
||||||
title=config.get_localized_string(30137),
|
|
||||||
url=videourl,
|
|
||||||
server='directo'
|
|
||||||
)
|
|
||||||
]
|
|
||||||
return support.server(item, itemlist=itemlist)
|
|
||||||
Reference in New Issue
Block a user