Advertisement
Guest User

plugin.video.acesvideo/lib/utils.py

a guest
Aug 2nd, 2023
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.07 KB | None | 0 0
  1. # -*- coding: utf-8 -*-
  2. import sys
  3. import six
  4.  
  5. from six.moves import urllib_parse
  6.  
  7. import xbmc, xbmcgui, xbmcplugin, xbmcaddon
  8.  
  9. try:
  10.     import requests
  11.  
  12.     from requests.packages.urllib3.exceptions import InsecureRequestWarning
  13.     requests.packages.urllib3.disable_warnings(InsecureRequestWarning)
  14.    
  15.     session = requests.session()
  16. except ImportError:
  17.     session = None
  18.  
  19. ADDON = xbmcaddon.Addon()
  20.  
  21. ADDON_NAME = ADDON.getAddonInfo("name")
  22. ADDON_ICON = ADDON.getAddonInfo("icon")
  23.  
  24. def XbmcDebug(message):
  25.     xbmc.log(f"{ADDON_NAME} > {message}", xbmc.LOGWARNING)
  26.  
  27. def BuildURL(query):
  28.     return sys.argv[0] + "?" + urllib_parse.urlencode({
  29.         k: v.encode("utf-8") if isinstance(v, six.text_type) else str(v).encode("utf-8")
  30.         for k, v in query.items()
  31.     })
  32.  
  33. class Listing:
  34.     def __init__(self):
  35.         self.listItems = []
  36.    
  37.     def addItem(self, label, image=ADDON_ICON, data={}, color="yellow", infoType=None, infoLabels=None, **properties):
  38.         list_item = xbmcgui.ListItem(f"[COLOR {color}]{label}[/COLOR]", label2=label)
  39.         list_item.setArt({ "thumb": image })
  40.        
  41.         if infoType and infoLabels:
  42.             list_item.setInfo(infoType, infoLabels)
  43.        
  44.         for item in properties.items():
  45.             XbmcDebug(item)
  46.             list_item.setProperty(item[0], item[1])
  47.  
  48.         self.listItems.append((BuildURL(data), list_item, True))
  49.  
  50.     def show(self, handle=int(sys.argv[1])):
  51.         xbmcplugin.addDirectoryItems(
  52.             handle,
  53.             tuple(self.listItems)
  54.         )
  55.  
  56.         xbmcplugin.endOfDirectory(handle)
  57.  
  58. def PlayVideo(url, handle=int(sys.argv[1])):
  59.     XbmcDebug(url)
  60.     XbmcDebug(handle)
  61.  
  62.     play_item = xbmcgui.ListItem(path="https://ia800908.us.archive.org/30/items/TheStranger_0/The_Stranger_512kb.mp4")
  63.     xbmcplugin.setResolvedUrl(handle, succeeded=True, listitem=play_item)
  64.  
  65. def Main(globals, defaultAction="ActionMainMenu"):
  66.     params = dict(urllib_parse.parse_qsl(sys.argv[2][1:], keep_blank_values=True))
  67.     globals[params.get("action", defaultAction)](params)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement