Skip to content

Commit

Permalink
Add way to blacklist resolution for movies
Browse files Browse the repository at this point in the history
  • Loading branch information
k-aito committed Mar 20, 2023
1 parent 685ecb0 commit 5e53330
Showing 1 changed file with 54 additions and 13 deletions.
67 changes: 54 additions & 13 deletions plugin.video.vstream/resources/sites/pastebin.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
UNCLASSIFIED = 'Indéterminé'

MOVIE_MOVIE = (URL_MAIN + '&sMedia=film', 'showMenuFilms')
# MOVIE_NEWS = (URL_MAIN + '&sMedia=film&sYear=2022', 'showMovies')
#MOVIE_NEWS = (URL_MAIN + '&sMedia=film&sYear=2022', 'showMovies')
MOVIE_NEWS = ('movie/now_playing', 'showTMDB')
# MOVIE_GENRES = (URL_MAIN + '&sMedia=film', 'showGenres')
MOVIE_GENRES = ('genre/movie/list', 'showGenreMovieTMDB')
Expand Down Expand Up @@ -94,10 +94,17 @@ def getNbItemParPage():
addon().setSetting(SITE_IDENTIFIER + '_nbItemParPage', nbItem)
return int(nbItem)

def getResolutionBlacklist():
nResolutions = addon().getSetting(SITE_IDENTIFIER + '_nResolutions')
if not nResolutions:
nResolutions = ""
addon().setSetting(SITE_IDENTIFIER + '_nResolutions', nResolutions)
return nResolutions

ITEM_PAR_PAGE = getNbItemParPage()
GROUPE_MAX = 50 # jusqu'à 50 dossiers, limitation du skin
PASTE_PAR_GROUPE = 100 # jusqu'à 100 liens pastebin par dossier
ITEM_PAR_PAGE = getNbItemParPage()
RESOLUTIONS_BACKLIST = getResolutionBlacklist()
GROUPE_MAX = 50 # jusqu'à 50 dossiers, limitation du skin
PASTE_PAR_GROUPE = 100 # jusqu'à 100 liens pastebin par dossier


# Durée du cache, en Heures
Expand Down Expand Up @@ -1268,7 +1275,7 @@ def showSearch():
sUrl = oInputParameterHandler.getValue('siteUrl')

sSearchText = oGui.showKeyBoard()
if sSearchText:
if sSearchText != False:
sUrl += Quote(sSearchText)

showMovies(sUrl)
Expand Down Expand Up @@ -1871,19 +1878,25 @@ def trie_res(key):


def showResolution():
oGui = cGui()
oInputParameterHandler = cInputParameterHandler()
siteUrl = oInputParameterHandler.getValue('siteUrl')
oGui = cGui()
oInputParameterHandler = cInputParameterHandler()
siteUrl = oInputParameterHandler.getValue('siteUrl')
oOutputParameterHandler = cOutputParameterHandler()
resolutions = [('DOLBY VISION', 'DOLBY VISION'), ('4K', '4K [2160p]'), ('1080P', 'fullHD [1080p]'), ('720P', 'HD [720p]'), ('SD', 'SD'), ('3D', '3D')]
resolutions = [('DOLBY VISION', 'DOLBY VISION'), ('4K', '4K [2160p]'), ('1080P', 'fullHD [1080p]'), ('720P', 'HD [720p]'), ('SD', 'SD'), ('3D', '3D')]

# Create BLACKLIST APPLIED folder if RESOLUTIONS_BACKLIST is not empty
if RESOLUTIONS_BACKLIST != "":
sUrl = siteUrl + '&sRes=' + 'BLACKLIST APPLIED'
oOutputParameterHandler.addParameter('siteUrl', sUrl)
oGui.addDir(SITE_IDENTIFIER, 'showMenuFilms', 'BLACKLIST APPLIED', 'hd.png', oOutputParameterHandler)

