/usr/share/weboob/plugin.video.videoobmc/resources/lib/test/common_test.py is in weboob 1.1-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 | # -*- coding: utf-8 -*-
from __future__ import print_function
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))
|