diff --git a/channels/paramount.py b/channels/paramount.py index 0e4c8684..6a91cf5d 100644 --- a/channels/paramount.py +++ b/channels/paramount.py @@ -171,6 +171,6 @@ def findvideos(item): for quality, url in video_urls: if quality not in qualities: qualities.append(quality) - itemlist.append(item.clone(title=support.config.get_localized_string(30137), server='directo', action='play', url=url, quality=quality)) + itemlist.append(item.clone(title=support.config.get_localized_string(30137), server='directo', action='play', url=url, quality=quality, focusOnVideoPlayer=True)) itemlist.sort(key=lambda item: item.quality) return support.server(item, itemlist=itemlist, Download=False) diff --git a/channels/toonitalia.py b/channels/toonitalia.py index ea7876eb..e6362337 100644 --- a/channels/toonitalia.py +++ b/channels/toonitalia.py @@ -30,7 +30,7 @@ def search(item, texto): support.info(texto) item.args='search' item.contentType='tvshow' - item.url = host + '/?s=' + texto + item.url = host + '/wp-json/wp/v2/search?search=' + texto try: return peliculas(item) # Continua la ricerca in caso di errore @@ -45,7 +45,7 @@ def newest(categoria): support.info(categoria) item = support.Item() try: - item.contentType = 'tvshow' + item.contentType = 'undefined' item.url= host item.args= 'new' return peliculas(item) @@ -61,20 +61,16 @@ def newest(categoria): def peliculas(item): pagination = '' anime = True - # debug = True + action = 'findvideos' if item.contentType == 'movie' else 'episodios' blacklist = ['-Film Animazione disponibili in attesa di recensione '] if item.args == 'search': - patron = r'

