Recupero url su community channel + varie (#329)

* Aggiunto recupero da url + varie

* Autoplay da community channel

* small fix

* cambiato patter server "directo" per escludere gli spazi vuoti e trovare url di file m3u8, mp4, mpeg, mpd, flv m3u
Aggiunta funzionalità sul canale community per filtrare i risultati trovati tramite patterns

* fix consigliati

* fix se l'url inserito è un server conosciuto da kod

* creata chiave apposita "find_links" per differenziare il funzionamento standard aggiunto il controllo sugli short link (per poterli utilizzare nel canale), aggiunto is.gd come servizio di short link su unshortenit

Co-authored-by: Alex Pettiti <alex.pettiti@axterisko.it>
Co-authored-by: mac12m99 <10120390+mac12m99@users.noreply.github.com>
This commit is contained in:
4l3x87
2021-08-26 18:19:35 +02:00
committed by GitHub
parent 48eac3643b
commit 4f83b6f8be
4 changed files with 215 additions and 157 deletions
+1 -1
View File
@@ -39,7 +39,7 @@ def start(itemlist, item):
if not config.is_xbmc():
return itemlist
if config.get_setting('autoplay'):
if config.get_setting('autoplay') or (item.channel == 'community' and item.autoplay):
# Save the current value of "Action and Player Mode" in preferences
user_config_setting_action = config.get_setting("default_action")
# user_config_setting_player = config.get_setting("player_mode")
+1 -1
View File
@@ -45,7 +45,7 @@ class UnshortenIt(object):
# for services that only include real link inside iframe
_simple_iframe_regex = r'cryptmango|xshield\.net|vcrypt\.club'
# for services that only do redirects
_simple_redirect = r'streamcrypt\.net/[^/]+|uprot\.net'
_simple_redirect = r'streamcrypt\.net/[^/]+|uprot\.net|is\.gd'
listRegex = [_adfly_regex, _linkbucks_regex, _adfocus_regex, _lnxlu_regex, _shst_regex, _hrefli_regex, _anonymz_regex,
_shrink_service_regex, _rapidcrypt_regex, _simple_iframe_regex, _linkup_regex, _linkhub_regex,
+1 -6
View File
@@ -4,12 +4,7 @@
"ignore_urls": [],
"patterns": [
{
"pattern": "((?:http://|https://).*?m3u8[^\"'\n]*)",
"url": "\\1"
},
{
"pattern": "((?:http://|https://).*?.mpd[^\"'\n]*)",
"pattern": "((?:https?://).\\S+.(m3u8|mp4|mpeg|mpd|flv)[^\"'\n]*)",
"url": "\\1"
},
{
+102 -39
View File
@@ -2,17 +2,21 @@
# -*- Channel Community -*-
import re, inspect, xbmcgui
import re, inspect, mimetypes, xbmcgui
from core import httptools, jsontools, tmdb, support, filetools
from core.item import Item
from lib import unshortenit
from platformcode import config, platformtools, logger
from channelselector import get_thumb
from collections import OrderedDict
from core import servertools
info_language = ["de", "en", "es", "fr", "it", "pt"] # from videolibrary.json
try: lang = info_language[config.get_setting("info_language", "videolibrary")]
except: lang = 'it'
try:
lang = info_language[config.get_setting("info_language", "videolibrary")]
except:
lang = 'it'
defpage = ["", "20", "40", "60", "80", "100"]
defp = defpage[config.get_setting('pagination', 'community')]
@@ -21,6 +25,7 @@ show_seasons = config.get_setting('show_seasons','community')
tmdb_api = 'a1ab8b8669da03637a4b98fa39c39228'
def mainlist(item):
logger.debug()
@@ -77,7 +82,6 @@ def show_menu(item):
logger.debug()
itemlist = []
if item.menu: # if second level menu
get_sub_menu(item, item.menu, 'level2', itemlist)
else:
@@ -103,14 +107,12 @@ def show_menu(item):
itemlist += get_seasons(item)
elif key in ['episodes_list']:
itemlist += episodios(item, json, key)
elif key in ['links']:
elif key in ['links', 'find_links']:
itemlist += findvideos(item)
elif key in ['search'] and 'url' in json['search']:
search_json = json['search']
itemlist += get_search_menu(item, search_json)
if 'channel_name' in json and not 'disable_search' in json and 'search' not in json:
itemlist += get_search_menu(item, json, channel_name=json['channel_name'])
logger.debug('PAGINATION:', disable_pagination)
@@ -142,6 +144,7 @@ def search(item, text):
return itemlist
def global_search(item, text):
itemlist = []
json = load_json(item)
@@ -149,7 +152,8 @@ def global_search(item, text):
if 'menu' in json:
for option in json['menu']:
if option in ['submenu', 'level2'] and 'seach' in json['menu'][option] and 'url' in json['menu'][option]['search']:
if option in ['submenu', 'level2'] and 'seach' in json['menu'][option] and 'url' in json['menu'][option][
'search']:
item.custom_search = json['menu'][option]['search']['url']
itemlist += search(item, text)
else:
@@ -163,8 +167,6 @@ def global_search(item, text):
return itemlist
def peliculas(item, json='', key='', itemlist=[]):
item.plot = item.thumb = item.fanart = ''
logger.debug('PAGINATION:', item.disable_pagination)
@@ -174,25 +176,28 @@ def peliculas(item, json='', key='', itemlist=[]):
else:
json = json[key]
# logger.debug('DEBUG:', json)
infoLabels = item.infoLabels if item.infoLabels else {}
contentType = 'tvshow' if 'tvshow' in key else 'movie'
itlist = filterkey = []
action = 'findvideos'
if inspect.stack()[1][3] not in ['add_tvshow', 'get_episodes', 'update', 'find_episodes', 'search'] and not item.filterkey and not item.disable_pagination:
if inspect.stack()[1][3] not in ['add_tvshow', 'get_episodes', 'update', 'find_episodes',
'search'] and not item.filterkey and not item.disable_pagination:
Pagination = int(defp) if defp.isdigit() else ''
else: Pagination = ''
else:
Pagination = ''
pag = item.page if item.page else 1
for i, option in enumerate(json):
if Pagination and (pag - 1) * Pagination > i: continue # pagination
if Pagination and i >= pag * Pagination: break
if item.filterkey and item.filterkey in option:
filterkey = [it.lower() for it in option[item.filterkey]] if type(option[item.filterkey]) == list else [option[item.filterkey].lower()]
filterkey = [it.lower() for it in option[item.filterkey]] if type(option[item.filterkey]) == list else [
option[item.filterkey].lower()]
else:
filterkey = []
title = option['title'] if 'title' in option else ''
if 'tvshows_list' in key and 'links' not in option:
@@ -200,6 +205,12 @@ def peliculas(item, json='', key='', itemlist=[]):
# filter elements
if (not item.filter or item.filter.lower() in filterkey) and item.search.lower() in title.lower() and title:
if 'generic_list' in key and 'links' not in option and 'url' in option:
option['links'] = []
option['links'].append({'url': option['url']})
option['url'] = ''
extra = set_extra_values(item, option, item.path)
infoLabels['year'] = option['year'] if 'year' in option else ''
@@ -242,8 +253,10 @@ def get_seasons(item):
itemlist = []
infoLabels = item.infoLabels
json = item.url if type(item.url) == dict else item.url
if 'seasons_list' in json: json = json['seasons_list']
elif 'tvshows_list' in json: return show_menu(item)
if 'seasons_list' in json:
json = json['seasons_list']
elif 'tvshows_list' in json:
return show_menu(item)
for option in json:
infoLabels['season'] = option['season']
title = config.get_localized_string(60027) % option['season']
@@ -263,12 +276,14 @@ def get_seasons(item):
contentType='season' if show_seasons else 'tvshow',
path=extra.path))
if inspect.stack()[2][3] in ['add_tvshow', 'get_episodes', 'update', 'find_episodes', 'get_newest'] or show_seasons == False:
if inspect.stack()[2][3] in ['add_tvshow', 'get_episodes', 'update', 'find_episodes',
'get_newest'] or show_seasons == False:
itlist = []
for item in itemlist:
itlist = episodios(item)
itemlist = itlist
if inspect.stack()[2][3] not in ['add_tvshow', 'get_episodes', 'update', 'find_episodes', 'get_newest'] and defp and not item.disable_pagination:
if inspect.stack()[2][3] not in ['add_tvshow', 'get_episodes', 'update', 'find_episodes',
'get_newest'] and defp and not item.disable_pagination:
itemlist = pagination(item, itemlist)
if show_seasons:
@@ -304,9 +319,11 @@ def episodios(item, json ='', key='', itemlist =[]):
ep = 1
season = infoLabels['season'] if 'season' in infoLabels else item.contentSeason if item.contentSeason else 1
if inspect.stack()[1][3] not in ['add_tvshow', 'get_episodes', 'update', 'find_episodes', 'search'] and not show_seasons:
if inspect.stack()[1][3] not in ['add_tvshow', 'get_episodes', 'update', 'find_episodes',
'search'] and not show_seasons:
Pagination = int(defp) if defp.isdigit() else ''
else: Pagination = ''
else:
Pagination = ''
pag = item.page if item.page else 1
# make items
@@ -391,17 +408,46 @@ def episodios(item, json ='', key='', itemlist =[]):
# Find Servers
def findvideos(item):
logger.debug()
# logger.debug('DEBUG', item)
item.contentTitle = item.fulltitle
itemlist = []
json = []
if 'links' in item.url:
json = item.url['links']
elif 'find_links' in item.url:
for link in item.url['find_links']:
link['url'] = unshortenit.findlinks(link['url'])
mimetype = findS = None
mimetype = mimetypes.MimeTypes().guess_type(link['url'])[0]
if mimetype is None:
findS = servertools.get_server_from_url(link['url'])
if mimetype is None and findS is None:
data = support.match(link['url']).data
itemlist_url = servertools.find_video_items(data=data)
if len(itemlist_url):
for item_url in itemlist_url:
valid = True
patterns = link.get('patterns', False)
if patterns:
valid = False
for pattern in patterns:
match = re.search(pattern, item_url.url)
if match:
valid = True
break
if valid:
json.append({"url": item_url.url})
else:
json = item.url
json.append(link)
else:
url = item.url
item.url = {}
json.append({"url": url})
# support.dbg()
for option in json:
extra = set_extra_values(item, option, item.path)
itemlist.append(
item.clone(url=option['url'],
action='play',
@@ -409,14 +455,16 @@ def findvideos(item):
contentLanguage=extra.language,
extraInfo=extra.info))
videolibrary = item.url.get('videolibrary', True)
item.autoplay = item.url.get('autoplay', False)
item.url = '' # do not pass referer
return support.server(item, itemlist=itemlist)
return support.server(item, itemlist=itemlist, Videolibrary=videolibrary)
################################ Menu ################################
def get_menu(item, json, key, itemlist=[]):
logger.debug()
json = json[key]
for option in json:
title = option['title'] if 'title' in option else json[option] if 'search' not in option else ''
@@ -527,8 +575,10 @@ def submenu(item, json, key, itemlist = [], filter_list = []):
if type(item.description) == dict:
description = item.description
else:
if ':/' in item.description: url = item.description
else: url = filetools.join(item.path, item.description)
if ':/' in item.description:
url = item.description
else:
url = filetools.join(item.path, item.description)
description = load_json(url, no_order=True)
else:
description = None
@@ -585,8 +635,11 @@ def filter_thread(filter, key, item, description):
results = tmdb_inf.results[0]
id = results['id']
if id:
thumbnail = 'https://image.tmdb.org/t/p/original' + results['profile_path'] if results['profile_path'] else item.thumbnail
json_file = httptools.downloadpage('http://api.themoviedb.org/3/person/'+ str(id) + '?api_key=' + tmdb_api + '&language=en', use_requests=True).data
thumbnail = 'https://image.tmdb.org/t/p/original' + results['profile_path'] if results[
'profile_path'] else item.thumbnail
json_file = httptools.downloadpage(
'http://api.themoviedb.org/3/person/' + str(id) + '?api_key=' + tmdb_api + '&language=en',
use_requests=True).data
plot += jsontools.load(json_file)['biography']
if description:
@@ -596,7 +649,6 @@ def filter_thread(filter, key, item, description):
fanart = extra.fanart if extra.fanart else item.fanart
plot = extra.plot if extra.plot else item.plot
item = Item(channel=item.channel,
title=support.typo(filter, 'bold'),
url=item.url,
@@ -679,7 +731,8 @@ def set_extra_values(item, json, path):
elif key == 'plot':
ret.plot = json[key]
elif key in ['poster', 'thumbnail']:
ret.thumb = json[key] if ':/' in json[key] else filetools.join(path,json[key]) if '/' in json[key] else get_thumb(json[key])
ret.thumb = json[key] if ':/' in json[key] else filetools.join(path, json[key]) if '/' in json[
key] else get_thumb(json[key])
elif key == 'fanart':
ret.fanart = json[key] if ':/' in json[key] else filetools.join(path, json[key])
elif key in ['url', 'link']:
@@ -690,9 +743,11 @@ def set_extra_values(item, json, path):
elif key == 'episodes_list':
ret.url = {}
ret.url['episodes_list'] = json['episodes_list']
elif key == 'links':
elif key in ['links', 'find_links']:
ret.url = {}
ret.url['links'] = json[key]
ret.url[key] = json[key]
ret.url['videolibrary'] = json.get('videolibrary', True)
ret.url['autoplay'] = json.get('autoplay', False)
elif key == 'filter':
filterkey = json[key].keys()[0]
ret.filter = json[key][filterkey]
@@ -712,6 +767,7 @@ def set_extra_values(item, json, path):
if not ret.plot:
ret.plot = item.plot
logger.debug(ret.url)
return ret
@@ -744,7 +800,8 @@ def relative(key, json, path):
ret = ''
if key in json:
if key in ['thumbnail', 'poster']:
ret = json[key] if ':/' in json[key] else filetools.join(path,json[key]) if '/' in json[key] else get_thumb(json[key]) if json[key] else ''
ret = json[key] if ':/' in json[key] else filetools.join(path, json[key]) if '/' in json[
key] else get_thumb(json[key]) if json[key] else ''
else:
ret = json[key] if ':/' in json[key] else filetools.join(path, json[key]) if '/' in json[key] else ''
@@ -764,7 +821,8 @@ def pagination(item, itemlist = []):
encoded_itemlist.append(it.tourl())
if inspect.stack()[1][3] not in ['add_tvshow', 'get_episodes', 'update', 'find_episodes', 'search']:
Pagination = int(defp) if defp.isdigit() else ''
else: Pagination = ''
else:
Pagination = ''
pag = item.page if item.page else 1
for i, item in enumerate(itemlist):
@@ -791,11 +849,13 @@ def pagination(item, itemlist = []):
itemlist=encoded_itemlist))
return itlist
def add_channel(item):
logger.debug()
channel_to_add = {}
json_file = ''
result = platformtools.dialog_select(config.get_localized_string(70676), [config.get_localized_string(70678), config.get_localized_string(70679)])
result = platformtools.dialog_select(config.get_localized_string(70676),
[config.get_localized_string(70678), config.get_localized_string(70679)])
if result == -1:
return
if result == 0:
@@ -839,12 +899,14 @@ def add_channel(item):
file.write(jsontools.dump(community_json))
file.close()
platformtools.dialog_notification(config.get_localized_string(20000), config.get_localized_string(70683) % json_file['channel_name'])
platformtools.dialog_notification(config.get_localized_string(20000),
config.get_localized_string(70683) % json_file['channel_name'])
import xbmc
xbmc.sleep(1000)
platformtools.itemlist_refresh()
return
def remove_channel(item):
logger.debug()
@@ -860,6 +922,7 @@ def remove_channel(item):
file.write(jsontools.dump(community_json))
file.close()
platformtools.dialog_notification(config.get_localized_string(20000), config.get_localized_string(70684) % to_delete)
platformtools.dialog_notification(config.get_localized_string(20000),
config.get_localized_string(70684) % to_delete)
platformtools.itemlist_refresh()
return