Auto-Renumeration + Test in Anime World^C

This commit is contained in:
Alhaziel
2019-04-16 12:32:03 +02:00
parent 69d4a6fd3c
commit d37babe2fe
8 changed files with 218 additions and 24 deletions

View File

@@ -4,10 +4,10 @@
# ----------------------------------------------------------
import re, urlparse
from core import httptools, scrapertoolsV2, servertools, tmdb
from core import httptools, scrapertoolsV2, servertools, tmdb, tvdb
from core.item import Item
from platformcode import logger, config
from channels import autoplay, filtertools, support
from channels import autoplay, filtertools, support, autorenumber
from channelselector import thumb
@@ -214,7 +214,8 @@ def lista_anime(item):
plot=scrapedplot,
folder=True))
tmdb.set_infoLabels_itemlist(itemlist, seekTmdb=True)
tmdb.set_infoLabels_itemlist(itemlist, seekTmdb=True)
autorenumber.renumber(itemlist)
# Next page
next_page = scrapertoolsV2.find_single_match(data, '<a class="page-link" href="([^"]+)" rel="next"')
@@ -223,10 +224,10 @@ def lista_anime(item):
itemlist.append(
Item(channel=item.channel,
action='lista_anime',
title='[B]' + config.get_localized_string(30992) + ' &raquo;[/B]',
title='[B]' + config.get_localized_string(30992) + ' >[/B]',
url=next_page,
contentType=item.contentType,
thumbnail='http://2.bp.blogspot.com/-fE9tzwmjaeQ/UcM2apxDtjI/AAAAAAAAeeg/WKSGM2TADLM/s1600/pager+old.png'))
thumbnail=thumb()))
return itemlist
@@ -310,9 +311,11 @@ def video(item):
url=scrapedurl,
fulltitle=title,
show=title,
thumbnail=scrapedthumb))
thumbnail=scrapedthumb,
context = autoplay.context))
tmdb.set_infoLabels_itemlist(itemlist, seekTmdb=True)
autorenumber.renumber(itemlist)
# Next page
next_page = scrapertoolsV2.find_single_match(data, '<a class="page-link" href=".*?page=([^"]+)" rel="next"')
@@ -321,17 +324,17 @@ def video(item):
itemlist.append(
Item(channel=item.channel,
action='video',
title='[B]' + config.get_localized_string(30992) + ' &raquo;[/B]',
title='[B]' + config.get_localized_string(30992) + ' >[/B]',
url=re.sub('&page=([^"]+)', '', item.url) + '&page=' + next_page,
contentType=item.contentType,
thumbnail='http://2.bp.blogspot.com/-fE9tzwmjaeQ/UcM2apxDtjI/AAAAAAAAeeg/WKSGM2TADLM/s1600/pager+old.png'))
thumbnail=thumb()))
return itemlist
def episodios(item):
logger.info("[animeworld.py] episodios")
itemlist = []
itemlist = []
data = httptools.downloadpage(item.url).data.replace('\n', '')
data = re.sub(r'>\s*<', '><', data)
@@ -340,7 +343,7 @@ def episodios(item):
patron = r'<li><a.*?href="([^"]+)".*?>(.*?)<\/a>'
matches = re.compile(patron, re.DOTALL).findall(block)
for scrapedurl, scrapedtitle in matches:
scrapedtitle = '[B] Episodio ' + scrapedtitle + '[/B]'
itemlist.append(
@@ -355,7 +358,10 @@ def episodios(item):
plot=item.plot,
fanart=item.thumbnail,
thumbnail=item.thumbnail))
autorenumber.renumber(itemlist, item,'bold')
# Aggiungi a Libreria
if config.get_videolibrary_support() and len(itemlist) != 0:
itemlist.append(

View File

@@ -0,0 +1,136 @@
# -*- coding: utf-8 -*-
# --------------------------------------------------------------------------------
# autorenumber - Rinomina Automaticamente gli Episodi
# --------------------------------------------------------------------------------
import os
try:
import xbmcgui
except:
xbmcgui = None
from platformcode import config
from core import jsontools, tvdb
from core.item import Item
from platformcode import platformtools
from channels.support import typo, log
TAG_TVSHOW_RENUMERATE = "TVSHOW_AUTORENUMBER"
TAG_SEASON_EPISODE = "season_episode"
__channel__ = "autorenumber"
def access():
allow = False
if config.is_xbmc():
allow = True
return allow
def context():
if access():
_context = [{"title": config.get_localized_string(70585),
"action": "config_item",
"channel": "autorenumber"}]
return _context
def config_item(item):
log(item)
tvdb.find_and_set_infoLabels(item)
data = ''
data = add_season(data)
data.append(item.infoLabels['tvdb_id'])
write_data(item.from_channel, item.show, data)
def add_season(data=None):
log("data= ", data)
heading = config.get_localized_string(70686)
season = platformtools.dialog_numeric(0, heading)
if season != "":
heading = config.get_localized_string(70687)
episode = platformtools.dialog_numeric(0, heading)
if episode != "":
return [int(season), int(episode)]
def write_data(channel, show, data):
log()
dict_series = jsontools.get_node_from_file(channel, TAG_TVSHOW_RENUMERATE)
tvshow = show.strip()
list_season_episode = dict_series.get(tvshow, {}).get(TAG_SEASON_EPISODE, [])
if data:
dict_renumerate = {TAG_SEASON_EPISODE: data}
dict_series[tvshow] = dict_renumerate
else:
dict_series.pop(tvshow, None)
result, json_data = jsontools.update_node(dict_series, channel, TAG_TVSHOW_RENUMERATE)
if result:
if data:
message = config.get_localized_string(60446)
else:
message = config.get_localized_string(60444)
else:
message = config.get_localized_string(70593)
heading = show.strip()
platformtools.dialog_notification(heading, message)
def renumber(itemlist, item='', typography=''):
log()
if item:
try:
dict_series = jsontools.get_node_from_file(item.channel, TAG_TVSHOW_RENUMERATE)
SERIES = dict_series[item.show]['season_episode']
S = SERIES[0]
E = SERIES[1]
ID = SERIES[2]
logger.info(str(S) + '|' + str(E) + '|' + ID)
page = 1
epList = []
exist = True
item.infoLabels['tvdb_id'] = ID
tvdb.set_infoLabels_item(item)
while exist:
data = tvdb.otvdb_global.get_list_episodes(ID,page)
if data:
for episodes in data['data']:
if episodes['airedSeason'] >= S:
if episodes['airedEpisodeNumber'] >= E:
epList.append(str(episodes['airedSeason']) + 'x' + str(episodes['airedEpisodeNumber']))
page = page + 1
else:
exist = False
logger.info(str(epList))
ep = 0
for item in itemlist:
item.title = typo(epList[ep] + ' - ', typography) + item.title
ep = ep + 1
except:
return itemlist
else:
for item in itemlist:
if item.contentType != 'movie':
if item.context:
context2 = item.context
item.context = context() + context2
else:
item.context = context()
return itemlist

View File

@@ -5311,8 +5311,8 @@ msgid "Do you want to update Quasar to avoid errors?"
msgstr "¿Quiere actualizar Quasar para evitar errores?"
msgctxt "#70585"
msgid "RENUMERAR"
msgstr ""
msgid "RENUMBERING"
msgstr "RENUMERAR"
msgctxt "#70586"
msgid "Set up series number..."
@@ -5720,4 +5720,16 @@ msgstr "%s se ha agregado"
msgctxt "#70684"
msgid "%s has been deleted"
msgstr "%s ha sido eliminado"
msgstr "%s ha sido eliminado"
msgctxt "#70685"
msgid "Community"
msgstr "Comunidad"
msgctxt "#70686"
msgid "Enter the number of the starting season"
msgstr "Ingrese el número de la temporada de inicio"
msgctxt "#70687"
msgid "Enter the number of the starting episode"
msgstr "Ingrese el número del episodio inicial"

View File

@@ -10428,4 +10428,12 @@ msgstr ""
msgctxt "#70685"
msgid "Community"
msgstr ""
msgctxt "#70686"
msgid "Enter the number of the starting season"
msgstr ""
msgctxt "#70687"
msgid "Enter the number of the starting episode"
msgstr ""

View File

@@ -5416,4 +5416,12 @@ msgstr "%s è stato eliminato"
msgctxt "#70685"
msgid "Community"
msgstr "Community"
msgstr "Community"
msgctxt "#70686"
msgid "Enter the number of the starting season"
msgstr "Inserisci il numero della stagione di partenza"
msgctxt "#70687"
msgid "Enter the number of the starting episode"
msgstr "Inserisci il numero dell'episodio di partenza"

View File

@@ -5024,8 +5024,8 @@ msgid "Do you want to update Quasar to avoid errors?"
msgstr "¿Quiere actualizar Quasar para evitar errores?"
msgctxt "#70585"
msgid "RENUMERAR"
msgstr ""
msgid "RENUMBERING"
msgstr "RENUMERAR"
msgctxt "#70586"
msgid "Set up series number..."
@@ -5437,4 +5437,12 @@ msgstr "%s ha sido eliminado"
msgctxt "#70685"
msgid "Community"
msgstr "Comunidad"
msgstr "Comunidad"
msgctxt "#70686"
msgid "Enter the number of the starting season"
msgstr "Ingrese el número de la temporada de inicio"
msgctxt "#70687"
msgid "Enter the number of the starting episode"
msgstr "Ingrese el número del episodio inicial"

View File

@@ -5024,8 +5024,8 @@ msgid "Do you want to update Quasar to avoid errors?"
msgstr "¿Quiere actualizar Quasar para evitar errores?"
msgctxt "#70585"
msgid "RENUMERAR"
msgstr ""
msgid "RENUMBERING"
msgstr "RENUMERAR"
msgctxt "#70586"
msgid "Set up series number..."
@@ -5437,4 +5437,12 @@ msgstr "%s ha sido eliminado"
msgctxt "#70685"
msgid "Community"
msgstr "Comunidad"
msgstr "Comunidad"
msgctxt "#70686"
msgid "Enter the number of the starting season"
msgstr "Ingrese el número de la temporada de inicio"
msgctxt "#70687"
msgid "Enter the number of the starting episode"
msgstr "Ingrese el número del episodio inicial"

View File

@@ -5024,8 +5024,8 @@ msgid "Do you want to update Quasar to avoid errors?"
msgstr "¿Quiere actualizar Quasar para evitar errores?"
msgctxt "#70585"
msgid "RENUMERAR"
msgstr ""
msgid "RENUMBERING"
msgstr "RENUMERAR"
msgctxt "#70586"
msgid "Set up series number..."
@@ -5437,4 +5437,12 @@ msgstr "%s ha sido eliminado"
msgctxt "#70685"
msgid "Community"
msgstr "Comunidad"
msgstr "Comunidad"
msgctxt "#70686"
msgid "Enter the number of the starting season"
msgstr "Ingrese el número de la temporada de inicio"
msgctxt "#70687"
msgid "Enter the number of the starting episode"
msgstr "Ingrese el número del episodio inicial"