pulizia
This commit is contained in:
@@ -50,7 +50,6 @@
|
||||
<setting id="vidolibrary_export" type="action" label="80000" action="RunPlugin(plugin://plugin.video.kod/?ew0KICAgICJhY3Rpb24iOiAiZXhwb3J0X3ZpZGVvbGlicmFyeSIsDQogICAgImNoYW5uZWwiOiAiYmFja3VwIg0KfQ==)"/>
|
||||
<setting id="vidolibrary_import" type="action" label="80001" action="RunPlugin(plugin://plugin.video.kod/?ew0KICAgICJhY3Rpb24iOiAiaW1wb3J0X3ZpZGVvbGlicmFyeSIsDQogICAgImNoYW5uZWwiOiAiYmFja3VwIg0KfQ==)"/>
|
||||
<setting id="vidolibrary_delete" type="action" label="80036" action="RunPlugin(plugin://plugin.video.kod/?ew0KICAgICJhY3Rpb24iOiAiZGVsZXRlX3ZpZGVvbGlicmFyeSIsDQogICAgImNoYW5uZWwiOiAidmlkZW9saWJyYXJ5Ig0KfQ==)"/>
|
||||
<setting id="vidolibrary_restore" type="action" label="60567" action="RunPlugin(plugin://plugin.video.kod/?ew0KICAgICJhY3Rpb24iOiAicmVzdG9yZV90b29scyIsDQogICAgImNoYW5uZWwiOiAic2V0dGluZyINCn0=)"/>
|
||||
</category>
|
||||
|
||||
<!-- Channels -->
|
||||
|
||||
143
service.py
143
service.py
@@ -1,12 +1,9 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
import datetime
|
||||
import math
|
||||
import os
|
||||
import sys
|
||||
import threading
|
||||
import traceback
|
||||
import xbmc
|
||||
import xbmcgui
|
||||
from platformcode import config
|
||||
|
||||
try:
|
||||
@@ -22,96 +19,13 @@ except:
|
||||
librerias = xbmc.translatePath(os.path.join(config.get_runtime_path(), 'lib'))
|
||||
sys.path.insert(0, librerias)
|
||||
|
||||
from core import videolibrarytools, filetools, channeltools, httptools, scrapertools, db
|
||||
from core import filetools, httptools, scrapertools, db
|
||||
from lib import schedule
|
||||
from platformcode import logger, platformtools, updater, xbmc_videolibrary
|
||||
from specials import videolibrary
|
||||
from servers import torrent
|
||||
|
||||
|
||||
def update(path, p_dialog, i, t, serie, overwrite):
|
||||
logger.debug("Updating " + path)
|
||||
insertados_total = 0
|
||||
nfo_file = xbmc.translatePath(filetools.join(path, 'tvshow.nfo'))
|
||||
|
||||
head_nfo, it = videolibrarytools.read_nfo(nfo_file)
|
||||
videolibrarytools.update_renumber_options(it, head_nfo, path)
|
||||
|
||||
if not serie.library_url: serie = it
|
||||
category = serie.category
|
||||
|
||||
# logger.debug("%s: %s" %(serie.contentSerieName,str(list_canales) ))
|
||||
for channel, url in serie.library_urls.items():
|
||||
serie.channel = channel
|
||||
module = __import__('channels.%s' % channel, fromlist=["channels.%s" % channel])
|
||||
url = module.host + urlsplit(url).path
|
||||
serie.url = url
|
||||
|
||||
###### Redirection to the NewPct1.py channel if it is a clone, or to another channel and url if there has been judicial intervention
|
||||
try:
|
||||
head_nfo, it = videolibrarytools.read_nfo(nfo_file) # Refresh the .nfo to collect updates
|
||||
if it.emergency_urls:
|
||||
serie.emergency_urls = it.emergency_urls
|
||||
serie.category = category
|
||||
except:
|
||||
logger.error(traceback.format_exc())
|
||||
|
||||
channel_enabled = channeltools.is_enabled(serie.channel)
|
||||
|
||||
if channel_enabled:
|
||||
|
||||
heading = config.get_localized_string(20000)
|
||||
p_dialog.update(int(math.ceil((i + 1) * t)), heading, config.get_localized_string(60389) % (serie.contentSerieName, serie.channel.capitalize()))
|
||||
try:
|
||||
pathchannels = filetools.join(config.get_runtime_path(), "channels", serie.channel + '.py')
|
||||
logger.debug("loading channel: " + pathchannels + " " + serie.channel)
|
||||
|
||||
if serie.library_filter_show:
|
||||
serie.show = serie.library_filter_show.get(serie.channel, serie.contentSerieName)
|
||||
|
||||
obj = __import__('channels.%s' % serie.channel, fromlist=[pathchannels])
|
||||
|
||||
itemlist = obj.episodios(serie)
|
||||
|
||||
try:
|
||||
if int(overwrite) == 3:
|
||||
# Overwrite all files (tvshow.nfo, 1x01.nfo, 1x01 [channel] .json, 1x01.strm, etc ...)
|
||||
insertados, sobreescritos, fallidos, notusedpath = videolibrarytools.save_tvshow(serie, itemlist)
|
||||
#serie= videolibrary.check_season_playcount(serie, serie.contentSeason)
|
||||
#if filetools.write(path + '/tvshow.nfo', head_nfo + it.tojson()):
|
||||
# serie.infoLabels['playcount'] = serie.playcount
|
||||
else:
|
||||
insertados, sobreescritos, fallidos = videolibrarytools.save_episodes(path, itemlist, serie,
|
||||
silent=True,
|
||||
overwrite=overwrite)
|
||||
#it = videolibrary.check_season_playcount(it, it.contentSeason)
|
||||
#if filetools.write(path + '/tvshow.nfo', head_nfo + it.tojson()):
|
||||
# serie.infoLabels['playcount'] = serie.playcount
|
||||
insertados_total += insertados
|
||||
|
||||
except:
|
||||
import traceback
|
||||
logger.error("Error when saving the chapters of the series")
|
||||
logger.error(traceback.format_exc())
|
||||
|
||||
except:
|
||||
import traceback
|
||||
logger.error("Error in obtaining the episodes of: %s" % serie.show)
|
||||
logger.error(traceback.format_exc())
|
||||
|
||||
else:
|
||||
logger.debug("Channel %s not active is not updated" % serie.channel)
|
||||
# Synchronize the episodes seen from the Kodi video library with that of KoD
|
||||
try:
|
||||
if config.is_xbmc(): # If it's Kodi, we do it
|
||||
from platformcode import xbmc_videolibrary
|
||||
xbmc_videolibrary.mark_content_as_watched_on_kod(filetools.join(path,'tvshow.nfo'))
|
||||
except:
|
||||
logger.error(traceback.format_exc())
|
||||
|
||||
return insertados_total > 0
|
||||
|
||||
|
||||
def check_for_update():
|
||||
if config.get_setting("update", "videolibrary"):
|
||||
videolibrary.update_videolibrary()
|
||||
@@ -122,6 +36,7 @@ def updaterCheck():
|
||||
updated, needsReload = updater.check(background=True)
|
||||
if needsReload:
|
||||
xbmc.executescript(__file__)
|
||||
db.close()
|
||||
exit(0)
|
||||
|
||||
|
||||
@@ -277,60 +192,6 @@ if __name__ == "__main__":
|
||||
if config.get_setting('autostart'):
|
||||
xbmc.executebuiltin('RunAddon(plugin.video.' + config.PLUGIN_NAME + ')')
|
||||
|
||||
# port old db to new
|
||||
old_db_name = filetools.join(config.get_data_path(), "kod_db.sqlite")
|
||||
if filetools.isfile(old_db_name):
|
||||
try:
|
||||
import sqlite3
|
||||
|
||||
old_db_conn = sqlite3.connect(old_db_name, timeout=15)
|
||||
old_db = old_db_conn.cursor()
|
||||
old_db.execute('select * from viewed')
|
||||
|
||||
for ris in old_db.fetchall():
|
||||
if ris[1]: # tvshow
|
||||
show = db['viewed'].get(ris[0], {})
|
||||
show[str(ris[1]) + 'x' + str(ris[2])] = ris[3]
|
||||
db['viewed'][ris[0]] = show
|
||||
else: # film
|
||||
db['viewed'][ris[0]] = ris[3]
|
||||
except:
|
||||
pass
|
||||
finally:
|
||||
filetools.remove(old_db_name, True, False)
|
||||
|
||||
# replace tvdb to tmdb for series
|
||||
if config.get_setting('videolibrary_kodi') and config.get_setting('show_once'):
|
||||
nun_records, records = xbmc_videolibrary.execute_sql_kodi('select * from path where strPath like "' +
|
||||
filetools.join(config.get_setting('videolibrarypath'), config.get_setting('folder_tvshows')) +
|
||||
'%" and strScraper="metadata.tvdb.com"')
|
||||
if nun_records:
|
||||
import xbmcaddon
|
||||
# change language
|
||||
tvdbLang = xbmcaddon.Addon(id="metadata.tvdb.com").getSetting('language')
|
||||
newLang = tvdbLang + '-' + tvdbLang.upper()
|
||||
xbmcaddon.Addon(id="metadata.tvshows.themoviedb.org").setSetting('language', newLang)
|
||||
updater.refreshLang()
|
||||
|
||||
# prepare to replace strSettings
|
||||
path_settings = xbmc.translatePath(
|
||||
"special://profile/addon_data/metadata.tvshows.themoviedb.org/settings.xml")
|
||||
settings_data = filetools.read(path_settings)
|
||||
strSettings = ' '.join(settings_data.split()).replace("> <", "><")
|
||||
strSettings = strSettings.replace("\"", "\'")
|
||||
|
||||
# update db
|
||||
nun_records, records = xbmc_videolibrary.execute_sql_kodi(
|
||||
'update path set strScraper="metadata.tvshows.themoviedb.org", strSettings="' + strSettings + '" where strPath like "' +
|
||||
filetools.join(config.get_setting('videolibrarypath'), config.get_setting('folder_tvshows')) +
|
||||
'%" and strScraper="metadata.tvdb.com"')
|
||||
|
||||
# scan new info
|
||||
xbmc.executebuiltin('UpdateLibrary(video)')
|
||||
xbmc.executebuiltin('CleanLibrary(video)')
|
||||
while xbmc.getCondVisibility('Library.IsScanningVideo()'):
|
||||
xbmc.sleep(1000)
|
||||
|
||||
# check if the user has any connection problems
|
||||
from platformcode.checkhost import test_conn
|
||||
run_threaded(test_conn, (True, not config.get_setting('resolver_dns'), True, [], [], True))
|
||||
|
||||
@@ -708,83 +708,6 @@ def channel_status(item, dict_values):
|
||||
platformtools.dialog_notification(config.get_localized_string(60579), config.get_localized_string(60580))
|
||||
|
||||
|
||||
def restore_tools(item):
|
||||
import service
|
||||
from core import videolibrarytools
|
||||
import os
|
||||
|
||||
seleccion = platformtools.dialog_yesno(config.get_localized_string(60581),
|
||||
config.get_localized_string(60582) + '\n' +
|
||||
config.get_localized_string(60583))
|
||||
if seleccion == 1:
|
||||
# tvshows
|
||||
heading = config.get_localized_string(60584)
|
||||
p_dialog = platformtools.dialog_progress_bg(config.get_localized_string(60585), heading)
|
||||
p_dialog.update(0, '')
|
||||
|
||||
show_list = []
|
||||
for path, folders, files in filetools.walk(videolibrarytools.TVSHOWS_PATH):
|
||||
show_list.extend([filetools.join(path, f) for f in files if f == "tvshow.nfo"])
|
||||
|
||||
if show_list:
|
||||
t = float(100) / len(show_list)
|
||||
|
||||
for i, tvshow_file in enumerate(show_list):
|
||||
head_nfo, serie = videolibrarytools.read_nfo(tvshow_file)
|
||||
path = filetools.dirname(tvshow_file)
|
||||
|
||||
if not serie.active:
|
||||
# if the series is not active discard
|
||||
continue
|
||||
|
||||
# We delete the folder with the series ...
|
||||
if tvshow_file.endswith('.strm') or tvshow_file.endswith('.json') or tvshow_file.endswith('.nfo'):
|
||||
os.remove(os.path.join(path, tvshow_file))
|
||||
# filetools.rmdirtree(path)
|
||||
|
||||
# ... and we add it again
|
||||
service.update(path, p_dialog, i, t, serie, 3)
|
||||
p_dialog.close()
|
||||
|
||||
# movies
|
||||
heading = config.get_localized_string(60586)
|
||||
p_dialog2 = platformtools.dialog_progress_bg(config.get_localized_string(60585), heading)
|
||||
p_dialog2.update(0, '')
|
||||
|
||||
movies_list = []
|
||||
for path, folders, files in filetools.walk(videolibrarytools.MOVIES_PATH):
|
||||
movies_list.extend([filetools.join(path, f) for f in files if f.endswith(".json")])
|
||||
|
||||
logger.debug("movies_list %s" % movies_list)
|
||||
|
||||
if movies_list:
|
||||
t = float(100) / len(movies_list)
|
||||
|
||||
for i, movie_json in enumerate(movies_list):
|
||||
try:
|
||||
from core import jsontools
|
||||
path = filetools.dirname(movie_json)
|
||||
movie = Item().fromjson(filetools.read(movie_json))
|
||||
|
||||
# We delete the folder with the movie ...
|
||||
filetools.rmdirtree(path)
|
||||
|
||||
import math
|
||||
heading = config.get_localized_string(20000)
|
||||
|
||||
p_dialog2.update(int(math.ceil((i + 1) * t)), heading, config.get_localized_string(60389) % (movie.contentTitle,
|
||||
movie.channel.capitalize()))
|
||||
# ... and we add it again
|
||||
videolibrarytools.save_movie(movie)
|
||||
except Exception as ex:
|
||||
logger.error("Error creating movie again")
|
||||
template = "An exception of type %s occured. Arguments:\n%r"
|
||||
message = template % (type(ex).__name__, ex.args)
|
||||
logger.error(message)
|
||||
|
||||
p_dialog2.close()
|
||||
|
||||
|
||||
def report_menu(item):
|
||||
logger.debug('URL: ' + item.url)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user