[contrib] fix pyflakes in xbmc plugin
This commit is contained in:
parent
ed46d72f21
commit
579db854e8
11 changed files with 452 additions and 452 deletions
|
|
@ -1,31 +1,31 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
import sys
|
||||
import resources.lib.base.common_xbmc as common_xbmc
|
||||
import resources.lib.constants as constants
|
||||
from resources.lib.actions import actions
|
||||
|
||||
# Plugin constants
|
||||
version = "0.1.0"
|
||||
plugin = "videoobmc" + version
|
||||
addon_id = "plugin.video.videoobmc"
|
||||
author = "Bezleputh"
|
||||
mail = "carton_ben@yahoo.fr"
|
||||
|
||||
#import lxml.html import Element
|
||||
#print Element.__file__
|
||||
|
||||
#TODO gestion du logger, gestion des modules via XBMC (activation/desactivation)
|
||||
|
||||
#Bug encodge des categories
|
||||
#corriger version 1 pour que v2 et v1 donctionnent
|
||||
|
||||
if (__name__ == "__main__"):
|
||||
if not (sys.argv[2]):
|
||||
actions[constants.DISPLAY_MENU]()._do()
|
||||
else:
|
||||
params = common_xbmc.parse_params(sys.argv[2])
|
||||
action = params.get("action")
|
||||
if (action):
|
||||
actions[action]()._do(params)
|
||||
else:
|
||||
common_xbmc.display_error(" ARGV Nothing done.. verify params " + repr(params))
|
||||
# -*- coding: utf-8 -*-
|
||||
import sys
|
||||
import resources.lib.base.common_xbmc as common_xbmc
|
||||
import resources.lib.constants as constants
|
||||
from resources.lib.actions import actions
|
||||
|
||||
# Plugin constants
|
||||
version = "0.1.0"
|
||||
plugin = "videoobmc" + version
|
||||
addon_id = "plugin.video.videoobmc"
|
||||
author = "Bezleputh"
|
||||
mail = "carton_ben@yahoo.fr"
|
||||
|
||||
#import lxml.html import Element
|
||||
#print Element.__file__
|
||||
|
||||
#TODO gestion du logger, gestion des modules via XBMC (activation/desactivation)
|
||||
|
||||
#Bug encodge des categories
|
||||
#corriger version 1 pour que v2 et v1 donctionnent
|
||||
|
||||
if (__name__ == "__main__"):
|
||||
if not (sys.argv[2]):
|
||||
actions[constants.DISPLAY_MENU]()._do()
|
||||
else:
|
||||
params = common_xbmc.parse_params(sys.argv[2])
|
||||
action = params.get("action")
|
||||
if (action):
|
||||
actions[action]()._do(params)
|
||||
else:
|
||||
common_xbmc.display_error(" ARGV Nothing done.. verify params " + repr(params))
|
||||
|
|
|
|||
|
|
@ -1,23 +1,23 @@
|
|||
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
|
||||
<strings>
|
||||
<!-- Les strings de 30000 à 30999 sont réservées aux paramètres plug-in -->
|
||||
<string id="30000">Search</string>
|
||||
<string id="30001">Search: </string>
|
||||
<?xml vesion="1.0" encoding="utf-8" standalone="yes"?>
|
||||
<stings>
|
||||
<!-- Les stings de 30000 à 30999 sont ésevées aux paamètes plug-in -->
|
||||
<sting id="30000">Seach</sting>
|
||||
<sting id="30001">Seach: </sting>
|
||||
|
||||
<string id="30100">Download</string>
|
||||
<string id="30110">Information</string>
|
||||
<sting id="30100">Download</sting>
|
||||
<sting id="30110">Infomation</sting>
|
||||
|
||||
<string id="30200">Error!</string>
|
||||
<sting id="30200">Eo!</sting>
|
||||
|
||||
<string id="30300">Information</string>
|
||||
<string id="30301">Download started</string>
|
||||
<string id="30302">Download succeed</string>
|
||||
<sting id="30300">Infomation</sting>
|
||||
<sting id="30301">Download stated</sting>
|
||||
<sting id="30302">Download succeed</sting>
|
||||
|
||||
<string id="30510">Download folder: </string>
|
||||
<string id="30520">Number of videos per backends: </string>
|
||||
<string id="30530">Display Non Safe For Work videos: </string>
|
||||
<string id="30540">Enable debug mode: </string>
|
||||
<string id="30550">Update weboob backends</string>
|
||||
<string id="30551">Start updating weboob backends</string>
|
||||
<string id="30552">Weboob backends successfully updated</string>
|
||||
</strings>
|
||||
<sting id="30510">Download folde: </sting>
|
||||
<sting id="30520">Numbe of videos pe backends: </sting>
|
||||
<sting id="30530">Display Non Safe Fo Wok videos: </sting>
|
||||
<sting id="30540">Enable debug mode: </sting>
|
||||
<sting id="30550">Update weboob backends</sting>
|
||||
<sting id="30551">Stat updating weboob backends</sting>
|
||||
<sting id="30552">Weboob backends successfully updated</sting>
|
||||
</stings>
|
||||
|
|
|
|||
|
|
@ -1,23 +1,23 @@
|
|||
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
|
||||
<strings>
|
||||
<!-- Les strings de 30000 à 30999 sont réservées aux paramètres plug-in -->
|
||||
<string id="30000">Recherche</string>
|
||||
<string id="30001">Recherche: </string>
|
||||
<?xml vesion="1.0" encoding="utf-8" standalone="yes"?>
|
||||
<stings>
|
||||
<!-- Les stings de 30000 à 30999 sont ésevées aux paamètes plug-in -->
|
||||
<sting id="30000">Recheche</sting>
|
||||
<sting id="30001">Recheche: </sting>
|
||||
|
||||
<string id="30100">Télécharger</string>
|
||||
<string id="30110">Information</string>
|
||||
<sting id="30100">Téléchage</sting>
|
||||
<sting id="30110">Infomation</sting>
|
||||
|
||||
<string id="30200">Erreur!</string>
|
||||
<sting id="30200">Eeu!</sting>
|
||||
|
||||
<string id="30300">Information</string>
|
||||
<string id="30301">Lancement du téléchargement</string>
|
||||
<string id="30302">Fichier téléchargé avec succès</string>
|
||||
<sting id="30300">Infomation</sting>
|
||||
<sting id="30301">Lancement du téléchagement</sting>
|
||||
<sting id="30302">Fichie téléchagé avec succès</sting>
|
||||
|
||||
<string id="30510">Répertoire de Téléchargement:</string>
|
||||
<string id="30520">Nombre de vidéos par backends:</string>
|
||||
<string id="30530">Afficher les vidéos interdites aux moins de 18 ans :</string>
|
||||
<string id="30540">Enable debug mode :</string>
|
||||
<string id="30550">Mise à jour des modules weboob</string>
|
||||
<string id="30551">Debut de la mise à jour</string>
|
||||
<string id="30552">Weboob est maintenant à jour</string>
|
||||
</strings>
|
||||
<sting id="30510">Répetoie de Téléchagement:</sting>
|
||||
<sting id="30520">Nombe de vidéos pa backends:</sting>
|
||||
<sting id="30530">Affiche les vidéos intedites aux moins de 18 ans :</sting>
|
||||
<sting id="30540">Enable debug mode :</sting>
|
||||
<sting id="30550">Mise à jou des modules weboob</sting>
|
||||
<sting id="30551">Debut de la mise à jou</sting>
|
||||
<sting id="30552">Weboob est maintenant à jou</sting>
|
||||
</stings>
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
# Dummy file to make this directory a package.
|
||||
# Dummy file to make this directory a package.
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
# Dummy file to make this directory a package.
|
||||
# Dummy file to make this directory a package.
|
||||
|
|
|
|||
|
|
@ -1,157 +1,157 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
import xbmc
|
||||
import xbmcgui
|
||||
import xbmcplugin
|
||||
import xbmcaddon
|
||||
|
||||
import urllib
|
||||
import sys
|
||||
|
||||
from traceback import print_exc
|
||||
|
||||
|
||||
def get_addon():
|
||||
if hasattr(sys.modules["__main__"], "addon_id"):
|
||||
_id = sys.modules["__main__"].addon_id
|
||||
return xbmcaddon.Addon(id=_id)
|
||||
|
||||
|
||||
def get_translation(key):
|
||||
addon = get_addon()
|
||||
if addon:
|
||||
return addon.getLocalizedString(int(key))
|
||||
|
||||
|
||||
def get_settings(key):
|
||||
addon = get_addon()
|
||||
if addon:
|
||||
return addon.getSetting(key)
|
||||
|
||||
|
||||
def get_addon_dir():
|
||||
addon = get_addon()
|
||||
if addon:
|
||||
addonDir = addon.getAddonInfo("path")
|
||||
else:
|
||||
addonDir = xbmc.translatePath("special://profile/addon_data/")
|
||||
|
||||
return addonDir
|
||||
|
||||
|
||||
def display_error(msg):
|
||||
xbmc.executebuiltin("XBMC.Notification(%s, %s)" % (get_translation('30200').decode('utf-8'), msg))
|
||||
print msg
|
||||
print_exc(msg)
|
||||
|
||||
|
||||
def display_info(msg):
|
||||
xbmc.executebuiltin("XBMC.Notification(%s, %s, 3000, DefaultFolder.png)" % (get_translation('30300').encode('utf-8'),
|
||||
msg.encode('utf-8')))
|
||||
#print msg
|
||||
print_exc()
|
||||
|
||||
|
||||
def parse_params(param_str):
|
||||
param_dic = {}
|
||||
# Parameters are on the 3rd arg passed to the script
|
||||
param_str = sys.argv[2]
|
||||
if len(param_str) > 1:
|
||||
param_str = param_str.replace('?', '')
|
||||
|
||||
# Ignore last char if it is a '/'
|
||||
if param_str[len(param_str) - 1] == '/':
|
||||
param_str = param_str[0:len(param_str) - 2]
|
||||
|
||||
# Processing each parameter splited on '&'
|
||||
for param in param_str.split('&'):
|
||||
try:
|
||||
# Spliting couple key/value
|
||||
key, value = param.split('=')
|
||||
except:
|
||||
key = param
|
||||
value = ''
|
||||
|
||||
key = urllib.unquote_plus(key)
|
||||
value = urllib.unquote_plus(value)
|
||||
|
||||
# Filling dictionnary
|
||||
param_dic[key] = value
|
||||
|
||||
return param_dic
|
||||
|
||||
|
||||
def ask_user(content, title):
|
||||
keyboard = xbmc.Keyboard(content, title)
|
||||
keyboard.doModal()
|
||||
if keyboard.isConfirmed() and keyboard.getText():
|
||||
return keyboard.getText()
|
||||
return ""
|
||||
|
||||
|
||||
def create_param_url(param_dic, quote_plus=False):
|
||||
"""
|
||||
Create an plugin URL based on the key/value passed in a dictionary
|
||||
"""
|
||||
url = sys.argv[0]
|
||||
sep = '?'
|
||||
|
||||
try:
|
||||
for param in param_dic:
|
||||
if quote_plus:
|
||||
url = url + sep + urllib.quote_plus(param) + '=' + urllib.quote_plus(param_dic[param])
|
||||
else:
|
||||
url = "%s%s%s=%s" % (url, sep, param, param_dic[param])
|
||||
|
||||
sep = '&'
|
||||
except Exception, msg:
|
||||
display_error("create_param_url %s" % msg)
|
||||
url = None
|
||||
return url
|
||||
|
||||
|
||||
def create_list_item(name, itemInfoType="Video", itemInfoLabels=None, iconimage="DefaultFolder.png",
|
||||
c_items=None, isPlayable=False):
|
||||
lstItem = xbmcgui.ListItem(label=name, iconImage=iconimage, thumbnailImage=iconimage)
|
||||
|
||||
if c_items:
|
||||
lstItem.addContextMenuItems(c_items, replaceItems=True)
|
||||
|
||||
if itemInfoLabels:
|
||||
iLabels = itemInfoLabels
|
||||
else:
|
||||
iLabels = {"Title": name, }
|
||||
|
||||
lstItem.setInfo(type=itemInfoType, infoLabels=iLabels)
|
||||
if isPlayable:
|
||||
lstItem.setProperty('IsPlayable', "true")
|
||||
|
||||
return lstItem
|
||||
|
||||
|
||||
def add_menu_item(params={}):
|
||||
url = create_param_url(params)
|
||||
if params.get('name'):
|
||||
if params.get('iconimage'):
|
||||
lstItem = create_list_item(params.get('name'), iconimage=params.get('iconimage'))
|
||||
else:
|
||||
lstItem = create_list_item(params.get('name'))
|
||||
xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]), url=url, listitem=lstItem, isFolder=True)
|
||||
else:
|
||||
display_error('add_menu_item : Fail to add item to menu')
|
||||
|
||||
|
||||
def add_menu_link(params={}):
|
||||
if params.get('name') and params.get('iconimage') and params.get('url') and \
|
||||
params.get('itemInfoLabels') and params.get('c_items'):
|
||||
url = params.get('url')
|
||||
lstItem = create_list_item(params.get('name'), iconimage=params.get('iconimage'),
|
||||
itemInfoLabels=params.get('itemInfoLabels'), c_items=params.get('c_items'),
|
||||
isPlayable=True)
|
||||
xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]), url=url, listitem=lstItem)
|
||||
else:
|
||||
display_error('add_menu_link : Fail to add item to menu')
|
||||
|
||||
|
||||
def end_of_directory(update=False):
|
||||
xbmcplugin.endOfDirectory(handle=int(sys.argv[1]), succeeded=True, updateListing=update) # , cacheToDisc=True)
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import xbmc
|
||||
import xbmcgui
|
||||
import xbmcplugin
|
||||
import xbmcaddon
|
||||
|
||||
import urllib
|
||||
import sys
|
||||
|
||||
from traceback import print_exc
|
||||
|
||||
|
||||
def get_addon():
|
||||
if hasattr(sys.modules["__main__"], "addon_id"):
|
||||
_id = sys.modules["__main__"].addon_id
|
||||
return xbmcaddon.Addon(id=_id)
|
||||
|
||||
|
||||
def get_translation(key):
|
||||
addon = get_addon()
|
||||
if addon:
|
||||
return addon.getLocalizedString(int(key))
|
||||
|
||||
|
||||
def get_settings(key):
|
||||
addon = get_addon()
|
||||
if addon:
|
||||
return addon.getSetting(key)
|
||||
|
||||
|
||||
def get_addon_dir():
|
||||
addon = get_addon()
|
||||
if addon:
|
||||
addonDir = addon.getAddonInfo("path")
|
||||
else:
|
||||
addonDir = xbmc.translatePath("special://profile/addon_data/")
|
||||
|
||||
return addonDir
|
||||
|
||||
|
||||
def display_error(msg):
|
||||
xbmc.executebuiltin("XBMC.Notification(%s, %s)" % (get_translation('30200').decode('utf-8'), msg))
|
||||
print msg
|
||||
print_exc(msg)
|
||||
|
||||
|
||||
def display_info(msg):
|
||||
xbmc.executebuiltin("XBMC.Notification(%s, %s, 3000, DefaultFolder.png)" % (get_translation('30300').encode('utf-8'),
|
||||
msg.encode('utf-8')))
|
||||
#print msg
|
||||
print_exc()
|
||||
|
||||
|
||||
def parse_params(param_str):
|
||||
param_dic = {}
|
||||
# Parameters are on the 3rd arg passed to the script
|
||||
param_str = sys.argv[2]
|
||||
if len(param_str) > 1:
|
||||
param_str = param_str.replace('?', '')
|
||||
|
||||
# Ignore last char if it is a '/'
|
||||
if param_str[len(param_str) - 1] == '/':
|
||||
param_str = param_str[0:len(param_str) - 2]
|
||||
|
||||
# Processing each parameter splited on '&'
|
||||
for param in param_str.split('&'):
|
||||
try:
|
||||
# Spliting couple key/value
|
||||
key, value = param.split('=')
|
||||
except:
|
||||
key = param
|
||||
value = ''
|
||||
|
||||
key = urllib.unquote_plus(key)
|
||||
value = urllib.unquote_plus(value)
|
||||
|
||||
# Filling dictionnary
|
||||
param_dic[key] = value
|
||||
|
||||
return param_dic
|
||||
|
||||
|
||||
def ask_user(content, title):
|
||||
keyboard = xbmc.Keyboard(content, title)
|
||||
keyboard.doModal()
|
||||
if keyboard.isConfirmed() and keyboard.getText():
|
||||
return keyboard.getText()
|
||||
return ""
|
||||
|
||||
|
||||
def create_param_url(param_dic, quote_plus=False):
|
||||
"""
|
||||
Create an plugin URL based on the key/value passed in a dictionary
|
||||
"""
|
||||
url = sys.argv[0]
|
||||
sep = '?'
|
||||
|
||||
try:
|
||||
for param in param_dic:
|
||||
if quote_plus:
|
||||
url = url + sep + urllib.quote_plus(param) + '=' + urllib.quote_plus(param_dic[param])
|
||||
else:
|
||||
url = "%s%s%s=%s" % (url, sep, param, param_dic[param])
|
||||
|
||||
sep = '&'
|
||||
except Exception as msg:
|
||||
display_error("create_param_url %s" % msg)
|
||||
url = None
|
||||
return url
|
||||
|
||||
|
||||
def create_list_item(name, itemInfoType="Video", itemInfoLabels=None, iconimage="DefaultFolder.png",
|
||||
c_items=None, isPlayable=False):
|
||||
lstItem = xbmcgui.ListItem(label=name, iconImage=iconimage, thumbnailImage=iconimage)
|
||||
|
||||
if c_items:
|
||||
lstItem.addContextMenuItems(c_items, replaceItems=True)
|
||||
|
||||
if itemInfoLabels:
|
||||
iLabels = itemInfoLabels
|
||||
else:
|
||||
iLabels = {"Title": name, }
|
||||
|
||||
lstItem.setInfo(type=itemInfoType, infoLabels=iLabels)
|
||||
if isPlayable:
|
||||
lstItem.setProperty('IsPlayable', "true")
|
||||
|
||||
return lstItem
|
||||
|
||||
|
||||
def add_menu_item(params={}):
|
||||
url = create_param_url(params)
|
||||
if params.get('name'):
|
||||
if params.get('iconimage'):
|
||||
lstItem = create_list_item(params.get('name'), iconimage=params.get('iconimage'))
|
||||
else:
|
||||
lstItem = create_list_item(params.get('name'))
|
||||
xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]), url=url, listitem=lstItem, isFolder=True)
|
||||
else:
|
||||
display_error('add_menu_item : Fail to add item to menu')
|
||||
|
||||
|
||||
def add_menu_link(params={}):
|
||||
if params.get('name') and params.get('iconimage') and params.get('url') and \
|
||||
params.get('itemInfoLabels') and params.get('c_items'):
|
||||
url = params.get('url')
|
||||
lstItem = create_list_item(params.get('name'), iconimage=params.get('iconimage'),
|
||||
itemInfoLabels=params.get('itemInfoLabels'), c_items=params.get('c_items'),
|
||||
isPlayable=True)
|
||||
xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]), url=url, listitem=lstItem)
|
||||
else:
|
||||
display_error('add_menu_link : Fail to add item to menu')
|
||||
|
||||
|
||||
def end_of_directory(update=False):
|
||||
xbmcplugin.endOfDirectory(handle=int(sys.argv[1]), succeeded=True, updateListing=update) # , cacheToDisc=True)
|
||||
|
|
|
|||
|
|
@ -1,40 +1,40 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
import sys
|
||||
|
||||
if hasattr(sys.modules["__main__"], "common_xbmc"):
|
||||
common_xbmc = sys.modules["__main__"].common_xbmc
|
||||
else:
|
||||
import common_xbmc
|
||||
|
||||
|
||||
class BaseMenuItem():
|
||||
|
||||
def __init__(self, name, action, iconimage="DefaultFolder.png"):
|
||||
self.params = {}
|
||||
self.params['name'] = name
|
||||
self.params['action'] = action
|
||||
self.params['iconimage'] = iconimage
|
||||
|
||||
def get(self, element):
|
||||
return self.params[element]
|
||||
|
||||
def add_to_menu(self):
|
||||
common_xbmc.add_menu_item(self.params)
|
||||
|
||||
|
||||
class BaseMenuLink(BaseMenuItem):
|
||||
|
||||
def __init__(self, name, url, action, iconimage="DefaultFolder.png"):
|
||||
BaseMenuItem.__init__(self, name, action, iconimage)
|
||||
self.params["url"] = url
|
||||
|
||||
def createVideoContextMenu(self):
|
||||
return ""
|
||||
|
||||
def create_info_labels(self):
|
||||
return ""
|
||||
|
||||
def add_to_menu(self):
|
||||
self.params["itemInfoLabels"] = self.create_info_labels()
|
||||
self.params["c_items"] = self.createVideoContextMenu()
|
||||
common_xbmc.add_menu_link(self.params)
|
||||
# -*- coding: utf-8 -*-
|
||||
import sys
|
||||
|
||||
if hasattr(sys.modules["__main__"], "common_xbmc"):
|
||||
common_xbmc = sys.modules["__main__"].common_xbmc
|
||||
else:
|
||||
import common_xbmc
|
||||
|
||||
|
||||
class BaseMenuItem():
|
||||
|
||||
def __init__(self, name, action, iconimage="DefaultFolder.png"):
|
||||
self.params = {}
|
||||
self.params['name'] = name
|
||||
self.params['action'] = action
|
||||
self.params['iconimage'] = iconimage
|
||||
|
||||
def get(self, element):
|
||||
return self.params[element]
|
||||
|
||||
def add_to_menu(self):
|
||||
common_xbmc.add_menu_item(self.params)
|
||||
|
||||
|
||||
class BaseMenuLink(BaseMenuItem):
|
||||
|
||||
def __init__(self, name, url, action, iconimage="DefaultFolder.png"):
|
||||
BaseMenuItem.__init__(self, name, action, iconimage)
|
||||
self.params["url"] = url
|
||||
|
||||
def createVideoContextMenu(self):
|
||||
return ""
|
||||
|
||||
def create_info_labels(self):
|
||||
return ""
|
||||
|
||||
def add_to_menu(self):
|
||||
self.params["itemInfoLabels"] = self.create_info_labels()
|
||||
self.params["c_items"] = self.createVideoContextMenu()
|
||||
common_xbmc.add_menu_link(self.params)
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ class Weboobmc():
|
|||
os.path.join(os.path.expanduser('~'), '.local', 'share')
|
||||
), 'weboob')
|
||||
icons_dir = os.path.join(datadir, 'icons')
|
||||
|
||||
|
||||
return os.path.join(icons_dir, '%s.png' % module)
|
||||
|
||||
def is_category(self, obj):
|
||||
|
|
|
|||
|
|
@ -1,72 +1,72 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
import sys
|
||||
import constants
|
||||
|
||||
from datetime import datetime, timedelta
|
||||
from base.menu import BaseMenuItem, BaseMenuLink
|
||||
|
||||
if hasattr(sys.modules["__main__"], "common_xbmc"):
|
||||
common_xbmc = sys.modules["__main__"].common_xbmc
|
||||
else:
|
||||
import common_xbmc
|
||||
|
||||
|
||||
class MenuItem(BaseMenuItem):
|
||||
params = {}
|
||||
|
||||
def __init__(self, name, action, iconimage="DefaultFolder.png", backend=''):
|
||||
BaseMenuItem.__init__(self, name, action, iconimage)
|
||||
self.params['backend'] = backend
|
||||
|
||||
|
||||
class MenuItemPath(MenuItem):
|
||||
|
||||
def __init__(self, collection, action=constants.DISPLAY_COLLECTION_MENU, iconimage="DefaultFolder.png"):
|
||||
MenuItem.__init__(self, collection.title, action, iconimage, collection.fullid.split('@')[-1])
|
||||
self.params["path"] = '/'.join(collection.split_path)
|
||||
|
||||
|
||||
class MenuItemVideo(BaseMenuLink):
|
||||
def __init__(self, video, iconimage="DefaultFolder.png"):
|
||||
name = '[%s] %s' % (video.backend, video.title)
|
||||
BaseMenuLink.__init__(self, name, video.url, constants.VIDEO,
|
||||
video.thumbnail.url if video.thumbnail.url else iconimage)
|
||||
self.video = video
|
||||
self.params["id"] = self.video.id
|
||||
|
||||
def createVideoContextMenu(self):
|
||||
cm = []
|
||||
|
||||
#Information
|
||||
cm.append((common_xbmc.get_translation('30110'), "XBMC.Action(Info)"))
|
||||
|
||||
#Téléchargement
|
||||
url = "%s?action=%s&id=%s&backend=%s" % (sys.argv[0], constants.DOWNLOAD, self.video.id, self.video.backend)
|
||||
cm.append((common_xbmc.get_translation('30100'), "XBMC.PlayMedia(%s)" % (url)))
|
||||
|
||||
return cm
|
||||
|
||||
def create_info_labels(self):
|
||||
date, year = self.format_date(self.video.date)
|
||||
|
||||
duration = 0
|
||||
if self.video.duration:
|
||||
duration = u'%s' % str(self.video.duration.total_seconds()/60) if isinstance(self.video.duration, timedelta) else self.video.duration
|
||||
|
||||
description = u'%s' % self.video.description
|
||||
|
||||
return {"Title": self.video.title,
|
||||
"Year": year,
|
||||
"Plot": description,
|
||||
"PlotOutline": description[0:30] if len(description) > 30 else description,
|
||||
"Director": self.video.author if self.video.author else 'Unknown',
|
||||
"Duration": duration,
|
||||
"Date": date}
|
||||
|
||||
def format_date(self, video_date):
|
||||
date = datetime.now().strftime("%d/%m/%Y")
|
||||
if video_date:
|
||||
date = video_date.strftime("%d/%m/%Y")
|
||||
|
||||
year = date.split('/')[-1]
|
||||
return date, year
|
||||
# -*- coding: utf-8 -*-
|
||||
import sys
|
||||
import constants
|
||||
|
||||
from datetime import datetime, timedelta
|
||||
from base.menu import BaseMenuItem, BaseMenuLink
|
||||
|
||||
if hasattr(sys.modules["__main__"], "common_xbmc"):
|
||||
common_xbmc = sys.modules["__main__"].common_xbmc
|
||||
else:
|
||||
import common_xbmc
|
||||
|
||||
|
||||
class MenuItem(BaseMenuItem):
|
||||
params = {}
|
||||
|
||||
def __init__(self, name, action, iconimage="DefaultFolder.png", backend=''):
|
||||
BaseMenuItem.__init__(self, name, action, iconimage)
|
||||
self.params['backend'] = backend
|
||||
|
||||
|
||||
class MenuItemPath(MenuItem):
|
||||
|
||||
def __init__(self, collection, action=constants.DISPLAY_COLLECTION_MENU, iconimage="DefaultFolder.png"):
|
||||
MenuItem.__init__(self, collection.title, action, iconimage, collection.fullid.split('@')[-1])
|
||||
self.params["path"] = '/'.join(collection.split_path)
|
||||
|
||||
|
||||
class MenuItemVideo(BaseMenuLink):
|
||||
def __init__(self, video, iconimage="DefaultFolder.png"):
|
||||
name = '[%s] %s' % (video.backend, video.title)
|
||||
BaseMenuLink.__init__(self, name, video.url, constants.VIDEO,
|
||||
video.thumbnail.url if video.thumbnail.url else iconimage)
|
||||
self.video = video
|
||||
self.params["id"] = self.video.id
|
||||
|
||||
def createVideoContextMenu(self):
|
||||
cm = []
|
||||
|
||||
#Information
|
||||
cm.append((common_xbmc.get_translation('30110'), "XBMC.Action(Info)"))
|
||||
|
||||
#Téléchargement
|
||||
url = "%s?action=%s&id=%s&backend=%s" % (sys.argv[0], constants.DOWNLOAD, self.video.id, self.video.backend)
|
||||
cm.append((common_xbmc.get_translation('30100'), "XBMC.PlayMedia(%s)" % (url)))
|
||||
|
||||
return cm
|
||||
|
||||
def create_info_labels(self):
|
||||
date, year = self.format_date(self.video.date)
|
||||
|
||||
duration = 0
|
||||
if self.video.duration:
|
||||
duration = u'%s' % str(self.video.duration.total_seconds()/60) if isinstance(self.video.duration, timedelta) else self.video.duration
|
||||
|
||||
description = u'%s' % self.video.description
|
||||
|
||||
return {"Title": self.video.title,
|
||||
"Year": year,
|
||||
"Plot": description,
|
||||
"PlotOutline": description[0:30] if len(description) > 30 else description,
|
||||
"Director": self.video.author if self.video.author else 'Unknown',
|
||||
"Duration": duration,
|
||||
"Date": date}
|
||||
|
||||
def format_date(self, video_date):
|
||||
date = datetime.now().strftime("%d/%m/%Y")
|
||||
if video_date:
|
||||
date = video_date.strftime("%d/%m/%Y")
|
||||
|
||||
year = date.split('/')[-1]
|
||||
return date, year
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
# Dummy file to make this directory a package.
|
||||
# Dummy file to make this directory a package.
|
||||
|
|
|
|||
|
|
@ -1,110 +1,110 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
import urllib
|
||||
|
||||
|
||||
def get_addon():
|
||||
pass
|
||||
|
||||
|
||||
def get_translation(key):
|
||||
translation = {'30000': 'Recherche',
|
||||
'30001': 'Recherche :',
|
||||
'30100': 'Télécharger',
|
||||
'30110': 'Information',
|
||||
'30200': 'Erreur!',
|
||||
'30300': 'Information',
|
||||
'30301': 'Lancement du téléchargement',
|
||||
'30302': 'Fichier téléchargé avec succès',
|
||||
'30551': 'Debut de la mise à jour',
|
||||
'30552': 'Weboob est maintenant à jour'}
|
||||
return translation.get(key)
|
||||
|
||||
|
||||
def get_addon_dir():
|
||||
return '/home/benjamin'
|
||||
|
||||
|
||||
def get_settings(key):
|
||||
settings = {'downloadPath': get_addon_dir(),
|
||||
'nbVideoPerBackend': '0',
|
||||
'nsfw': 'False'}
|
||||
return settings.get(key)
|
||||
|
||||
|
||||
def display_error(error):
|
||||
print "%s: %s" % ("ERROR", error)
|
||||
|
||||
|
||||
def display_info(msg):
|
||||
print "%s: %s" % ("INFO", msg)
|
||||
|
||||
|
||||
def parse_params(paramStr):
|
||||
|
||||
paramDic = {}
|
||||
# Parameters are on the 3rd arg passed to the script
|
||||
if len(paramStr) > 1:
|
||||
paramStr = paramStr.replace('?', '')
|
||||
|
||||
# Ignore last char if it is a '/'
|
||||
if paramStr[len(paramStr) - 1] == '/':
|
||||
paramStr = paramStr[0:len(paramStr) - 2]
|
||||
|
||||
# Processing each parameter splited on '&'
|
||||
for param in paramStr.split('&'):
|
||||
try:
|
||||
# Spliting couple key/value
|
||||
key, value = param.split('=')
|
||||
except:
|
||||
key = param
|
||||
value = ''
|
||||
|
||||
key = urllib.unquote_plus(key)
|
||||
value = urllib.unquote_plus(value)
|
||||
|
||||
# Filling dictionnary
|
||||
paramDic[key] = value
|
||||
return paramDic
|
||||
|
||||
|
||||
def ask_user(content, title):
|
||||
return raw_input(title)
|
||||
|
||||
|
||||
def create_param_url(paramsDic, quote_plus=False):
|
||||
|
||||
#url = sys.argv[0]
|
||||
url = ''
|
||||
sep = '?'
|
||||
|
||||
try:
|
||||
for param in paramsDic:
|
||||
if quote_plus:
|
||||
url = url + sep + urllib.quote_plus(param) + '=' + urllib.quote_plus(paramsDic[param])
|
||||
else:
|
||||
url = "%s%s%s=%s" % (url, sep, param, paramsDic[param])
|
||||
|
||||
sep = '&'
|
||||
except Exception, msg:
|
||||
display_error("create_param_url %s" % msg)
|
||||
url = None
|
||||
return url
|
||||
|
||||
|
||||
def add_menu_item(params={}):
|
||||
print '%s => "%s"' % (params.get('name'), create_param_url(params))
|
||||
|
||||
|
||||
def add_menu_link(params={}):
|
||||
print '[%s] %s (%s)' % (params.get('id'), params.get('name'), params.get('url'))
|
||||
#print params.get('itemInfoLabels')
|
||||
#print params.get('c_items')
|
||||
|
||||
|
||||
def end_of_directory(update=False):
|
||||
print '******************************************************'
|
||||
|
||||
|
||||
def download_video(url, name, dir='./'):
|
||||
print 'Downlaod a video %s from %s' % (name, url)
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import urllib
|
||||
|
||||
|
||||
def get_addon():
|
||||
pass
|
||||
|
||||
|
||||
def get_translation(key):
|
||||
translation = {'30000': 'Recherche',
|
||||
'30001': 'Recherche :',
|
||||
'30100': 'Télécharger',
|
||||
'30110': 'Information',
|
||||
'30200': 'Erreur!',
|
||||
'30300': 'Information',
|
||||
'30301': 'Lancement du téléchargement',
|
||||
'30302': 'Fichier téléchargé avec succès',
|
||||
'30551': 'Debut de la mise à jour',
|
||||
'30552': 'Weboob est maintenant à jour'}
|
||||
return translation.get(key)
|
||||
|
||||
|
||||
def get_addon_dir():
|
||||
return '/home/benjamin'
|
||||
|
||||
|
||||
def get_settings(key):
|
||||
settings = {'downloadPath': get_addon_dir(),
|
||||
'nbVideoPerBackend': '0',
|
||||
'nsfw': 'False'}
|
||||
return settings.get(key)
|
||||
|
||||
|
||||
def display_error(error):
|
||||
print "%s: %s" % ("ERROR", error)
|
||||
|
||||
|
||||
def display_info(msg):
|
||||
print "%s: %s" % ("INFO", msg)
|
||||
|
||||
|
||||
def parse_params(paramStr):
|
||||
|
||||
paramDic = {}
|
||||
# Parameters are on the 3rd arg passed to the script
|
||||
if len(paramStr) > 1:
|
||||
paramStr = paramStr.replace('?', '')
|
||||
|
||||
# Ignore last char if it is a '/'
|
||||
if paramStr[len(paramStr) - 1] == '/':
|
||||
paramStr = paramStr[0:len(paramStr) - 2]
|
||||
|
||||
# Processing each parameter splited on '&'
|
||||
for param in paramStr.split('&'):
|
||||
try:
|
||||
# Spliting couple key/value
|
||||
key, value = param.split('=')
|
||||
except:
|
||||
key = param
|
||||
value = ''
|
||||
|
||||
key = urllib.unquote_plus(key)
|
||||
value = urllib.unquote_plus(value)
|
||||
|
||||
# Filling dictionnary
|
||||
paramDic[key] = value
|
||||
return paramDic
|
||||
|
||||
|
||||
def ask_user(content, title):
|
||||
return raw_input(title)
|
||||
|
||||
|
||||
def create_param_url(paramsDic, quote_plus=False):
|
||||
|
||||
#url = sys.argv[0]
|
||||
url = ''
|
||||
sep = '?'
|
||||
|
||||
try:
|
||||
for param in paramsDic:
|
||||
if quote_plus:
|
||||
url = url + sep + urllib.quote_plus(param) + '=' + urllib.quote_plus(paramsDic[param])
|
||||
else:
|
||||
url = "%s%s%s=%s" % (url, sep, param, paramsDic[param])
|
||||
|
||||
sep = '&'
|
||||
except Exception as msg:
|
||||
display_error("create_param_url %s" % msg)
|
||||
url = None
|
||||
return url
|
||||
|
||||
|
||||
def add_menu_item(params={}):
|
||||
print '%s => "%s"' % (params.get('name'), create_param_url(params))
|
||||
|
||||
|
||||
def add_menu_link(params={}):
|
||||
print '[%s] %s (%s)' % (params.get('id'), params.get('name'), params.get('url'))
|
||||
#print params.get('itemInfoLabels')
|
||||
#print params.get('c_items')
|
||||
|
||||
|
||||
def end_of_directory(update=False):
|
||||
print '******************************************************'
|
||||
|
||||
|
||||
def download_video(url, name, dir='./'):
|
||||
print 'Downlaod a video %s from %s' % (name, url)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue