implemented infobar which shows: current page, result count and username if presented
[enigma2-plugins.git] / mytube / src / __init__.py
1 # -*- coding: ISO-8859-1 -*-
2
3 from Components.Language import language
4 from Tools.Directories import resolveFilename, SCOPE_PLUGINS
5 import gettext, hashlib
6
7 PluginLanguageDomain = "MyTube"
8 PluginLanguagePath = "Extensions/MyTube/locale"
9
10 def localeInit():
11         gettext.bindtextdomain(PluginLanguageDomain, resolveFilename(SCOPE_PLUGINS, PluginLanguagePath))
12
13 def _(txt):
14         t = gettext.dgettext(PluginLanguageDomain, txt)
15         if t == txt:
16                 #print "[MyTube] fallback to default translation for", txt
17                 t = gettext.gettext(txt)
18         return t
19
20 def bin2long(s):
21         return reduce( lambda x,y:(x<<8L)+y, map(ord, s))
22
23 def long2bin(l):
24         res = ""
25         for byte in range(128):
26                 res += chr((l >> (1024 - (byte + 1) * 8)) & 0xff)
27         return res
28
29 def rsa_pub1024(src, mod):
30         return long2bin(pow(bin2long(src), 65537, bin2long(mod)))
31         
32 def decrypt_block(src, mod):
33         if len(src) != 128 and len(src) != 202:
34                 return None
35         dest = rsa_pub1024(src[:128], mod)
36         hash = hashlib.sha1(dest[1:107])
37         if len(src) == 202:
38                 hash.update(src[131:192])       
39         result = hash.digest()
40         if result == dest[107:127]:
41                 return dest
42         return None
43
44 localeInit()
45 language.addCallback(localeInit)