def play(self, name, url=None, as_script=True, append_string=''): try: url = self.worker(name, url, append_string) if url is None: return title = control.infoLabel('listitem.title') if title == '': title = control.infoLabel('listitem.label') icon = control.infoLabel('listitem.icon') item = control.item(path=url, iconImage=icon, thumbnailImage=icon) try: item.setArt({'icon': icon}) except Exception: pass item.setInfo(type='Video', infoLabels={'title': title}) if as_script: control.player.play(url, item) else: directory.resolve(url, meta={'title': title}, icon=icon) except Exception: pass
def miscellany(self): self.data = self.misc_list() self.list = [] for item in self.data: if control.setting('lang_split') == '0': if 'Greek' in control.infoLabel('System.Language'): li = control.item(label=item['title'].partition(' - ')[2]) elif 'English' in control.infoLabel('System.Language'): li = control.item(label=item['title'].partition(' - ')[0]) else: li = control.item(label=item['title']) elif control.setting('lang_split') == '1': li = control.item(label=item['title'].partition(' - ')[0]) elif control.setting('lang_split') == '2': li = control.item(label=item['title'].partition(' - ')[2]) else: li = control.item(label=item['title']) li.setArt({ 'icon': item['icon'], 'fanart': control.addonInfo('fanart') }) url = item['url'] isFolder = True self.list.append((url, li, isFolder)) control.addItems(syshandle, self.list) control.directory(syshandle)
def kids_songs(self): self.data = [ { 'title': u'Zouzounia TV kids songs - Παιδικά Τραγούδια από τα Ζουζούνια', 'url': 'plugin://plugin.video.zouzounia.tv/', 'icon': 'https://yt3.ggpht.com/-zhH35bOsqec/AAAAAAAAAAI/AAAAAAAAAAA/LxUO6o-ZHPc/s256-c-k-no-mo-rj-c0xffffff/photo.jpg' } , { 'title': u'Greek songs with lyrics No.1 - Ελληνικά παιδικά τραγούδια με στίχους No.1', 'url': '{0}/channel/UCUmGu9Ncu5NeaEjwpLXW0PQ/'.format(YT_ADDON), 'icon': 'https://yt3.ggpht.com/-MVbyrB7DJrY/AAAAAAAAAAI/AAAAAAAAAAA/WjLUCzyX3zI/s256-c-k-no-mo-rj-c0xffffff/photo.jpg' } , { 'title': u'Greek songs with lyrics No.2 - Ελληνικά παιδικά τραγούδια με στίχους No.2', 'url': '{0}/channel/UCyENiZwRYzfXzbwP-Mxk9oA/'.format(YT_ADDON), 'icon': 'https://yt3.ggpht.com/-Jdrq5I2r5Tc/AAAAAAAAAAI/AAAAAAAAAAA/z7IPqFS7jqA/s256-c-k-no-mo-rj-c0xffffff/photo.jpg' } , { 'title': u'Greek Karaoke - Ελληνικό Καραόκε', 'url': '{0}/channel/UCp_0VMwvn5LeJMhtreBFIcA/playlist/PLP25S0MkvCeRlD0w1GXbitRL6sbyMscVi/'.format(YT_ADDON), 'icon': 'https://i.ytimg.com/vi/Iz5P8xJel-U/mqdefault.jpg' } , { 'title': u'Karaoke for English Learning - Μαθαίνω Αγγλικά με καραόκε', 'url': '{0}/channel/UCp_0VMwvn5LeJMhtreBFIcA/playlist/PLP25S0MkvCeSL-M5Q0qG3Eszj0I1O98bT/'.format(YT_ADDON), 'icon': 'https://i.ytimg.com/vi/L2atYpQ7Zbg/mqdefault.jpg' } , { 'title': u'Learning Music for Kids - Μαθαίνω Μουσική, για παιδιά', 'url': '{0}/channel/UCp_0VMwvn5LeJMhtreBFIcA/playlist/PLP25S0MkvCeRr5VH-HylSX89MHXQ_KyS0/'.format(YT_ADDON), 'icon': 'https://i.ytimg.com/vi/w5tF5J_BNfI/mqdefault.jpg' } ] for item in self.data: if control.setting('lang_split') == '0': if 'Greek' in control.infoLabel('System.Language'): li = control.item(label=item['title'].partition(' - ')[2]) elif 'English' in control.infoLabel('System.Language'): li = control.item(label=item['title'].partition(' - ')[0]) else: li = control.item(label=item['title']) elif control.setting('lang_split') == '1': li = control.item(label=item['title'].partition(' - ')[0]) elif control.setting('lang_split') == '2': li = control.item(label=item['title'].partition(' - ')[2]) else: li = control.item(label=item['title']) li.setArt({'icon': item['icon'], 'fanart': control.addonInfo('fanart')}) self.list.append((item['url'], li, True)) control.addItems(syshandle, self.list) control.directory(syshandle)
def changelog(): if control.setting('changelog_lang') == '0' and 'Greek' in control.infoLabel('System.Language'): change_txt = 'changelog.el.txt' elif (control.setting('changelog_lang') == '0' and 'Greek' not in control.infoLabel('System.Language')) or control.setting('changelog_lang') == '1': change_txt = 'changelog.txt' else: change_txt = 'changelog.el.txt' change_txt = control.join(control.addonPath, change_txt) control.dialog.textviewer(control.addonInfo('name') + ', ' + control.lang(30110), file_to_text(change_txt))
def setup(credentials): def call(): plugin_call = 'plugin://plugin.video.youtube/api/update/?enable=true' route = '{0}&client_id={1}&client_secret={2}&api_key={3}'.format( plugin_call, credentials[0], credentials[2], credentials[1]) control.execute('RunPlugin({0})'.format(route)) if int(YT_VERSION) >= 550 and control.setting('route543') == 'true': call() elif int(YT_VERSION) >= 543 and control.setting( 'route543') == 'true' and 'English' in control.infoLabel( 'System.Language'): call() else: if int(YT_VERSION) < 670: control.addon('plugin.video.youtube').setSetting( 'youtube.api.enable', 'true') control.addon('plugin.video.youtube').setSetting( 'youtube.api.id', credentials[0]) control.addon('plugin.video.youtube').setSetting( 'youtube.api.key', credentials[1]) control.addon('plugin.video.youtube').setSetting( 'youtube.api.secret', credentials[2]) control.infoDialog(message=control.lang(30015), time=3000)
def enable_iptv(): xbmc_path = control.join('special://xbmc', 'addons', 'pvr.iptvsimple') home_path = control.join('special://home', 'addons', 'pvr.iptvsimple') if control.condVisibility('Pvr.HasTVChannels') and ( path.exists(control.transPath(xbmc_path)) or path.exists(control.transPath(home_path)) ) and control.addon_details('pvr.iptvsimple').get('enabled'): control.infoDialog(message=control.lang(30407), time=4000) elif not path.exists(control.join(iptv_folder, 'settings.xml')): control.infoDialog(message=control.lang(30409), time=4000) else: if control.yesnoDialog(line1=control.lang(30406)): control.enable_addon('pvr.iptvsimple') if control.infoLabel( 'System.AddonVersion(xbmc.python)') == '2.24.0': control.execute('StartPVRManager')
def addon_version(addon_id): version = int( control.infoLabel('System.AddonVersion({0})'.format(addon_id)).replace( '.', '')) return version
def channel_id(): if control.setting('language') == '0': if control.infoLabel('System.Language') == 'Greek': main_id = 'UC9QSJuIBLUT2GbjgKymkTaQ' elif control.infoLabel('System.Language') == 'Japanese': main_id = 'UCGVTSfgmHJBzpq1gVq1ofhA' else: main_id = 'UCzsQf6eiWz4gIHgx0oYadXA' elif control.setting('language') == '2': main_id = 'UC9QSJuIBLUT2GbjgKymkTaQ' elif control.setting('language') == '3': main_id = 'UCGVTSfgmHJBzpq1gVq1ofhA' else: main_id = 'UCzsQf6eiWz4gIHgx0oYadXA' return main_id
def meta_viewer(url): heading = control.infoLabel('Listitem.Label') if control.setting('debug') == 'false': plot = cache.get(_plot, 96, url) else: plot = _plot(url) control.dialog.textviewer(heading=heading, text=plot)
def pin(): control.busy() title = control.infoLabel('ListItem.Title') pin_to_file(PINNED, title) control.infoDialog(control.lang(30338), time=750) control.idle()
def main(argv=None): if sys.argv: argv = sys.argv params = dict(parse_qsl(argv[2][1:])) action = params.get('action', 'root') if 'audio' in infoLabel('Container.FolderPath') and action in [ None, 'root' ]: action = 'radios' urldispatcher.dispatch(action, params)
def videos(link): if link == 'mgtow': if control.setting('language') == '0' and control.infoLabel( 'System.Language') == 'Greek': video_list = cache.get(item_list, 12, gr_id2) + cache.get( item_list, 12, gr_id3) + cache.get( youtube.youtube(key=key).playlist, 12, gr_id1) elif control.setting('language') == '0' and control.infoLabel( 'System.Language') != 'Greek' or control.setting( 'language') == '1': video_list = cache.get(item_list, 12, en_id1) + cache.get( item_list, 12, en_id2) else: video_list = cache.get(item_list, 12, gr_id2) + cache.get( item_list, 12, gr_id3) + cache.get( youtube.youtube(key=key).playlist, 12, gr_id1) else: video_list = cache.get(item_list, 12, link) for v in video_list: v.update({'action': 'play', 'isFolder': 'False'}) for item in video_list: bookmark = dict((k, v) for k, v in item.iteritems() if not k == 'next') bookmark['bookmark'] = item['url'] bm_cm = { 'title': 30006, 'query': { 'action': 'addBookmark', 'url': json.dumps(bookmark) } } refresh = {'title': 30008, 'query': {'action': 'refresh'}} cache_clear = {'title': 30005, 'query': {'action': 'cache_clear'}} item.update({'cm': [refresh, cache_clear, bm_cm]}) directory.add(video_list, content='videos')
def miscellany(self): if control.setting('debug') == 'true': self.data = cache.get(self.misc_list, int(control.setting('cache_period'))) else: self.data = cache.get(self.misc_list, 24) if self.data is None: log_debug('Misc channels list did not load successfully') return self.list = [] for item in self.data: if control.setting('lang_split') == '0': if 'Greek' in control.infoLabel('System.Language'): li = control.item(label=item['title'].partition(' - ')[2]) elif 'English' in control.infoLabel('System.Language'): li = control.item(label=item['title'].partition(' - ')[0]) else: li = control.item(label=item['title']) elif control.setting('lang_split') == '1': li = control.item(label=item['title'].partition(' - ')[0]) elif control.setting('lang_split') == '2': li = control.item(label=item['title'].partition(' - ')[2]) else: li = control.item(label=item['title']) li.setArt({ 'icon': item['icon'], 'fanart': control.addonInfo('fanart') }) url = item['url'] isFolder = True self.list.append((url, li, isFolder)) control.addItems(self.syshandle, self.list) control.directory(self.syshandle)
def changelog(get_text=False): if control.setting( 'changelog_lang') == '0' and 'Greek' in control.infoLabel( 'System.Language'): change_txt = 'changelog.el.txt' elif (control.setting('changelog_lang') == '0' and 'Greek' not in control.infoLabel('System.Language') ) or control.setting('changelog_lang') == '1': change_txt = 'changelog.en.txt' else: change_txt = 'changelog.el.txt' change_txt = control.join(control.addonPath, 'resources', 'texts', change_txt) if get_text: return py2_uni(file_to_text(change_txt)).partition(u'\n\n')[0] else: control.dialog.textviewer( control.addonInfo('name') + ', ' + control.lang(30110), file_to_text(change_txt))
def unpin(): control.busy() title = control.infoLabel('ListItem.Title') unpin_from_file(PINNED, title) control.sleep(100) control.refresh() control.infoDialog(control.lang(30338), time=750) control.idle()
def enable_proxy_module(): if control.condVisibility('System.HasAddon(service.streamlink.proxy)'): control.infoDialog(control.lang(30143)) else: if control.infoLabel('System.AddonVersion(xbmc.python)') == '2.24.0': control.execute('RunPlugin(plugin://service.streamlink.proxy/)') else: control.execute('InstallAddon(service.streamlink.proxy)')
def checkpoint(): if control.setting('first_time') == 'true' and 'CEMC' in control.infoLabel( 'System.FriendlyName') and control.exists( control.transPath( 'special://xbmc/addons/plugin.video.faros.on-air/')): set_a_setting('locale.keyboardlayouts', ['English QWERTY', 'Greek QWERTY']) weather_set_up() youtube_set_up() key_map_setup() if not bool_skin_setting('AutoScroll'): set_skin_setting('AutoScroll') if bool_skin_setting('HomeMenuNoMusicButton'): set_skin_setting('HomeMenuNoMusicButton', 'false') if bool_skin_setting('HomeMenuNoPVRRadioButton'): set_skin_setting('HomeMenuNoPVRRadioButton', 'false') if bool_skin_setting('HomeMenuNoPVRTVButton'): set_skin_setting('HomeMenuNoPVRTVButton', 'false') if bool_skin_setting('HomeMenuNoWeatherButton'): set_skin_setting('HomeMenuNoWeatherButton', 'false') if bool_skin_setting('HomeMenuNoPicturesButton'): set_skin_setting('HomeMenuNoWeatherButton', 'false') if not bool_skin_setting('homepageWeatherinfo'): set_skin_setting('homepageWeatherinfo') if not bool_skin_setting('RemoveFloorGraphics'): set_skin_setting('RemoveFloorGraphics') if not bool_skin_setting('HomepageHideSearchButton'): set_skin_setting('HomepageHideSearchButton') if not bool_skin_setting('ViewTypesSimplicity'): set_skin_setting('ViewTypesSimplicity') if not bool_skin_setting('HomepageHideSearchButton'): set_skin_setting('HomepageHideSearchButton') # lang_choice() # control.okDialog(heading=control.addonInfo('name'), line1=control.lang(30024)) control.setSetting('first_time', 'false') else: pass
def get_skin_resolution(): aspect_ratio = control.infoLabel('Skin.AspectRatio') xml = control.join(control.transPath('special://skin/'), 'addon.xml') with open(xml) as f: xml_file = f.read() res_extension_point = client.parseDOM(xml_file, 'extension', attrs={'point': 'xbmc.gui.skin'})[0] res_lines = res_extension_point.splitlines() try: skin_resolution = [res for res in res_lines if aspect_ratio in res][0] except IndexError: skin_resolution = res_lines[0] xval = int(re.findall(r'width="(\d{3,4})"', skin_resolution)[0]) yval = int(re.findall(r'height="(\d{3,4})"', skin_resolution)[0]) return xval, yval
def live(self): lang = 'www' if self.lang == 'en' else self.lang stream = self.resolve_live(lang=lang) if control.setting('quality_live') == '2' and int( control.infoLabel('System.AddonVersion({0})'.format('xbmc.python')).replace('.', '') ) >= 2260: dash = True manifest_type = 'hls' mimetype= 'application/vnd.apple.mpegurl' else: dash = False manifest_type = None mimetype = None directory.resolve( stream, meta={'title': 'Euronews'}, dash=dash, manifest_type=manifest_type, mimetype=mimetype )
(at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. ''' from __future__ import print_function from tulip import control, client from tulip.compat import quote import re, json YT_VERSION = control.infoLabel( 'System.AddonVersion(plugin.video.youtube)').partition('~')[0].replace( '.', '') def local(path): with open(path) as txtfile: f = txtfile.read() if not f: return f = f.strip('\r\n') if path.endswith('.txt') or len(f.splitlines()) in (3, 4): keys = f.splitlines()
def download(self, path, url): try: result = client.request(url) # f = os.path.splitext(urlparse.urlparse(url).path)[1][1:] f = os.path.join(path, url.rpartition('/')[2]) with open(f, 'wb') as subFile: subFile.write(result) dirs, files = control.listDir(path) if len(files) == 0: return if not f.lower().endswith('.rar'): control.execute('Extract("%s","%s")' % (f, path)) if control.infoLabel('System.Platform.Windows'): conversion = urllib.quote else: conversion = urllib.quote_plus if f.lower().endswith('.rar'): uri = "rar://{0}/".format(conversion(f)) dirs, files = control.listDir(uri) else: for i in range(0, 10): try: dirs, files = control.listDir(path) if len(files) > 1: break if control.aborted is True: break control.wait(1) except: pass filename = [ i for i in files if any( i.endswith(x) for x in ['.srt', '.sub']) ][0].decode('utf-8') subtitle = os.path.join(path, filename) if f.lower().endswith('.rar'): content = control.openFile(uri + filename).read() with open(subtitle, 'wb') as subFile: subFile.write(content) control.deleteFile(f) return subtitle else: control.deleteFile(f) return subtitle except: pass
def kodi_auth(): aspect_ratio = control.infoLabel('Skin.AspectRatio') def obtain_authorization(_cookie, _uh): data = { 'authorize': 'Allow', 'state': state, 'redirect_uri': redirect_uri, 'response_type': 'code', 'client_id': client_id, 'duration': 'permanent', 'scope': ' '.join(scope), 'uh': _uh } headers = client.request(api_link('authorize'), cookie=_cookie, post=data, redirect=False, output='headers') geturl = dict([ line.partition(': ')[::2] for line in str(headers).splitlines() ]).get('location') token = dict(parse_qsl(urlparse(geturl).query)).get('code') if not token: return get_tokens(code=token) class Prompt(pyxbmct.AddonDialogWindow): pyxbmct.skin.estuary = control.setting('pyxbmct.estuary') == 'true' if aspect_ratio == '4:3': geometry = (506, 380, 5, 5) else: geometry = (676, 380, 5, 5) def __init__(self, title, description, _cookie, _uh): super(Prompt, self).__init__(title) self.allow_button = None self.deny_button = None self.text_box = None self.text = description self.cookie = _cookie self.uh = _uh self.setGeometry(*self.geometry) self.set_controls() self.set_navigation() self.connect(pyxbmct.ACTION_NAV_BACK, self.close) def set_controls(self): # Text box self.text_box = pyxbmct.TextBox() self.placeControl(self.text_box, 0, 0, 4, 5) self.text_box.setText(self.text) self.text_box.autoScroll(1000, 1000, 1000) # Allow self.allow_button = pyxbmct.Button(control.lang(30150)) self.placeControl(self.allow_button, 4, 1) self.connect(self.allow_button, lambda: self.authorize()) # Deny self.deny_button = pyxbmct.Button(control.lang(30151)) self.placeControl(self.deny_button, 4, 3) self.connect(self.deny_button, self.close) def set_navigation(self): self.allow_button.controlRight(self.deny_button) self.deny_button.controlLeft(self.allow_button) self.setFocus(self.allow_button) def authorize(self): obtain_authorization(self.cookie, self.uh) self.close() class UserPass(pyxbmct.AddonDialogWindow): pyxbmct.skin.estuary = control.setting('pyxbmct.estuary') == 'true' if aspect_ratio == '4:3': geometry = (341, 296, 6, 1) else: geometry = (455, 296, 6, 1) def __init__(self, title): super(UserPass, self).__init__(title) self.username_label = None self.user_input = None self.password_label = None self.pass_input = None self.submit_button = None self.cancel_button = None self.setGeometry(*self.geometry) self.set_controls() self.set_navigation() self.connect(pyxbmct.ACTION_NAV_BACK, self.close) def set_controls(self): # Username label self.username_label = pyxbmct.Label(control.lang(30152)) self.placeControl(self.username_label, 0, 0) # Username input self.user_input = pyxbmct.Edit(control.lang(30152)) self.placeControl(self.user_input, 1, 0) # Password label self.password_label = pyxbmct.Label(control.lang(30153)) self.placeControl(self.password_label, 2, 0) # Password input self.pass_input = pyxbmct.Edit(control.lang(30153), isPassword=True) self.placeControl(self.pass_input, 3, 0) # Submit button self.submit_button = pyxbmct.Button(control.lang(30154)) self.placeControl(self.submit_button, 4, 0) self.connect(self.submit_button, lambda: self.submit(True)) # Cancel button self.cancel_button = pyxbmct.Button(control.lang(30064)) self.placeControl(self.cancel_button, 5, 0) self.connect(self.cancel_button, self.close) def set_navigation(self): self.user_input.controlDown(self.pass_input) self.pass_input.controlUp(self.user_input) self.pass_input.controlDown(self.submit_button) self.submit_button.controlUp(self.pass_input) self.submit_button.controlDown(self.cancel_button) self.cancel_button.controlUp(self.submit_button) self.setFocus(self.user_input) def credentials(self): return self.user_input.getText(), self.pass_input.getText() def submit(self, _submitted=False): if _submitted: self.close() return True userpass_window = UserPass(control.name()) userpass_window.doModal() username, password = userpass_window.credentials() if not username or not password: return login_url = base_link(True) + '/api/login/' + username data = { 'form_is_compact': 'true', 'dest': authorization_link(True), 'passwd': password, 'user': username, 'rem': 'on', 'api_type': 'json', 'op': 'login' } del userpass_window cookie = client.request(login_url, close=False, post=data, output='cookie') html = client.request(authorization_link(True), cookie=cookie) try: uh = client.parseDOM(html, 'input', attrs={'name': 'uh'}, ret='value')[0] permissions = client.parseDOM(html, 'div', attrs={'class': 'access-permissions'})[0] notice = client.parseDOM(html, 'p', attrs={'class': 'notice'})[0] text = client.replaceHTMLCodes( client.stripTags(permissions + '[CR]' + notice)) text = substitute(r'([.:]) ?', r'\1[CR]', text).partition('[CR]') prompt_window = Prompt(title=text[0], description=text[2], _cookie=cookie, _uh=uh) prompt_window.doModal() del prompt_window except IndexError: control.okDialog(control.name(), control.lang(30114))
def educational(self): self.data = [{ 'title': u'Learn about animals - Μάθε για τα ζώα', 'url': '{0}/channel/UCsKQX1G7XQO2a5nD9nrse-Q/playlist/PL7Adbo89X3LRboPyGr30sIRMnc20C77ui/' .format(YT_ADDON), 'icon': 'https://i.ytimg.com/vi/_fDdVYJA9Vk/mqdefault.jpg' }, { 'title': u'Secondary school education - Εκπαίδευση Δημοτικού Σχολείου', 'url': '{0}/channel/UCsKQX1G7XQO2a5nD9nrse-Q/playlist/PL7Adbo89X3LQvxn7RyUySvQy6C6hTUTXf/' .format(YT_ADDON), 'icon': 'https://i.ytimg.com/vi/isxjo7M2h74/mqdefault.jpg' }, { 'title': u'Sexual Education for children - Σεξουαλική Αγωγή για παιδιά', 'url': '{0}/channel/UCsKQX1G7XQO2a5nD9nrse-Q/playlist/PL7Adbo89X3LRy-LRQEeRdT_kf5iFdofsu/' .format(YT_ADDON), 'icon': 'https://i.ytimg.com/vi/l9gN1F6S3bc/mqdefault.jpg' }, { 'title': u'World\'s Seven Ancient Miracles - Τα Επτά Θαύματα του Αρχαίου Κόσμου', 'url': '{0}/channel/UCp_0VMwvn5LeJMhtreBFIcA/playlist/PLP25S0MkvCeThKG7GK1k2DRgB5im-vPHc/' .format(YT_ADDON), 'icon': 'https://i.ytimg.com/vi/5nEDQ_jYJIo/mqdefault.jpg' }, { 'title': u'The land of Knowledge - Η Χώρα των Γνώσεων', 'url': '{0}/channel/UCp_0VMwvn5LeJMhtreBFIcA/playlist/PLP25S0MkvCeS-ZVlk0vgNdx5igsFvYN8s/' .format(YT_ADDON), 'icon': 'https://i.ytimg.com/vi/K-Ba9l2uDDk/mqdefault.jpg' }, { 'title': u'Ancient Egypt - Αρχαία Αίγυπτος', 'url': '{0}/channel/UCp_0VMwvn5LeJMhtreBFIcA/playlist/PLP25S0MkvCeTrRcdIHjtziNEkqPqalUOa/' .format(YT_ADDON), 'icon': 'https://i.ytimg.com/vi/pV8EMy8gaXI/mqdefault.jpg' }, { 'title': u'Explorers & Seafarers - Εξερευνητές και Θαλασσοπόροι', 'url': '{0}/channel/UCp_0VMwvn5LeJMhtreBFIcA/playlist/PLP25S0MkvCeQRBb7ayyynWgYEUbkQKPpJ/' .format(YT_ADDON), 'icon': 'https://i.ytimg.com/vi/SPdnnVNZgwc/mqdefault.jpg' }, { 'title': u'Mini Encyclopaedia - Μικρή Εγκυκλοπαίδεια', 'url': '{0}/channel/UCp_0VMwvn5LeJMhtreBFIcA/playlist/PLP25S0MkvCeTLMi1bFqLC_cn5ZAtqSvlV/' .format(YT_ADDON), 'icon': 'https://i.ytimg.com/vi/o31_SNQFYhc/mqdefault.jpg' }, { 'title': u'Miscellaneous Documentaties - Διάφορα Ντοκυμαντέρ', 'url': '{0}/channel/UCp_0VMwvn5LeJMhtreBFIcA/playlist/PLP25S0MkvCeRY94Yga82ZYsPJ9Xbe3OiZ/' .format(YT_ADDON), 'icon': 'https://i.ytimg.com/vi/Vf_o_Q5ZQRg/mqdefault.jpg' }, { 'title': u'Learn Ancient Greek - Μάθετε Αρχαία Ελληνικά', 'url': '{0}/channel/UC5quWsvOBNUaR-Duv3K-JFA/playlist/PLxqCshQO3A1HnlHwxda3wX_kzY-C0gpZq/' .format(YT_ADDON), 'icon': 'https://i.ytimg.com/vi/st01jb_Xb7g/mqdefault.jpg' }, { 'title': u'Drawings - Ζωγραφιές', 'url': '{0}/channel/UC5quWsvOBNUaR-Duv3K-JFA/playlist/PLxqCshQO3A1FmjzGXbfIjTSXcysLfPfKM/' .format(YT_ADDON), 'icon': 'https://i.ytimg.com/vi/GdiLSXePno8/mqdefault.jpg' }] for item in self.data: if control.setting('lang_split') == '0': if 'Greek' in control.infoLabel('System.Language'): li = control.item(label=item['title'].partition(' - ')[2]) elif 'English' in control.infoLabel('System.Language'): li = control.item(label=item['title'].partition(' - ')[0]) else: li = control.item(label=item['title']) elif control.setting('lang_split') == '1': li = control.item(label=item['title'].partition(' - ')[0]) elif control.setting('lang_split') == '2': li = control.item(label=item['title'].partition(' - ')[2]) else: li = control.item(label=item['title']) li.setArt({ 'icon': item['icon'], 'fanart': control.addonInfo('fanart') }) self.list.append((item['url'], li, True)) control.addItems(syshandle, self.list) control.directory(syshandle)
def i18n(): lang = 'el_GR' if 'Greek' in control.infoLabel( 'System.Language') else 'en_GB' return lang
def resolve(url, meta=None, icon=None, dash=False, manifest_type=None, inputstream_type='adaptive', headers=None, mimetype=None, resolved_mode=True, live=False): """ Prepares a resolved url into a listitem for playback :param url: Requires a string or unicode, append required urlencoded headers with pipe | :param meta: a dictionary with listitem keys: values :param icon: String :param dash: Boolean :param manifest_type: String :param inputstream_type: String 99.9% of the time it is adaptive :param headers: dictionary or urlencoded string :param mimetype: String :return: None """ from tulip.init import syshandle # Fail gracefully instead of making Kodi complain. if url is None: from kodi_six.xbmc import log log('URL was not provided, failure to resolve stream') return if not headers and '|' in url: url, sep, headers = url.rpartition('|') elif headers: if isinstance(headers, basestring): if headers.startswith('|'): headers = headers[1:] elif isinstance(headers, dict): headers = urlencode(headers) if not dash and headers: url = '|'.join([url, headers]) item = control.item(path=url) if icon is not None: item.setArt({'icon': icon, 'thumb': icon}) if meta is not None: item.setInfo(type='Video', infoLabels=meta) krypton_plus = int( control.infoLabel('System.AddonVersion(xbmc.python)').replace( '.', '')) >= 2250 try: isa_enabled = control.addon_details('inputstream.adaptive').get( 'enabled') except KeyError: isa_enabled = False if dash and krypton_plus and isa_enabled: if not manifest_type: manifest_type = 'mpd' if not mimetype: mimetype = 'application/xml+dash' item.setContentLookup(False) item.setMimeType('{0}'.format(mimetype)) item.setProperty('inputstreamaddon', 'inputstream.{}'.format(inputstream_type)) item.setProperty( 'inputstream.{0}.manifest_type'.format(inputstream_type), manifest_type) if headers: item.setProperty( "inputstream.{0}.stream_headers".format(inputstream_type), headers) elif mimetype: item.setContentLookup(False) item.setMimeType('{0}'.format(mimetype)) if dash and live: item.setProperty( 'inputstream.{}.manifest_update_parameter'.format( inputstream_type), '&start_seq=$START_NUMBER$') if resolved_mode: control.resolve(syshandle, True, item) else: control.player().play(url, item)
def cartoon_collection(self): self.data = [{ 'title': u'Classical Films - Κλασσικά Κινηματογραφημένα', 'url': '{0}/channel/UCsKQX1G7XQO2a5nD9nrse-Q/playlist/PLF0A5359586D57FE8/' .format(YT_ADDON), 'icon': 'https://i.ytimg.com/vi/X9RxumkELfE/mqdefault.jpg' }, { 'title': u'Mythology - Μυθολογία', 'url': '{0}/channel/UCsKQX1G7XQO2a5nD9nrse-Q/playlist/PL3E1C926284F12F32/' .format(YT_ADDON), 'icon': 'https://i.ytimg.com/vi/kpd-Z_VK6Jc/mqdefault.jpg' }, { 'title': u'Aesop\'s Fables - Αισώπου Μύθοι', 'url': '{0}/channel/UCsKQX1G7XQO2a5nD9nrse-Q/playlist/PL4FF9F773D3596E60/' .format(YT_ADDON), 'icon': 'https://i.ytimg.com/vi/Gkr-pV_gY48/mqdefault.jpg' }, { 'title': u'Greek Fairy Tales - Ελληνικά Παραμύθια', 'url': '{0}/channel/UC9VmWb5Wd5sc4E4k1CevEug/'.format(YT_ADDON), 'icon': 'https://yt3.ggpht.com/-n8KoGQ6U_zc/AAAAAAAAAAI/AAAAAAAAAAA/SoUWvy5-Tb8/s256-c-k-no-mo-rj-c0xffffff/photo.jpg' }, { 'title': u'Fairy Tales & Songs - Παραμύθια και Τραγούδια', 'url': '{0}/channel/UCClAFTnbGditvz9_7_7eumw/playlists/'.format(YT_ADDON), 'icon': 'https://yt3.ggpht.com/-mBPhzUcDIHM/AAAAAAAAAAI/AAAAAAAAAAA/pNQi44zsLq8/s256-c-k-no-mo-rj-c0xffffff/photo.jpg' }, { 'title': u'Collection Miscellaneous - Συλλογή Διάφορα', 'url': '{0}/channel/UCsKQX1G7XQO2a5nD9nrse-Q/playlist/PL4075DA390F6E82B1/' .format(YT_ADDON), 'icon': 'https://i.ytimg.com/vi/MPtZ_VHNg34/mqdefault.jpg' }] for i in self.data: i['url'] = '?'.join( [i['url'], 'addon_id={}'.format(control.addonInfo('id'))]) additional = { 'title': u'Various full length movies - Διάφορες ταινίες πλήρους μήκους', 'url': '{0}?action={1}'.format(sysaddon, 'cartoon_various'), 'icon': iconname('kids') } if control.setting('show_alt_vod') == 'true': self.data.insert(0, additional) for item in self.data: if control.setting('lang_split') == '0': if 'Greek' in control.infoLabel('System.Language'): li = control.item(label=item['title'].partition(' - ')[2]) elif 'English' in control.infoLabel('System.Language'): li = control.item(label=item['title'].partition(' - ')[0]) else: li = control.item(label=item['title']) elif control.setting('lang_split') == '1': li = control.item(label=item['title'].partition(' - ')[0]) elif control.setting('lang_split') == '2': li = control.item(label=item['title'].partition(' - ')[2]) else: li = control.item(label=item['title']) li.setArt({ 'icon': item['icon'], 'fanart': control.addonInfo('fanart') }) self.list.append((item['url'], li, True)) control.addItems(syshandle, self.list) control.directory(syshandle)
def root(self): self.list = [{ 'title': control.lang(30001), 'action': 'live', 'icon': 'live.jpg' }, { 'title': control.lang(30036), 'action': 'play', 'isFolder': 'False', 'url': self.radio_url, 'icon': 'radio.png', 'fanart': control.join(control.addonPath, 'resources', 'media', 'bgradio.jpg') }, { 'title': control.lang(30002), 'action': 'videos', 'icon': 'youtube.png' }, { 'title': control.lang(30003), 'action': 'playlist', 'url': 'PL0cttCfQzkdtUFNDIHozh_EpVSUYwCVuI', 'icon': 'newspapers.png' }, { 'title': control.lang(30004), 'action': 'playlist', 'url': 'PL0cttCfQzkduInQQt3nCEKYValRROk1AV', 'icon': 'users.png' }, { 'title': control.lang(30005), 'action': 'playlist', 'url': 'PL0cttCfQzkdskGTTd3pLvUVKmlK8UyK3J', 'icon': 'diet.png' }, { 'title': control.lang(30006), 'action': 'playlist', 'url': 'PL0cttCfQzkdve608IsDG2jHqQ2AwAB4rm', 'icon': 'sports.png' }, { 'title': control.lang(30007), 'action': 'playlist', 'url': 'PL0cttCfQzkduVZzwQZyAXOgkL_2CRCBlC', 'icon': 'culture.png' }, { 'title': control.lang(30008), 'action': 'playlist', 'url': 'PL0cttCfQzkdsgy5MDvGyl_Qsw7bKKq7V9', 'icon': 'events.png' }, { 'title': control.lang(30009), 'action': 'playlist', 'url': 'PL0cttCfQzkdvjJGEFQsNvQSOXaFA6jFde', 'icon': 'world.png' }, { 'title': control.lang(30010), 'action': 'playlist', 'url': 'PL0cttCfQzkdtnlBmYgZM75dVPbN3V6YsP', 'icon': 'doctor.png' }, { 'title': control.lang(30013), 'action': 'favourites' if 'CEMC' in control.infoLabel('System.FriendlyName') else 'bookmarks', 'icon': 'favourites.png' }, { 'title': control.lang(30017), 'action': 'search', 'icon': 'search.png' }, { 'title': control.lang(30025), 'action': 'weather', 'icon': 'weather.png' }, { 'title': control.lang(30032), 'action': 'external_links', 'icon': 'external.png' }, { 'title': control.lang(30037), 'action': 'presentation', 'icon': control.addonInfo('icon'), 'isFolder': 'False', 'isPlayable': 'False' }, { 'title': control.lang(30012), 'action': 'settings', 'icon': 'settings.png', 'isFolder': 'False', 'isPlayable': 'False' }, { 'title': control.lang(30018), 'action': 'quit_kodi', 'icon': 'quit.png', 'isFolder': 'False', 'isPlayable': 'False' }] if control.setting('show_exit_button') == 'false': self.list = [ d for d in self.list if d.get('action') != 'quit_kodi' ] if not get_weather_bool()[0] and not get_weather_bool()[1]: self.list = [d for d in self.list if d.get('action') != 'weather'] for item in self.list: cache_clear = {'title': 30015, 'query': {'action': 'cache_clear'}} refresh_cm = {'title': 30022, 'query': {'action': 'refresh'}} item.update({'cm': [cache_clear, refresh_cm]}) control.set_view_mode('500') control.sleep(50) directory.add(self.list, content='videos') control.wait(1) checkpoint()
def run(self, query=None): if not 'Greek' in str(langs).split(','): control.directory(syshandle) control.infoDialog(control.lang(32002).encode('utf-8')) return if query is None: title = control.infoLabel('VideoPlayer.Title') if re.search(r'[^\x00-\x7F]+', title) is not None: title = control.infoLabel('VideoPlayer.OriginalTitle') year = control.infoLabel('VideoPlayer.Year') tvshowtitle = control.infoLabel('VideoPlayer.TVshowtitle') season = control.infoLabel('VideoPlayer.Season') episode = control.infoLabel('VideoPlayer.Episode') if 's' in episode.lower(): season, episode = '0', episode[-1:] if not tvshowtitle == '': # episode query = '%s S%02dE%02d' % (tvshowtitle, int(season), int(episode)) elif not year == '': # movie query = '%s (%s)' % (title, year) else: # file query, year = getCleanMovieTitle(title) if not year == '': query = '%s (%s)' % (query, year) self.query = query threads = [] threads.append(workers.Thread(self.xsubstv)) threads.append(workers.Thread(self.subzxyz)) threads.append(workers.Thread(self.subtitlesgr)) [i.start() for i in threads] for i in range(0, 10 * 2): try: is_alive = [x.is_alive() for x in threads] if all(x == False for x in is_alive): break if control.aborted is True: break control.sleep(500) except: pass if len(self.list) == 0: control.directory(syshandle) return f = [] f += [i for i in self.list if i['source'] == 'xsubstv'] f += [i for i in self.list if i['source'] == 'subzxyz'] f += [i for i in self.list if i['source'] == 'subtitlesgr'] self.list = f for i in self.list: try: if i['source'] == 'subzxyz': i['name'] = '[subzxyz] %s' % i['name'] elif i['source'] == 'xsubstv': i['name'] = '[xsubstv] %s' % i['name'] except: pass for i in self.list: try: name, url, source, rating = i['name'], i['url'], i[ 'source'], i['rating'] u = {'action': 'download', 'url': url, 'source': source} u = '%s?%s' % (sysaddon, urllib.urlencode(u)) item = control.item(label='Greek', label2=name, iconImage=str(rating), thumbnailImage='el') item.setProperty('sync', 'false') item.setProperty('hearing_imp', 'false') control.addItem(handle=syshandle, url=u, listitem=item, isFolder=False) except: pass control.directory(syshandle)
def read_plot(): heading = control.infoLabel('Listitem.Title') plot = control.infoLabel('Listitem.Plot') control.dialog.textviewer(heading=heading, text=plot)
def download(self, path, url): try: url = re.findall(r'/(\d+)/', url + '/', re.I)[-1] url = ''.join([self.download_link, '/getp.php?id={0}'.format(url)]) url = client.request(url, output='geturl', timeout=control.setting('timeout')) req = Request(url) req.add_header('User-Agent', randomagent()) opener = urlopen(req) data = opener.read() zip_file = zipfile.ZipFile(BytesIO(data)) opener.close() files = zip_file.namelist() files = [i for i in files if i.startswith('subs/')] srt = [i for i in files if i.endswith(('.srt', '.sub'))] archive = [i for i in files if i.endswith(('.rar', '.zip'))] if len(srt) > 0: if len(srt) > 1: srt = multichoice(srt) else: srt = srt[0] result = zip_file.open(srt).read() subtitle = basename(srt) try: subtitle = control.join(path, subtitle.decode('utf-8')) except Exception: subtitle = control.join(path, subtitle) with open(subtitle, 'wb') as subFile: subFile.write(result) return subtitle elif len(archive) > 0: if len(archive) > 1: archive = multichoice(archive) else: archive = archive[0] result = zip_file.open(archive).read() f = control.join(path, os_split(url)[1]) with open(f, 'wb') as subFile: subFile.write(result) dirs, files = control.listDir(path) if len(files) == 0: return if zipfile.is_zipfile(f): zipped = zipfile.ZipFile(f) zipped.extractall(path) if not zipfile.is_zipfile(f): if control.infoLabel('System.Platform.Windows'): uri = "rar://{0}/".format(quote(f)) else: uri = "rar://{0}/".format(quote_plus(f)) dirs, files = control.listDir(uri) else: dirs, files = control.listDir(path) if dirs and not zipfile.is_zipfile(f): for dir in dirs: _dirs, _files = control.listDir(control.join(uri, dir)) [files.append(control.join(dir, i)) for i in _files] if _dirs: for _dir in _dirs: _dir = control.join(_dir, dir) __dirs, __files = control.listDir( control.join(uri, _dir)) [ files.append(control.join(_dir, i)) for i in __files ] filenames = [i for i in files if i.endswith(('.srt', '.sub'))] filename = multichoice(filenames) try: filename = filename.decode('utf-8') except Exception: pass if not control.exists(control.join( path, os_split(filename)[0])) and not zipfile.is_zipfile(f): control.makeFiles(control.join(path, os_split(filename)[0])) subtitle = control.join(path, filename) if not zipfile.is_zipfile(f): with closing(control.openFile(uri + filename)) as fn: try: output = bytes(fn.readBytes()) except Exception: output = bytes(fn.read()) content = output.decode('utf-16') with closing(control.openFile(subtitle, 'w')) as subFile: subFile.write(bytearray(content.encode('utf-8'))) fileparts = os_split(subtitle)[1].split('.') # noinspection PyTypeChecker result = control.join( os_split(subtitle)[0], 'subtitles.' + fileparts[len(fileparts) - 1]) control.rename(subtitle, result) return result except Exception as e: _, __, tb = sys.exc_info() print(traceback.print_tb(tb)) log_debug( 'Subtitles.gr subtitle download failed for the following reason: ' + str(e)) return