for sRes, sDisplayRes in resolutions:
sUrl = siteUrl + '&sRes=' + sRes
oOutputParameterHandler.addParameter('siteUrl', sUrl)
oGui.addDir(SITE_IDENTIFIER, 'showMenuFilms', sDisplayRes, 'hd.png', oOutputParameterHandler)

oGui.setEndOfDirectory()


def alphaList():
oGui = cGui()
oInputParameterHandler = cInputParameterHandler()
Expand Down Expand Up @@ -2174,12 +2187,24 @@ def showMovies(sSearch=''):
listRes.append('')

if sRes:
if sRes == 'BLACKLIST APPLIED':
# Extract the resolution that are blacklisted from listRes
oldListRes = listRes
listRes = []
for res in oldListRes:
if res not in RESOLUTIONS_BACKLIST.strip().split(','):
listRes.append(res)
if sRes == UNCLASSIFIED:
if '' not in listRes:
continue

bValid = False

for res in listRes:
# Set bValid = True if sRest = BLACKLIST APPLIED because it is like we got each sRes in res
if sRes == "BLACKLIST APPLIED":
bValid = True
break
if sRes in res:
bValid = True
break
Expand Down Expand Up @@ -2218,7 +2243,6 @@ def showMovies(sSearch=''):
oOutputParameterHandler.addParameter('sYear', movieYear) # Utilisé par TMDB
if listRes:
oOutputParameterHandler.addParameter('listRes', listRes)

if sMedia == 'serie':
oGui.addTV(SITE_IDENTIFIER, 'showSerieSaisons', sDisplayTitle, 'series.png', '', '', oOutputParameterHandler)
elif sMedia == 'anime':
Expand Down Expand Up @@ -2546,7 +2570,8 @@ def getHosterList(siteUrl):
idxResMovie += 1

# On vérifie la résolution attendue si pas uptostream
if sRes and sRes not in resMovie:
# And different than BLACKLIST APPLIED
if sRes and sRes not in resMovie and sRes != "BLACKLIST APPLIED":
if pbContent.getUptoStream() == 2:
continue

Expand All @@ -2570,11 +2595,16 @@ def getHosterList(siteUrl):

linkToAdd = False
if sRes: # Recherche d'une résolution en particulier
if res and res != 'ori':
# if sRes = BLACKLIST APPLIED check that res are not in RESOLUTIONS_BACKLIST
if sRes == "BLACKLIST APPLIED":
if res not in RESOLUTIONS_BACKLIST.strip().split(','):
linkToAdd = True
elif res and res != 'ori':
if sRes in res:
linkToAdd = True
elif sRes in resMovie:
linkToAdd = True

else:
linkToAdd = True

Expand Down Expand Up @@ -2927,6 +2957,9 @@ def adminContenu():
# Menu pour rafraichir le cache
oGui.addDir(SITE_IDENTIFIER, 'adminNbElement', "[COLOR %s]Nombre d'éléments affichés[/COLOR]" % sDecoColor, 'listes.png', oOutputParameterHandler)

# Menu pour définir les résolutions à NE PAS utiliser
oGui.addDir(SITE_IDENTIFIER, 'adminBlacklistResolution', "[COLOR %s]Résolutions à ne pas afficher[/COLOR]" % sDecoColor, 'listes.png', oOutputParameterHandler)

oGui.setEndOfDirectory()


Expand All @@ -2945,6 +2978,14 @@ def adminNbElement():
if nElement:
addon().setSetting(SITE_IDENTIFIER + '_nbItemParPage', nElement)

# Définir les résolutions a NE PAS utiliser
def adminBlacklistResolution():
oGui = cGui()
nResolutions = oGui.showKeyBoard(str(RESOLUTIONS_BACKLIST), "Résolutions a ne pas utiliser séparé par une virgule par exemple (4K,SD)")
if nResolutions:
addon().setSetting(SITE_IDENTIFIER + '_nResolutions', nResolutions)
else:
addon().setSetting(SITE_IDENTIFIER + '_nResolutions', "")

# Retourne la décompte de média par type
def getNbMedia():
Expand Down

0 comments on commit 5e53330

Please sign in to comment.