Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ajout d'une option de blacklist de résolution pour les films #4026

Open
wants to merge 2 commits into
base: Beta
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 53 additions & 14 deletions plugin.video.vstream/resources/sites/pastebin.py
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Je pense que ce sera plus propre de définir une constante avec la valeur:
BLACKLIST APPLIED. Du genre:

BLACKLIST_APPLIED = "BLACKLIST APPLIED"
# Et donc dans le code:
sUrl = siteUrl + '&sRes=' + BLACKLIST_APPLIED
# ...
if sRes == BLACKLIST_APPLIED:

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ce serait plus cohérent avec le reste du code, je crois avoir vu que le sRes est également une variable.

Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,10 @@
SETTING_PASTE_LABEL = SITE_IDENTIFIER + '_label_'
UNCLASSIFIED_GENRE = '_NON CLASSÉ_'
UNCLASSIFIED = 'Indéterminé'
BLACKLIST_APPLIED = "BLACKLIST APPLIED"

MOVIE_MOVIE = (URL_MAIN + '&sMedia=film', 'showMenuFilms')
#MOVIE_NEWS = (URL_MAIN + '&sMedia=film&sYear=2023', 'showMovies')
# MOVIE_NEWS = (URL_MAIN + '&sMedia=film&sYear=2023', '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 +95,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 +1276,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 +1879,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 @@ -2177,13 +2191,22 @@ 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:
if sRes in res:
# Set bValid = True if sRest = BLACKLIST APPLIED because it is like we got each sRes in res
if sRes == BLACKLIST_APPLIED or sRes in res:
bValid = True
break

Expand Down Expand Up @@ -2221,7 +2244,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 @@ -2552,7 +2574,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 @@ -2576,11 +2599,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 @@ -2933,6 +2961,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 @@ -2951,6 +2982,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