change all/official/fanmade videoselection into a function (incomplete, not used everywhere)
This commit is contained in:
parent
76753e2fee
commit
75f286828e
1 changed files with 53 additions and 111 deletions
126
default.py
126
default.py
|
@ -32,8 +32,14 @@ maxFileAge = maxFileAge * 60
|
||||||
mediatype = addon.getSetting("mediatype")
|
mediatype = addon.getSetting("mediatype")
|
||||||
# show only official, fanmade or all videos?
|
# show only official, fanmade or all videos?
|
||||||
videoselection = str(addon.getSetting("videoselection")).lower()
|
videoselection = str(addon.getSetting("videoselection")).lower()
|
||||||
# despite this selection show all in similar playlists and more from?
|
if videoselection != "2":
|
||||||
relatedselection = str(addon.getSetting("relatedselection")).lower()
|
# videoselection is set to official or fanmade
|
||||||
|
# despite this selection show all in similar playlists and more from?
|
||||||
|
relatedselection = str(addon.getSetting("relatedselection")).lower()
|
||||||
|
else:
|
||||||
|
# if videoselection is set to show all videos relatedselection should
|
||||||
|
# also be true if the setting was set to false beforehand
|
||||||
|
relatedselection = "true"
|
||||||
playLocalFile = str(addon.getSetting("playLocalFile")).lower()
|
playLocalFile = str(addon.getSetting("playLocalFile")).lower()
|
||||||
filesinlists = int(addon.getSetting("filesinlists"))
|
filesinlists = int(addon.getSetting("filesinlists"))
|
||||||
useYTDL = addon.getSetting("useytdl")
|
useYTDL = addon.getSetting("useytdl")
|
||||||
|
@ -502,6 +508,8 @@ def sortArtists(channel=""):
|
||||||
for artist in channels:
|
for artist in channels:
|
||||||
if artist in [unidecode(name.upper()) for name in entry['artists']]:
|
if artist in [unidecode(name.upper()) for name in entry['artists']]:
|
||||||
if entry not in result:
|
if entry not in result:
|
||||||
|
# limit selection based on videoselection setting if show all isn't activated
|
||||||
|
if relatedselection != "true" and videoselection != "2":
|
||||||
if videoselection == "0":
|
if videoselection == "0":
|
||||||
if "true" in entry['official'].lower():
|
if "true" in entry['official'].lower():
|
||||||
result.append(entry)
|
result.append(entry)
|
||||||
|
@ -539,20 +547,16 @@ def sortTitlesBy(limit, sort, start):
|
||||||
start = int(start)
|
start = int(start)
|
||||||
end = start + filesinlists
|
end = start + filesinlists
|
||||||
nextstart = end + 1
|
nextstart = end + 1
|
||||||
|
|
||||||
fanart = getFanart(channel)
|
fanart = getFanart(channel)
|
||||||
|
|
||||||
|
# limit selection if "all" isn't activated in videoselection
|
||||||
|
if videoselection != "2" and channel != "related" and channel != "relartists":
|
||||||
|
data = limitselection(data)
|
||||||
|
|
||||||
# limit to hits
|
# limit to hits
|
||||||
if hit != "" and hit == "true":
|
if hit != "" and hit == "true":
|
||||||
for entry in data:
|
for entry in data:
|
||||||
if entry['hit'] == "true":
|
if entry['hit'] == "true":
|
||||||
if videoselection == "0":
|
|
||||||
if "true" in entry['official']:
|
|
||||||
result.append(entry)
|
|
||||||
elif videoselection == "1":
|
|
||||||
if "false" in entry['official']:
|
|
||||||
result.append(entry)
|
|
||||||
elif videoselection == "2":
|
|
||||||
result.append(entry)
|
result.append(entry)
|
||||||
data = result
|
data = result
|
||||||
result = []
|
result = []
|
||||||
|
@ -562,13 +566,6 @@ def sortTitlesBy(limit, sort, start):
|
||||||
for entry in data:
|
for entry in data:
|
||||||
# played often at provider
|
# played often at provider
|
||||||
if int(entry['pcount']) >= pcounthigh:
|
if int(entry['pcount']) >= pcounthigh:
|
||||||
if videoselection == "0":
|
|
||||||
if "true" in entry['official']:
|
|
||||||
result.append(entry)
|
|
||||||
elif videoselection == "1":
|
|
||||||
if "false" in entry['official']:
|
|
||||||
result.append(entry)
|
|
||||||
elif videoselection == "2":
|
|
||||||
result.append(entry)
|
result.append(entry)
|
||||||
data = result
|
data = result
|
||||||
result = []
|
result = []
|
||||||
|
@ -577,13 +574,6 @@ def sortTitlesBy(limit, sort, start):
|
||||||
if mycount != "" and mycount == "acount" and sort != "count":
|
if mycount != "" and mycount == "acount" and sort != "count":
|
||||||
for entry in data:
|
for entry in data:
|
||||||
if int(entry['acount']) >= acounthigh:
|
if int(entry['acount']) >= acounthigh:
|
||||||
if videoselection == "0":
|
|
||||||
if "true" in entry['official']:
|
|
||||||
result.append(entry)
|
|
||||||
elif videoselection == "1":
|
|
||||||
if "false" in entry['official']:
|
|
||||||
result.append(entry)
|
|
||||||
elif videoselection == "2":
|
|
||||||
result.append(entry)
|
result.append(entry)
|
||||||
data = result
|
data = result
|
||||||
result = []
|
result = []
|
||||||
|
@ -592,13 +582,6 @@ def sortTitlesBy(limit, sort, start):
|
||||||
if mycount != "" and mycount == "comments" and sort != "count":
|
if mycount != "" and mycount == "comments" and sort != "count":
|
||||||
for entry in data:
|
for entry in data:
|
||||||
if int(entry['comments']) >= ccounthigh:
|
if int(entry['comments']) >= ccounthigh:
|
||||||
if videoselection == "0":
|
|
||||||
if "true" in entry['official']:
|
|
||||||
result.append(entry)
|
|
||||||
elif videoselection == "1":
|
|
||||||
if "false" in entry['official']:
|
|
||||||
result.append(entry)
|
|
||||||
elif videoselection == "2":
|
|
||||||
result.append(entry)
|
result.append(entry)
|
||||||
data = result
|
data = result
|
||||||
result = []
|
result = []
|
||||||
|
@ -607,15 +590,7 @@ def sortTitlesBy(limit, sort, start):
|
||||||
if mycount != "" and mycount == "likes" and sort != "count":
|
if mycount != "" and mycount == "likes" and sort != "count":
|
||||||
for entry in data:
|
for entry in data:
|
||||||
if int(entry['likes']) >= likecounthigh:
|
if int(entry['likes']) >= likecounthigh:
|
||||||
if videoselection == "0":
|
|
||||||
if "true" in entry['official']:
|
|
||||||
result.append(entry)
|
result.append(entry)
|
||||||
elif videoselection == "1":
|
|
||||||
if "false" in entry['official']:
|
|
||||||
result.append(entry)
|
|
||||||
elif videoselection == "2":
|
|
||||||
result.append(entry)
|
|
||||||
# xbmc.log(msg=str(entry['pcount']), level=xbmc.LOGNOTICE)
|
|
||||||
data = result
|
data = result
|
||||||
result = []
|
result = []
|
||||||
|
|
||||||
|
@ -623,13 +598,6 @@ def sortTitlesBy(limit, sort, start):
|
||||||
if mycount != "" and mycount == "dislikes" and sort != "count":
|
if mycount != "" and mycount == "dislikes" and sort != "count":
|
||||||
for entry in data:
|
for entry in data:
|
||||||
if int(entry['dislikes']) >= dislikecounthigh:
|
if int(entry['dislikes']) >= dislikecounthigh:
|
||||||
if videoselection == "0":
|
|
||||||
if "true" in entry['official']:
|
|
||||||
result.append(entry)
|
|
||||||
elif videoselection == "1":
|
|
||||||
if "false" in entry['official']:
|
|
||||||
result.append(entry)
|
|
||||||
elif videoselection == "2":
|
|
||||||
result.append(entry)
|
result.append(entry)
|
||||||
data = result
|
data = result
|
||||||
result = []
|
result = []
|
||||||
|
@ -638,13 +606,6 @@ def sortTitlesBy(limit, sort, start):
|
||||||
if mycount != "" and mycount == "controversial":
|
if mycount != "" and mycount == "controversial":
|
||||||
for entry in data:
|
for entry in data:
|
||||||
if int(entry['controversial']) == int(1):
|
if int(entry['controversial']) == int(1):
|
||||||
if videoselection == "0":
|
|
||||||
if "true" in entry['official']:
|
|
||||||
result.append(entry)
|
|
||||||
elif videoselection == "1":
|
|
||||||
if "false" in entry['official']:
|
|
||||||
result.append(entry)
|
|
||||||
elif videoselection == "2":
|
|
||||||
result.append(entry)
|
result.append(entry)
|
||||||
data = result
|
data = result
|
||||||
result = []
|
result = []
|
||||||
|
@ -653,13 +614,6 @@ def sortTitlesBy(limit, sort, start):
|
||||||
if channel != "" and channel != "all" and channel != "year" and channel != "related":
|
if channel != "" and channel != "all" and channel != "year" and channel != "related":
|
||||||
for entry in data:
|
for entry in data:
|
||||||
if entry['style'] == channel:
|
if entry['style'] == channel:
|
||||||
if videoselection == "0":
|
|
||||||
if "true" in entry['official']:
|
|
||||||
result.append(entry)
|
|
||||||
elif videoselection == "1":
|
|
||||||
if "false" in entry['official']:
|
|
||||||
result.append(entry)
|
|
||||||
elif videoselection == "2":
|
|
||||||
result.append(entry)
|
result.append(entry)
|
||||||
# or limit to last year
|
# or limit to last year
|
||||||
# hm, either style or year, not both?
|
# hm, either style or year, not both?
|
||||||
|
@ -674,13 +628,6 @@ def sortTitlesBy(limit, sort, start):
|
||||||
import time
|
import time
|
||||||
dateadded = datetime.fromtimestamp(time.mktime(time.strptime(entry['dateadded'], '%Y-%m-%d %H:%M:%S')))
|
dateadded = datetime.fromtimestamp(time.mktime(time.strptime(entry['dateadded'], '%Y-%m-%d %H:%M:%S')))
|
||||||
if dateadded >= lastyear:
|
if dateadded >= lastyear:
|
||||||
if videoselection == "0":
|
|
||||||
if "true" in entry['official']:
|
|
||||||
result.append(entry)
|
|
||||||
elif videoselection == "1":
|
|
||||||
if "false" in entry['official']:
|
|
||||||
result.append(entry)
|
|
||||||
elif videoselection == "2":
|
|
||||||
result.append(entry)
|
result.append(entry)
|
||||||
# related tracks (generated with musly)
|
# related tracks (generated with musly)
|
||||||
elif channel != "" and channel == "related":
|
elif channel != "" and channel == "related":
|
||||||
|
@ -692,7 +639,6 @@ def sortTitlesBy(limit, sort, start):
|
||||||
slugs.extend(entry['slug'].split(", "))
|
slugs.extend(entry['slug'].split(", "))
|
||||||
# and add all related slugs
|
# and add all related slugs
|
||||||
slugs.extend(entry['related'].split(", "))
|
slugs.extend(entry['related'].split(", "))
|
||||||
#xbmc.log(msg=str(slugs), level=xbmc.LOGNOTICE)
|
|
||||||
for entry in data:
|
for entry in data:
|
||||||
# add all related slugs
|
# add all related slugs
|
||||||
if entry['slug'] in slugs:
|
if entry['slug'] in slugs:
|
||||||
|
@ -701,14 +647,6 @@ def sortTitlesBy(limit, sort, start):
|
||||||
# main slug will be filtered out.
|
# main slug will be filtered out.
|
||||||
# In this case we add it again later, after sorting the result
|
# In this case we add it again later, after sorting the result
|
||||||
if not filter(lambda result: result['title'] == entry['title'], result):
|
if not filter(lambda result: result['title'] == entry['title'], result):
|
||||||
if videoselection != "2" and relatedselection != "true":
|
|
||||||
if videoselection == "0":
|
|
||||||
if "true" in entry['official']:
|
|
||||||
result.append(entry)
|
|
||||||
elif videoselection == "1":
|
|
||||||
if "false" in entry['official']:
|
|
||||||
result.append(entry)
|
|
||||||
else:
|
|
||||||
result.append(entry)
|
result.append(entry)
|
||||||
# slugs are sorted newest first because that's how they occur in the json
|
# slugs are sorted newest first because that's how they occur in the json
|
||||||
# so we have to sort the result to the order in related aka the musly order (with prepended main slug)
|
# so we have to sort the result to the order in related aka the musly order (with prepended main slug)
|
||||||
|
@ -722,6 +660,9 @@ def sortTitlesBy(limit, sort, start):
|
||||||
for entry in data:
|
for entry in data:
|
||||||
if entry['slug'] == start:
|
if entry['slug'] == start:
|
||||||
result.insert(0, entry)
|
result.insert(0, entry)
|
||||||
|
if relatedselection != "true":
|
||||||
|
result = limitselection(result)
|
||||||
|
|
||||||
maximum = len(result)
|
maximum = len(result)
|
||||||
# related is a list with max 21 entries, so we have to set start always to 0
|
# related is a list with max 21 entries, so we have to set start always to 0
|
||||||
start = 0
|
start = 0
|
||||||
|
@ -738,27 +679,15 @@ def sortTitlesBy(limit, sort, start):
|
||||||
xbmc.log(msg=str(artists), level=xbmc.LOGNOTICE)
|
xbmc.log(msg=str(artists), level=xbmc.LOGNOTICE)
|
||||||
# add all entries with artist in artists
|
# add all entries with artist in artists
|
||||||
if entry['artists'] in artists:
|
if entry['artists'] in artists:
|
||||||
if videoselection != "2" and relatedselection != "true":
|
|
||||||
if videoselection == "0":
|
|
||||||
if "true" in entry['official']:
|
|
||||||
result.append(entry)
|
|
||||||
elif videoselection == "1":
|
|
||||||
if "false" in entry['official']:
|
|
||||||
result.append(entry)
|
|
||||||
else:
|
|
||||||
result.append(entry)
|
result.append(entry)
|
||||||
|
xbmc.log(msg=str(results), level=xbmc.LOGNOTICE)
|
||||||
|
if relatedselection != "true":
|
||||||
|
result = limitselection(result)
|
||||||
start = 0
|
start = 0
|
||||||
|
|
||||||
# unfiltered sorted lists (by date and by numbers. But NOT controversial, which is a fixed list)
|
# sorted lists (by date and by numbers. But NOT controversial, which is a fixed list)
|
||||||
else:
|
else:
|
||||||
for entry in data:
|
for entry in data:
|
||||||
if videoselection == "0":
|
|
||||||
if "true" in entry['official']:
|
|
||||||
result.append(entry)
|
|
||||||
elif videoselection == "1":
|
|
||||||
if "false" in entry['official']:
|
|
||||||
result.append(entry)
|
|
||||||
elif videoselection == "2":
|
|
||||||
result.append(entry)
|
result.append(entry)
|
||||||
|
|
||||||
if sort != "" and sort == "random":
|
if sort != "" and sort == "random":
|
||||||
|
@ -930,6 +859,19 @@ def getFanart(channel):
|
||||||
fanart = icon
|
fanart = icon
|
||||||
return fanart
|
return fanart
|
||||||
|
|
||||||
|
def limitselection(data):
|
||||||
|
xbmc.log(msg="limit by videoselection", level=xbmc.DEBUG)
|
||||||
|
result = []
|
||||||
|
for entry in data:
|
||||||
|
if videoselection == "0":
|
||||||
|
if "true" in entry['official']:
|
||||||
|
result.append(entry)
|
||||||
|
elif videoselection == "1":
|
||||||
|
if "false" in entry['official']:
|
||||||
|
result.append(entry)
|
||||||
|
elif videoselection == "2":
|
||||||
|
result.append(entry)
|
||||||
|
return result
|
||||||
|
|
||||||
def addDir(name, url, mode, iconimage, total=0):
|
def addDir(name, url, mode, iconimage, total=0):
|
||||||
u = sys.argv[0] + "?url=" + urllib.quote_plus(url.encode('utf-8')) + "&mode=" + str(mode)
|
u = sys.argv[0] + "?url=" + urllib.quote_plus(url.encode('utf-8')) + "&mode=" + str(mode)
|
||||||
|
|
Loading…
Reference in a new issue