(?P[^<]+)</a>.*?<p>(?P<plot>[^<]+)</p>.*?<span class="cat-links">Pubblicato in.*?.*?(?P<type>(?:[Ff]ilm|</artic))[^>]+>' - typeContentDict={'movie':['film']} - typeActionDict={'findvideos':['film']} - patronNext = r'<a href="([^"]+)"\s*>Articoli meno recenti' + action = 'check' + data = support.match(item).data.replace('\\','') + patron = r'"title":"(?P<title>[^"]+)","url":"(?P<url>[^"]+)' elif item.args == 'last': patronBlock = 'Aggiornamenti</h2>(?P<block>.*)</ul>' patron = r'<a href="(?P<url>[^"]+)">\s*<img[^>]+src(?:set)?="(?P<thumbnail>[^ ]+)[^>]+>\s*<span[^>]+>(?P<title>[^<]+)' - # elif item.args == 'most_view': - # patronBlock = 'I piu visti</h2>(?P<block>.*)</ul>' - # patron = r'<a href="(?P<url>[^"]+)" title="(?P<title>[^"]+)"' elif item.args == 'new': patronBlock = '<main[^>]+>(?P<block>.*)</main>' patron = r'<a href="(?P<url>[^"]+)" rel="bookmark">(?P<title>[^<]+)</a>[^>]+>[^>]+>[^>]+><img.*?src="(?P<thumb>[^"]+)".*?<p>(?P<plot>[^<]+)</p>.*?<span class="cat-links">Pubblicato in.*?.*?(?P<type>(?:[Ff]ilm|</artic))[^>]+>' @@ -94,16 +90,19 @@ def peliculas(item): item.title = item.title.replace('[ITA]','[Sub-ITA]') item.contentLanguage = 'Sub-ITA' return item - - action = 'findvideos' if item.contentType == 'movie' else 'episodios' - return locals() +def check(item): + if support.match(item, headers=headers, patron=r'(category tag">Film)').match: + item.contentType = 'movie' + return findvideos(item) + else: + item.contentType = 'tvshow' + return episodios(item) @support.scrape def episodios(item): anime = True - # debug=True data = support.match(item, headers=headers).data if 'https://vcrypt.net' in data: patron = r'(?: /> |<p>)(?P<episode>\d+.\d+)?(?: – )?(?P<title>[^<]+)<a (?P<url>.*?)(?:<br|</p)' diff --git a/platformcode/backup.py b/platformcode/backup.py index c6405d45..baf4eea2 100644 --- a/platformcode/backup.py +++ b/platformcode/backup.py @@ -3,16 +3,18 @@ # Backup and restore video library # ------------------------------------------------------------ -import datetime, xbmc +import datetime, xbmc, os, shutil -from core import ziptools, videolibrarytools, filetools +from zipfile import ZipFile +from core import videolibrarytools, filetools from platformcode import logger, config, platformtools, xbmc_videolibrary from distutils.dir_util import copy_tree from specials import videolibrary temp_path = u'' + xbmc.translatePath("special://userdata/addon_data/plugin.video.kod/temp/") -movies_path = u'' + filetools.join(temp_path, "movies") -tvshows_path = u'' + filetools.join(temp_path, "tvshows") +videolibrary_temp_path = u'' + xbmc.translatePath("special://userdata/addon_data/plugin.video.kod/temp/videolibrary") +movies_path = u'' + filetools.join(videolibrary_temp_path, "movies") +tvshows_path = u'' + filetools.join(videolibrary_temp_path, "tvshows") videolibrary_movies_path = u'' + videolibrarytools.MOVIES_PATH videolibrary_tvshows_path = u'' + videolibrarytools.TVSHOWS_PATH @@ -26,11 +28,11 @@ def export_videolibrary(item): zip_file = u'' + xbmc.translatePath(zip_file_folder + "KoD_video_library-" + str(datetime.date.today()) + ".zip") p_dialog = platformtools.dialog_progress_bg(config.get_localized_string(20000), config.get_localized_string(80003)) - p_dialog.update(0) + # p_dialog.update(0) - if filetools.exists(temp_path): - filetools.rmdirtree(temp_path) - filetools.mkdir(temp_path) + if filetools.exists(videolibrary_temp_path): + shutil.rmtree(videolibrary_temp_path) + filetools.mkdir(videolibrary_temp_path) p_dialog.update(25) filetools.mkdir(movies_path) copy_tree(videolibrary_movies_path, movies_path) @@ -39,10 +41,8 @@ def export_videolibrary(item): copy_tree(videolibrary_tvshows_path, tvshows_path) p_dialog.update(75) - zipper = ziptools.ziptools() - zipper.zip(temp_path, zip_file) - - filetools.rmdirtree(temp_path) + zip(videolibrary_temp_path, zip_file) + shutil.rmtree(temp_path) p_dialog.update(100) xbmc.sleep(1000) @@ -60,21 +60,20 @@ def import_videolibrary(item): return p_dialog = platformtools.dialog_progress_bg(config.get_localized_string(20000), config.get_localized_string(80007)) - p_dialog.update(0) + # p_dialog.update(0) if filetools.exists(temp_path): - filetools.rmdirtree(temp_path) - filetools.mkdir(temp_path) + shutil.rmtree(temp_path) + filetools.mkdir(videolibrary_temp_path) - unzipper = ziptools.ziptools() - unzipper.extract(zip_file, temp_path) + unzip(videolibrary_temp_path, zip_file) p_dialog.update(20) if config.is_xbmc() and config.get_setting("videolibrary_kodi"): xbmc_videolibrary.clean() p_dialog.update(30) - filetools.rmdirtree(videolibrary_movies_path) - filetools.rmdirtree(videolibrary_tvshows_path) + shutil.rmtree(videolibrary_movies_path) + shutil.rmtree(videolibrary_tvshows_path) p_dialog.update(50) config.verify_directories_created() @@ -84,7 +83,7 @@ def import_videolibrary(item): if filetools.exists(tvshows_path): copy_tree(tvshows_path, videolibrary_tvshows_path) p_dialog.update(90) - filetools.rmdirtree(temp_path) + shutil.rmtree(temp_path) p_dialog.update(100) xbmc.sleep(1000) @@ -93,4 +92,31 @@ def import_videolibrary(item): videolibrary.update_videolibrary() if config.is_xbmc() and config.get_setting("videolibrary_kodi"): - xbmc_videolibrary.update() \ No newline at end of file + xbmc_videolibrary.update() + + +def zip(dir, file): + smb = False + if file.lower().startswith('smb://'): + temp = file + file = filetools.join(temp_path, os.path.split(file)[-1]) + smb = True + with ZipFile(file, "w") as zf: + abs_src = os.path.abspath(dir) + for dirname, subdirs, files in os.walk(dir): + for filename in files: + absname = os.path.abspath(os.path.join(dirname, filename)) + arcname = absname[len(abs_src) + 1:] + zf.write(absname, arcname) + zf.close() + if smb: + filetools.move(file, temp) + +def unzip(dir, file): + if file.lower().startswith('smb://'): + temp = filetools.join(temp_path, os.path.split(file)[-1]) + filetools.copy(file, temp) + file = temp + + with ZipFile(file, 'r') as zf: + zf.extractall(dir) \ No newline at end of file diff --git a/platformcode/infoplus.py b/platformcode/infoplus.py index ee38c076..4d8aaca8 100644 --- a/platformcode/infoplus.py +++ b/platformcode/infoplus.py @@ -32,6 +32,7 @@ NEXT = 30009 PREVIOUS = 30010 LOADING = 30011 COMMANDS = 30012 +IMAGES = 30013 RECOMANDED = TRAILERS = 30500 ACTORS = 30501 CAST = 30502 @@ -67,6 +68,7 @@ class MainWindow(xbmcgui.WindowXMLDialog): self.cast = [] self.actors = [] self.ids = {} + self.tmdb = [] def onInit(self): #### Compatibility with Kodi 18 #### @@ -91,9 +93,9 @@ class MainWindow(xbmcgui.WindowXMLDialog): def onClick(self, control_id): setFocus(self) + title = self.getControl(RECOMANDED).getSelectedItem().getProperty('title') + mode = self.getControl(RECOMANDED).getSelectedItem().getProperty('mediatype') if control_id in [SEARCH]: - title = self.getControl(RECOMANDED).getSelectedItem().getProperty('title') - mode = self.getControl(RECOMANDED).getSelectedItem().getProperty('mediatype') self.close() if self.getControl(RECOMANDED).getSelectedPosition() > 0: Search(ITEM.clone(action='search', search_text=title)) @@ -103,6 +105,12 @@ class MainWindow(xbmcgui.WindowXMLDialog): info = self.getControl(RECOMANDED).getSelectedItem() self.close() Trailer(info) + elif control_id in [IMAGES]: + info = self.getControl(RECOMANDED).getSelectedItem() + images = tmdb.Tmdb(id_Tmdb=info.getProperty('tmdb_id'), tipo='movie' if mode == 'movie' else 'tv').result.get("images", {}) + for key, value in list(images.items()): + if not value: images.pop(key) + ImagesWindow(tmdb = images).doModal() elif control_id in [ACTORS, CAST]: self.close() Main(self.getControl(self.getFocusId()).getSelectedItem()) @@ -346,7 +354,7 @@ class TrailerWindow(xbmcgui.WindowXMLDialog): elif action in [EXIT]: self.close() -class images(xbmcgui.WindowDialog): +class ImagesWindow(xbmcgui.WindowDialog): def __init__(self, *args, **kwargs): self.tmdb = kwargs.get("tmdb", {}) self.imdb = kwargs.get("imdb", {}) @@ -371,47 +379,61 @@ class images(xbmcgui.WindowDialog): self.main_image = xbmcgui.ControlImage(0, 0, 1280, 720, main_image, 2) self.addControl(self.main_image) + if self.image_list: + self.counter = xbmcgui.ControlTextBox(1180, 640, 60, 40, 'font30_title') + self.addControl(self.counter) + self.counter.setText('%s/%s' % (1,len(self.image_list))) + else: + self.text = xbmcgui.ControlLabel(0, 0, 1280, 720, 'NESSUNA IMMAGINE', 'font30_title', alignment=2|4) + self.addControl(self.text) + self.close_btn = xbmcgui.ControlButton(0, 0, 1280, 720, '' ,'', '') self.addControl(self.close_btn) - # BUTTON LEFT - self.btn_left = xbmcgui.ControlButton(0, 330, 60, 60, '', imagepath('previous_focus'), imagepath('previous_nofocus')) - self.addControl(self.btn_left) - self.btn_left.setAnimations([('WindowOpen', 'effect=slide start=-60,0 end=0,0 delay=100 time=200'),('WindowClose', 'effect=slide start=0,0 end=-60,0 delay=100 time=200')]) + if len(self.image_list) > 1: + # BUTTON LEFT + self.btn_left = xbmcgui.ControlButton(0, 330, 60, 60, '', imagepath('previous_focus'), imagepath('previous_nofocus')) + self.addControl(self.btn_left) + self.btn_left.setAnimations([('WindowOpen', 'effect=slide start=-60,0 end=0,0 delay=100 time=200'),('WindowClose', 'effect=slide start=0,0 end=-60,0 delay=100 time=200')]) - # BUTTON RIGHT - self.btn_right = xbmcgui.ControlButton(1220, 330, 60, 60, '', imagepath('next_focus'), imagepath('next_nofocus')) - self.addControl(self.btn_right) - self.btn_right.setAnimations([('WindowOpen', 'effect=slide start=60,0 end=0,0 delay=100 time=200'),('WindowClose', 'effect=slide start=0,0 end=60,0 delay=100 time=200')]) + # BUTTON RIGHT + self.btn_right = xbmcgui.ControlButton(1220, 330, 60, 60, '', imagepath('next_focus'), imagepath('next_nofocus')) + self.addControl(self.btn_right) + self.btn_right.setAnimations([('WindowOpen', 'effect=slide start=60,0 end=0,0 delay=100 time=200'),('WindowClose', 'effect=slide start=0,0 end=60,0 delay=100 time=200')]) - self.count = 0 + self.count = 0 def onAction(self, action): if action in [BACKSPACE, EXIT]: self.close() + if len(self.image_list) > 1: + if action in [RIGHT, DOWN]: + self.count += 1 + if self.count > len(self.image_list) -1: self.count = 0 + self.main_image.setImage(self.image_list[self.count]) + self.counter.setText('%s/%s' % (self.count,len(self.image_list))) - if action in [RIGHT, DOWN]: - self.count += 1 - if self.count > len(self.image_list) -1: self.count = 0 - self.main_image.setImage(self.image_list[self.count]) - - if action in [LEFT, UP]: - self.count -= 1 - if self.count < 0: self.count = len(self.image_list) -1 - self.main_image.setImage(self.image_list[self.count]) + if action in [LEFT, UP]: + self.count -= 1 + if self.count < 0: self.count = len(self.image_list) -1 + self.main_image.setImage(self.image_list[self.count]) + self.counter.setText('%s/%s' % (self.count,len(self.image_list))) def onControl(self, control): - if control.getId() == self.btn_right.getId(): - self.count += 1 - if self.count > len(self.image_list) -1: self.count = 0 - self.main_image.setImage(self.image_list[self.count]) + if len(self.image_list) > 1: + if control.getId() == self.btn_right.getId(): + self.count += 1 + if self.count > len(self.image_list) -1: self.count = 0 + self.main_image.setImage(self.image_list[self.count]) - elif control.getId() == self.btn_left.getId(): - self.count -= 1 - if self.count < 0: self.count = len(self.image_list) -1 - self.main_image.setImage(self.image_list[self.count]) + elif control.getId() == self.btn_left.getId(): + self.count -= 1 + if self.count < 0: self.count = len(self.image_list) -1 + self.main_image.setImage(self.image_list[self.count]) + else: + self.close() else: self.close() diff --git a/platformcode/launcher.py b/platformcode/launcher.py index 8bfcc231..9eb64d2c 100644 --- a/platformcode/launcher.py +++ b/platformcode/launcher.py @@ -125,6 +125,10 @@ def run(item=None): from platformcode import infoplus return infoplus.Main(item) + elif item.channel == "backup": + from platformcode import backup + return getattr(backup, item.action)(item) + elif item.channel == "shortcuts": from platformcode import shortcuts return getattr(shortcuts, item.action)(item) diff --git a/platformcode/platformtools.py b/platformcode/platformtools.py index 609d2615..a1a9ac23 100644 --- a/platformcode/platformtools.py +++ b/platformcode/platformtools.py @@ -945,6 +945,13 @@ def set_player(item, xlistitem, mediaurl, view, strm, nfo_path=None, head_nfo=No from platformcode import xbmc_videolibrary xbmc_videolibrary.mark_auto_as_watched(item, nfo_path, head_nfo, item_nfo) + # for cases where the audio playback window appears in place of the video one + if item.focusOnVideoPlayer: + while is_playing and xbmcgui.getCurrentWindowId() != 12006: + continue + xbmc.sleep(500) + xbmcgui.Window(12005).show() + def torrent_client_installed(show_tuple=False): # External plugins found in servers / torrent.json node clients diff --git a/platformcode/xbmc_videolibrary.py b/platformcode/xbmc_videolibrary.py index fb6ea365..ea0c7745 100644 --- a/platformcode/xbmc_videolibrary.py +++ b/platformcode/xbmc_videolibrary.py @@ -44,7 +44,7 @@ def mark_auto_as_watched(item, nfo_path=None, head_nfo=None, item_nfo=None): while platformtools.is_playing(): actual_time = xbmc.Player().getTime() total_time = xbmc.Player().getTotalTime() - if item_nfo.played_time and item_nfo.played_time > actual_time > 1: + if item_nfo.played_time and xbmcgui.getCurrentWindowId() == 12005: xbmc.Player().seekTime(item_nfo.played_time) item_nfo.played_time = 0 # Fix for Slow Devices diff --git a/resources/skins/Default/720p/InfoPlus.xml b/resources/skins/Default/720p/InfoPlus.xml index 388018fe..89de92d5 100644 --- a/resources/skins/Default/720p/InfoPlus.xml +++ b/resources/skins/Default/720p/InfoPlus.xml @@ -309,8 +309,8 @@ <top>25</top> <right>25</right> <height>50</height> - <width>240</width> - <visible allowhiddenfocus="true">Control.HasFocus(30500) | Control.HasFocus(30006) | Control.HasFocus(30007) | Control.HasFocus(30008)</visible> + <width>300</width> + <visible allowhiddenfocus="true">Control.HasFocus(30500) | Control.HasFocus(30006) | Control.HasFocus(30007) | Control.HasFocus(30008) | Control.HasFocus(30013)</visible> <control type="image"> <width>50</width> <height>50</height> @@ -335,16 +335,26 @@ <texturefocus colordiffuse="FFFFFFFF">Infoplus/trailer.png</texturefocus> <ondown>30500</ondown> <onleft>30008</onleft> + <onright>30013</onright> + </control> + <control type="button" id="30013"> + <left>180</left> + <width>50</width> + <height>50</height> + <texturenofocus colordiffuse="AAFFFFFF">Infoplus/fanart.png</texturenofocus> + <texturefocus colordiffuse="FFFFFFFF">Infoplus/fanart.png</texturefocus> + <ondown>30500</ondown> + <onleft>30007</onleft> <onright>30008</onright> </control> <control type="button" id="30008"> - <left>180</left> + <left>240</left> <width>50</width> <height>50</height> <texturenofocus colordiffuse="AAFFFFFF">Infoplus/search.png</texturenofocus> <texturefocus colordiffuse="FFFFFFFF">Infoplus/search.png</texturefocus> <ondown>30500</ondown> - <onleft>30007</onleft> + <onleft>30013</onleft> <onright>30007</onright> </control> </control> diff --git a/resources/skins/Default/media/Infoplus/fanart.png b/resources/skins/Default/media/Infoplus/fanart.png new file mode 100644 index 00000000..790d1c28 Binary files /dev/null and b/resources/skins/Default/media/Infoplus/fanart.png differ diff --git a/specials/community.py b/specials/community.py index 53de1afb..b5ac7034 100644 --- a/specials/community.py +++ b/specials/community.py @@ -63,7 +63,7 @@ def show_channels(item): itemlist.append(Item(channel=item.channel, title=support.typo(channel['channel_name'],'bold'), - url=channel['url'], + url=channel['url'] if 'url' in channel else path, thumbnail=thumbnail, fanart=fanart, plot=plot, diff --git a/specials/tvmoviedb.py b/specials/tvmoviedb.py index 590c5af6..a8198422 100644 --- a/specials/tvmoviedb.py +++ b/specials/tvmoviedb.py @@ -1775,7 +1775,7 @@ def imagenes(item): itemlist.append(Item(channel=item.channel, action="", thumbnail=thumb, fanart=fanart, title=title, infoLabels=item.infoLabels)) else: - imagesWindow = infoplus.images(tmdb=value).doModal() + imagesWindow = infoplus.ImagesWindow(tmdb=value).doModal() elif key == "fanart.tv": if item.folder: @@ -1787,7 +1787,7 @@ def imagenes(item): itemlist.append(Item(channel=item.channel, action="", thumbnail=thumb, fanart=fanart, title=title, infoLabels=item.infoLabels)) else: - imagesWindow = infoplus.images(fanartv=value).doModal() + imagesWindow = infoplus.ImagesWindow(fanartv=value).doModal() # elif key == "filmaffinity" and "Filmaffinity" in item.title: # if item.folder: @@ -1808,7 +1808,7 @@ def imagenes(item): Item(channel=item.channel, action="", thumbnail=thumb, fanart=fanart, title=title, infoLabels=item.infoLabels)) else: - imagesWindow = infoplus.images(imdb=value).doModal() + imagesWindow = infoplus.ImagesWindow(imdb=value).doModal() elif key == "myanimelist" and "MyAnimeList" in item.title: if item.folder: @@ -1817,7 +1817,7 @@ def imagenes(item): Item(channel=item.channel, action="", thumbnail=imagen, fanart=imagen, title=title, infoLabels=item.infoLabels)) else: - imagesWindow = infoplus.images(mal=value).doModal() + imagesWindow = infoplus.ImagesWindow(mal=value).doModal() return itemlist