Scrape come Classe

This commit is contained in:
Alhaziel01
2021-09-08 18:57:42 +02:00
parent 2a5a83c767
commit b84f682461
62 changed files with 1503 additions and 1397 deletions
+33 -34
View File
@@ -12,12 +12,11 @@ from past.utils import old_div
import re, time, unicodedata, xbmc
from core.support import thumb
from core.support import thumb, typo
from core import filetools, jsontools, scraper, scrapertools, servertools, videolibrarytools, support
from core.downloader import Downloader
from core.item import Item
from platformcode import config, logger, platformtools
from core.support import info, typo
from servers import torrent
kb = '0xFF65B3DA'
@@ -39,7 +38,7 @@ extensions_list = ['.aaf', '.3gp', '.asf', '.avi', '.flv', '.mpeg', '.m1v', '.m2
def mainlist(item):
info()
logger.debug()
itemlist = []
# File list
@@ -142,7 +141,7 @@ def settings(item):
def browser(item):
info()
logger.debug()
itemlist = []
for file in filetools.listdir(item.url):
@@ -176,7 +175,7 @@ def del_dir(item):
def clean_all(item):
info()
logger.debug()
stop_all()
removeFiles = False
if platformtools.dialog_yesno(config.get_localized_string(20000), config.get_localized_string(30300)):
@@ -202,7 +201,7 @@ def reload(item):
def stop_all(item=None):
info()
logger.debug()
for fichero in sorted(filetools.listdir(DOWNLOAD_LIST_PATH)):
if fichero.endswith(".json"):
@@ -220,7 +219,7 @@ def stop_all(item=None):
def clean_ready(item):
info()
logger.debug()
for fichero in sorted(filetools.listdir(DOWNLOAD_LIST_PATH)):
if fichero.endswith(".json"):
download_item = Item().fromjson(filetools.read(filetools.join(DOWNLOAD_LIST_PATH, fichero)))
@@ -232,7 +231,7 @@ def clean_ready(item):
def restart_error(item):
info()
logger.debug()
for fichero in sorted(filetools.listdir(DOWNLOAD_LIST_PATH)):
if fichero.endswith(".json"):
download_item = Item().fromjson(filetools.read(filetools.join(DOWNLOAD_LIST_PATH, fichero)))
@@ -271,7 +270,7 @@ def download_all_background(item):
def menu(item):
info(item)
logger.debug(item)
if item.downloadServer:
servidor = item.downloadServer.get("server", "Auto")
else:
@@ -367,7 +366,7 @@ def menu(item):
def move_to_libray(item):
info()
logger.debug()
if item.contentType == 'movie':
FOLDER = FOLDER_MOVIES
@@ -421,7 +420,7 @@ def move_to_libray(item):
if filename.startswith(name) and (filename.endswith('.strm') or (filename.endswith('.json') and 'downloads' not in filename)):
clean = True
file_path = filetools.join(config.get_setting("videolibrarypath"), FOLDER, path_title, File)
info('Delete File:', str(file_path))
logger.debug('Delete File:', str(file_path))
filetools.remove(file_path)
if file_path.endswith('.strm'):
file_strm_path = file_path
@@ -577,7 +576,7 @@ def sort_method(item):
def download_from_url(url, item):
info("Attempting to download:", url)
logger.debug("Attempting to download:", url)
if '.m3u8' in url.lower().split('|')[0] or url.lower().startswith("rtmp"):
save_server_statistics(item.server, 0, False)
platformtools.dialog_notification('m3u8 Download',config.get_localized_string(60364), sound=False)
@@ -606,22 +605,22 @@ def download_from_url(url, item):
update_json(item.path, {"downloadUrl": d.download_url, "downloadStatus": STATUS_CODES.downloading, "downloadSize": d.size[0],
"downloadProgress": d.progress, "downloadCompleted": d.downloaded[0], "downloadFilename": file})
d.start_dialog(config.get_localized_string(60332))
d.start_dialog(config.get_localized_string(30006))
# Download stopped. We get the state:
# Download failed
if d.state == d.states.error:
info("Error trying to download", url)
logger.debug("Error trying to download", url)
status = STATUS_CODES.error
# Download has stopped
elif d.state == d.states.stopped:
info("Stop download")
logger.debug("Stop download")
status = STATUS_CODES.canceled
# Download is complete
elif d.state == d.states.completed:
info("Downloaded correctly")
logger.debug("Downloaded correctly")
status = STATUS_CODES.completed
if (item.downloadSize and item.downloadSize != d.size[0]) or d.size[0] < 5000000: # if size don't correspond or file is too little (gounlimited for example send a little video to say the server is overloaded)
@@ -637,7 +636,7 @@ def download_from_url(url, item):
def download_from_server(item):
info(item.tostring())
logger.debug(item.tostring())
unsupported_servers = ["torrent"]
if item.contentChannel == 'local':
@@ -667,11 +666,11 @@ def download_from_server(item):
item.video_urls = itemlist
if not item.server: item.server = "directo"
else:
info("There is nothing to reproduce")
logger.debug("There is nothing to reproduce")
return {"downloadStatus": STATUS_CODES.error}
finally:
progreso.close()
info("contentAction: %s | contentChannel: %s | server: %s | url: %s" % (item.contentAction, item.contentChannel, item.server, item.url))
logger.debug("contentAction: %s | contentChannel: %s | server: %s | url: %s" % (item.contentAction, item.contentChannel, item.server, item.url))
if item.server == 'torrent':
import xbmcgui
@@ -691,11 +690,11 @@ def download_from_server(item):
# If it is not available, we go out
if not puedes:
info("The video is NOT available")
logger.debug("The video is NOT available")
return {"downloadStatus": STATUS_CODES.error}
else:
info("YES Video is available")
logger.debug("YES Video is available")
result = {}
@@ -716,14 +715,14 @@ def download_from_server(item):
def download_from_best_server(item):
info("contentAction: %s | contentChannel: %s | url: %s" % (item.contentAction, item.contentChannel, item.url))
logger.debug("contentAction: %s | contentChannel: %s | url: %s" % (item.contentAction, item.contentChannel, item.url))
result = {"downloadStatus": STATUS_CODES.error}
progreso = platformtools.dialog_progress_bg(config.get_localized_string(30101), config.get_localized_string(70179))
try:
if item.downloadItemlist:
info('using cached servers')
logger.debug('using cached servers')
play_items = [Item().fromurl(i) for i in item.downloadItemlist]
else:
if item.contentChannel in ['community', 'videolibrary']:
@@ -772,11 +771,11 @@ def download_from_best_server(item):
def select_server(item):
if item.server:
return "Auto"
info("contentAction: %s | contentChannel: %s | url: %s" % (item.contentAction, item.contentChannel, item.url))
logger.debug("contentAction: %s | contentChannel: %s | url: %s" % (item.contentAction, item.contentChannel, item.url))
progreso = platformtools.dialog_progress_bg(config.get_localized_string(30101), config.get_localized_string(70179))
try:
if item.downloadItemlist:
info('using cached servers')
logger.debug('using cached servers')
play_items = [Item().fromurl(i) for i in item.downloadItemlist]
else:
if item.contentChannel in ['community', 'videolibrary']:
@@ -818,7 +817,7 @@ def select_server(item):
def start_download(item):
info("contentAction: %s | contentChannel: %s | url: %s" % (item.contentAction, item.contentChannel, item.url))
logger.debug("contentAction: %s | contentChannel: %s | url: %s" % (item.contentAction, item.contentChannel, item.url))
# We already have a server, we just need to download
if item.contentAction == "play":
ret = download_from_server(item)
@@ -838,7 +837,7 @@ def start_download(item):
def get_episodes(item):
info("contentAction: %s | contentChannel: %s | contentType: %s" % (item.contentAction, item.contentChannel, item.contentType))
logger.debug("contentAction: %s | contentChannel: %s | contentType: %s" % (item.contentAction, item.contentChannel, item.contentType))
if 'dlseason' in item:
season = True
@@ -915,7 +914,7 @@ def get_episodes(item):
# Any other result is not worth it, we ignore it
else:
info("Omitiendo item no válido:", episode.tostring())
logger.debug("Omitiendo item no válido:", episode.tostring())
# Any other result is not worth it, we ignore it...
# itemlist = videolibrarytools.filter_list(itemlist)
@@ -924,7 +923,7 @@ def get_episodes(item):
def write_json(item):
info()
logger.debug()
channel = item.from_channel if item.from_channel else item.channel
item.action = "menu"
@@ -969,7 +968,7 @@ def save_download(item):
def save_download_background(item):
info()
logger.debug()
# Menu contextual
if item.from_action and item.from_channel:
item.channel = item.from_channel
@@ -1018,7 +1017,7 @@ def save_download_background(item):
def save_download_videolibrary(item):
info()
logger.debug()
show_disclaimer()
item.contentChannel = 'videolibrary'
item.channel = "downloads"
@@ -1027,7 +1026,7 @@ def save_download_videolibrary(item):
def save_download_video(item):
info("contentAction: %s | contentChannel: %s | contentTitle: %s" % (item.contentAction, item.contentChannel, item.contentTitle))
logger.debug("contentAction: %s | contentChannel: %s | contentTitle: %s" % (item.contentAction, item.contentChannel, item.contentTitle))
set_movie_title(item)
@@ -1042,7 +1041,7 @@ def save_download_video(item):
def save_download_movie(item):
info("contentAction: %s | contentChannel: %s | contentTitle: %s" % ( item.contentAction, item.contentChannel, item.contentTitle))
logger.debug("contentAction: %s | contentChannel: %s | contentTitle: %s" % ( item.contentAction, item.contentChannel, item.contentTitle))
progreso = platformtools.dialog_progress_bg(config.get_localized_string(30101), config.get_localized_string(70191))
@@ -1076,7 +1075,7 @@ def save_download_movie(item):
def save_download_tvshow(item):
info("contentAction: %s | contentChannel: %s | contentType: %s | contentSerieName: %s" % (item.contentAction, item.contentChannel, item.contentType, item.contentSerieName))
logger.debug("contentAction: %s | contentChannel: %s | contentType: %s | contentSerieName: %s" % (item.contentAction, item.contentChannel, item.contentType, item.contentSerieName))
progreso = platformtools.dialog_progress_bg(config.get_localized_string(30101), config.get_localized_string(70188))
try:
item.show = item.fulltitle
+1 -1
View File
@@ -166,7 +166,7 @@ class SearchWindow(xbmcgui.WindowXML):
tmdb_info = tmdb.Tmdb(searched_text=self.item.text, search_type=self.item.mode.replace('show', ''))
results = tmdb_info.results
def make(n, result):
result = tmdb_info.get_infoLabels(result, origen=result)
if self.item.mode == 'movie':
+2 -2
View File
@@ -388,7 +388,7 @@ def get_newest(channel_id, categoria):
def get_title(item):
# support.info("ITEM NEWEST ->", item)
# logger.debug("ITEM NEWEST ->", item)
# item.contentSerieName c'è anche se è un film
if item.contentSerieName and item.contentType != 'movie': # Si es una serie
title = item.contentSerieName
@@ -442,7 +442,7 @@ def no_group(list_result_canal):
global channels_id_name
for i in list_result_canal:
# support.info("NO GROUP i -> ", i)
# logger.debug("NO GROUP i -> ", i)
canale = channels_id_name[i.channel]
canale = canale # to differentiate it from the color of the other items
i.title = get_title(i) + " [" + canale + "]"
+3 -3
View File
@@ -1,13 +1,13 @@
# -*- coding: utf-8 -*-
from core import servertools
from core.support import match, info, server
from core.support import match, server
from core.item import Item
from platformcode import config, logger
def mainlist(item):
info()
logger.debug()
itemlist = []
itemlist.append(Item(channel=item.channel, action="search", title=config.get_localized_string(60089), thumbnail=item.thumbnail, args='server'))
@@ -19,7 +19,7 @@ def mainlist(item):
# When the function "search" is called, the launcher asks for a text to search for and adds it as a parameter
def search(item, text):
info(text)
logger.debug(text)
if not text.startswith("http"):
text = "http://" + text