Ejemplo n.º 1
0
def add_Channel(idChannel, nameChannel, order):
    url = build_url({'mode': 'folder', 'channel': idChannel, 'param': 'none'})
    li = xbmcgui.ListItem(nameChannel,
                          iconImage=os.path.join(globalvar.MEDIA,
                                                 idChannel + ".png"))
    commands = []
    if order != 0:
        commands.append(
            (globalvar.LANGUAGE(30101).encode('utf-8'),
             'XBMC.RunPlugin(%s?mode=up&channel=%s&param=none&name=none)' %
             (sys.argv[0], order)))
    if order != len(globalvar.ordered_channels) - 1:
        commands.append(
            (globalvar.LANGUAGE(30102).encode('utf-8'),
             'XBMC.RunPlugin(%s?mode=down&channel=%s&param=none&name=none)' %
             (sys.argv[0], order)))
    commands.append(
        (globalvar.LANGUAGE(30103).encode('utf-8'),
         'XBMC.RunPlugin(%s?mode=hide&channel=%s&param=none&name=none)' %
         (sys.argv[0], order)))
    if len(globalvar.hidden_channels) > 0:
        commands.append(
            (globalvar.LANGUAGE(30104).encode('utf-8') +
             ' (%s)' % len(globalvar.hidden_channels),
             'XBMC.RunPlugin(%s?mode=unhide&channel=%s&param=none&name=none)' %
             (sys.argv[0], order)))
    li.addContextMenuItems(commands)

    xbmcplugin.addDirectoryItem(handle=addon_handle,
                                url=url,
                                listitem=li,
                                isFolder=True)
Ejemplo n.º 2
0
def buildShowsList(videos):
    for chan, video_url, video_title, video_icon, infoLabels, video_mode in videos:
        li = xbmcgui.ListItem(video_title,
                              iconImage=video_icon,
                              thumbnailImage=video_icon,
                              path=video_url)
        url = build_url({
            'mode': video_mode,
            'channel': chan,
            'param': video_url,
            'name': video_title
        })
        if video_mode == 'play':
            li.setInfo(type='Video', infoLabels=infoLabels)
            li.setProperty('IsPlayable', 'true')
            li.addContextMenuItems([
                (globalvar.LANGUAGE(33020).encode('utf-8'),
                 'XBMC.RunPlugin(%s?mode=dl&channel=%s&param=%s&name=%s)' %
                 (sys.argv[0], chan, urllib.quote_plus(video_url),
                  urllib.quote_plus(video_title)))
            ])
            xbmcplugin.addSortMethod(addon_handle, xbmcplugin.SORT_METHOD_NONE)
            xbmcplugin.setPluginCategory(addon_handle, 'episodes')
            xbmcplugin.setContent(addon_handle, 'episodes')
        xbmcplugin.addDirectoryItem(handle=addon_handle,
                                    url=url,
                                    listitem=li,
                                    isFolder=video_mode != 'play')
    if channel == 'favourites' and param == 'unseen':
        notify(globalvar.LANGUAGE(33026).encode('utf-8'), 0)
Ejemplo n.º 3
0
def list_shows(channel,folder):
  shows=[]
  
  if folder=='none':                                         
    shows.append( [channel,'1vw_WcP8zyswY1b5l4dck_rE9huXrMNxMnLjbgyzks-g', globalvar.LANGUAGE(33031).encode('utf-8'),'','shows'] )
    shows.append( [channel,'1KKPs4EPV65c1qjS74hK8VEJ32EAtX-rWGp2glydwLJI', globalvar.LANGUAGE(33032).encode('utf-8'),'','shows'] )
    shows.append( [channel,'1Xx4AAA4lHOogJYCT1ylnNj3fNi62XGwZxQPOwc_hwSQ', globalvar.LANGUAGE(33033).encode('utf-8'),'','shows'] )
  return shows
Ejemplo n.º 4
0
def add_favourite(channel, param, display):
    result = ''
    shows = list_shows('none', 'show_folder')
    for show in shows:
        if show[0] == channel and show[1] == param:
            result = globalvar.LANGUAGE(33004).encode('utf-8')
    if result == '':
        shows.append([channel, param, display, '', 'shows'])
        f1 = open(globalvar.FAVOURITES_FILE, 'w+')
        print >> f1, json.dumps({'favourites': shows})
        result = globalvar.LANGUAGE(33005).encode('utf-8')
    return result
Ejemplo n.º 5
0
def list_shows(channel, folder):
    shows = []
    if folder == 'none':
        shows.append([channel, 'shows', globalvar.LANGUAGE(33011), '', 'folder'])
        shows.append([channel, 'reportages', globalvar.LANGUAGE(33010), '', 'shows'])
    else:
        filePath = utils.downloadCatalog(url_catalog, '%s.xml' % (channel), False, {})
        fileCat = open(filePath).read().replace('\n', '').decode('utf-8')
        cat = re.findall('<key>' + folder + '</key> +<array> +(.+?) +</array>', fileCat)[0]
        shows_s = re.findall('<dict> +(.+?) +</dict>', cat)
        for show in shows_s:
            show_title, show_thumb, show_infos, show_url = parse_dict(show)
            shows.append([channel, show_url, show_title, show_thumb, 'shows'])
    return shows
Ejemplo n.º 6
0
def list_videos(channel, param):
    videos = []

    filePath = utils.downloadCatalog(
        'https://docs.google.com/spreadsheets/d/%s/pubhtml' % (param),
        '%s.HTML' % (param), False, {})
    html = open(filePath).read()
    match = re.compile(
        r'<td class="s16" dir="ltr">(.*?)</td><td class="s16" dir="ltr">(.*?)</td><td class="s15" dir="ltr">(.*?)</td>',
        re.DOTALL).findall(html)
    #match = re.compile(r'<td class="s16" dir="ltr">(.*?)</td><td class="s16" dir="ltr">(.*?)</td><td class="s15" dir="ltr">(.*?)
    if match:
        for title, path, cnt in match:
            pIndex = path.find('&amp;p=')
            chan = path[3:pIndex]
            url = path[pIndex + 7:]
            infoLabels = {
                "Title": title,
                "Plot": cnt + ' ' + globalvar.LANGUAGE(33039).encode('utf-8')
            }
            videos.append([
                chan, url, title,
                os.path.join(globalvar.MEDIA, chan + ".png"), infoLabels,
                'play'
            ])

    return videos
Ejemplo n.º 7
0
def rem_favourite(channel, param):
    result = ''
    shows = list_shows('none', 'show_folder')
    for show in shows:
        if show[0] == channel and show[1] == param:
            shows.remove(show)
            f1 = open(globalvar.FAVOURITES_FILE, 'w+')
            print >> f1, json.dumps({'favourites': shows})
            result = globalvar.LANGUAGE(33006).encode('utf-8')
    return result
Ejemplo n.º 8
0
def list_shows(channel, folder):
    shows = []
    if folder == 'none':
        shows.append([
            channel, 'show_folder',
            globalvar.LANGUAGE(33000).encode('utf-8'), '', 'folder'
        ])
        shows.append([
            channel, 'unseen',
            globalvar.LANGUAGE(33001).encode('utf-8'), '', 'shows'
        ])
    elif folder == 'show_folder':
        if os.path.exists(globalvar.FAVOURITES_FILE):
            #Read favourites
            fileFav = open(globalvar.FAVOURITES_FILE)
            jsonFav = json.loads(fileFav.read())
            showsFav = jsonFav['favourites']
            fileFav.close()
            for show in showsFav:
                shows.append([x.encode('utf-8') for x in show])
    return shows
Ejemplo n.º 9
0
def list_shows(channel,folder):
  shows=[]      
  if folder=='none':
    shows.append( [channel,'https://www.wat.tv/v4/appmobile/user/subscriptions/channel', 'My Channels','','folder'] ) 
    shows.append( [channel,'http://www.wat.tv/v4/appmobile/theme/61', 'Replay TV','','folder'] ) 
    shows.append( [channel,'http://www.wat.tv/v4/appmobile/theme/1', 'Musique','','folder'] )   
    shows.append( [channel,'http://www.wat.tv/v4/appmobile/theme/101', 'Humour','','folder'] )  
    shows.append( [channel,'http://www.wat.tv/v4/appmobile/theme/39', 'Cinema','','folder'] )  
    shows.append( [channel,'http://www.wat.tv/v4/appmobile/theme/173', 'Actu','','folder'] )  
    shows.append( [channel,'http://www.wat.tv/v4/appmobile/theme/213', 'Sport','','folder'] )  
    shows.append( [channel,'http://www.wat.tv/v4/appmobile/theme/153', 'Manga','','folder'] )  
    shows.append( [channel,'http://www.wat.tv/v4/appmobile/theme/127', 'Jeux Video','','folder'] )  
    
    shows.append( [channel,'http://www.wat.tv/v4/appmobile/channel/mostFollowed', globalvar.LANGUAGE(33040).encode('utf-8'),'','folder'] )
    shows.append( [channel,'http://www.wat.tv/v4/appmobile/channel/recommendation', globalvar.LANGUAGE(33041).encode('utf-8'),'','folder'] ) 
    shows.append( [channel,'http://www.wat.tv/v4/appmobile/channel/popular', globalvar.LANGUAGE(33042).encode('utf-8'),'','folder'] )
    shows.append( [channel,'http://www.wat.tv/v4/appmobile/tops/wat', 'Tops Wat.tv','','shows'] )
    shows.append( [channel,'http://www.wat.tv/v4/appmobile/tops/facebook', 'Tops Facebook','','shows'] )
    shows.append( [channel,'http://www.wat.tv/v4/appmobile/tops/twitter', 'Tops Twitter','','shows'] )
  
  else:
    fileVideos=urllib2.urlopen(folder).read()
    jsonData     = json.loads(fileVideos)
    if 'contents' in jsonData:
      jsonChans=jsonData ['contents']
    else:
      jsonChans=jsonData ['channels']
      
    for chan in jsonChans : 
      if 'channelIcon' in chan:
        img=chan['channelIcon']
      else:             
        img=chan['vignette']
        
      shows.append( [channel,chan['link'].replace('\\',''), chan['title'].encode('utf-8'),img,'shows'] ) 
    
  return shows  
Ejemplo n.º 10
0
def list_videos(channel, show_title):
    videos = []
    if show_title == 'unseen':
        if os.path.exists(globalvar.FAVOURITES_FILE):
            #Read favourites
            fileFav = open(globalvar.FAVOURITES_FILE)
            jsonfav = json.loads(fileFav.read())
            pDialog = xbmcgui.DialogProgress()
            ret = pDialog.create(globalvar.LANGUAGE(33002).encode('utf-8'), '')
            i = 1
            for show_folder in jsonfav['favourites']:
                show_folder = [x.encode('utf-8') for x in show_folder]
                pDialog.update((i - 1) * 100 / len(jsonfav['favourites']),
                               globalvar.LANGUAGE(33003).encode('utf-8') +
                               show_folder[2] + ' - ' + str(i) + '/' +
                               str(len(jsonfav['favourites'])))
                videos += (list_videos(show_folder[0], show_folder[1]))
                i += 1
            fileFav.close()
            pDialog.close()
    else:
        videos = globalvar.channels[channel][1].list_videos(
            channel, show_title)
    return videos
Ejemplo n.º 11
0
#-*- coding: utf-8 -*-
import xml.etree.ElementTree as ET
from resources.lib import utils
from resources.lib import globalvar
import os, os.path
import re

title = [globalvar.LANGUAGE(33030).encode('utf-8')]
img = ['mostviewed']
readyForUse = True


def list_shows(channel, folder):
    shows = []

    if folder == 'none':
        shows.append([
            channel, '1vw_WcP8zyswY1b5l4dck_rE9huXrMNxMnLjbgyzks-g',
            globalvar.LANGUAGE(33031).encode('utf-8'), '', 'shows'
        ])
        shows.append([
            channel, '1KKPs4EPV65c1qjS74hK8VEJ32EAtX-rWGp2glydwLJI',
            globalvar.LANGUAGE(33032).encode('utf-8'), '', 'shows'
        ])
        shows.append([
            channel, '1Xx4AAA4lHOogJYCT1ylnNj3fNi62XGwZxQPOwc_hwSQ',
            globalvar.LANGUAGE(33033).encode('utf-8'), '', 'shows'
        ])
    return shows

Ejemplo n.º 12
0
    channel = args['channel'][0]
    param = args['param'][0]
    if mode[0] == 'folder':
        for chan, folder_param, folder_title, folder_icon, mode in globalvar.channels[
                channel][1].list_shows(channel, param):
            url = build_url({
                'mode': mode,
                'channel': chan,
                'param': folder_param,
                'name': folder_title
            })
            li = xbmcgui.ListItem(folder_title, iconImage=folder_icon)
            # Contextual Menu
            if mode == 'shows' and channel != 'favourites':
                li.addContextMenuItems([
                    (globalvar.LANGUAGE(33021).encode('utf-8'),
                     'XBMC.RunPlugin(%s?mode=bkm&action=add&channel=%s&param=%s&display=%s)'
                     % (sys.argv[0], chan, urllib.quote_plus(folder_param),
                        urllib.quote_plus(folder_title))),
                ])
            if mode == 'shows' and channel == 'favourites':
                li.addContextMenuItems([
                    (globalvar.LANGUAGE(33022).encode('utf-8'),
                     'XBMC.RunPlugin(%s?mode=bkm&action=rem&channel=%s&param=%s&display=%s)'
                     % (sys.argv[0], chan, urllib.quote_plus(folder_param),
                        urllib.quote_plus(folder_title))),
                ])

            if mode == 'play':
                print 'play', folder_title
                li.setInfo(type='Video', infoLabels={"Title": folder_title})
Ejemplo n.º 13
0
utils.init()

if mode is None: 
    for item in globalvar.ordered_channels:
      add_Channel(item[0],globalvar.channels[item[0]][0],item[1])
    xbmcplugin.endOfDirectory(addon_handle)
else:    
    channel = args['channel'][0]
    param = args['param'][0]
    if mode[0]=='folder':        
        for chan,folder_param, folder_title, folder_icon, mode in globalvar.channels[channel][1].list_shows(channel,param):
            url = build_url({'mode': mode, 'channel': chan, 'param':folder_param ,'name' : folder_title})
            li = xbmcgui.ListItem(folder_title, iconImage=folder_icon)
            #Contextual Menu
            if mode=='shows' and channel!='favourites':
                li.addContextMenuItems([ (globalvar.LANGUAGE(33021).encode('utf-8'), 'XBMC.RunPlugin(%s?mode=bkm&action=add&channel=%s&param=%s&display=%s)' % 
                                          (sys.argv[0],chan,urllib.quote_plus(folder_param),urllib.quote_plus(folder_title))),
                                          ])
            if mode=='shows' and channel=='favourites':
                li.addContextMenuItems([ (globalvar.LANGUAGE(33022).encode('utf-8'), 'XBMC.RunPlugin(%s?mode=bkm&action=rem&channel=%s&param=%s&display=%s)' % 
                                        (sys.argv[0],chan,urllib.quote_plus(folder_param),urllib.quote_plus(folder_title))),
                                        ])
            
            if mode=='play':
                print 'play', folder_title
                li.setInfo( type='Video', infoLabels={ "Title": folder_title})            
                li.setProperty('IsPlayable', 'true')
                li.addContextMenuItems([(globalvar.LANGUAGE(33020).encode('utf-8'), 'XBMC.RunPlugin(%s?mode=dl&channel=%s&param=%s&name=%s)' % (sys.argv[0],chan,urllib.quote_plus(folder_param),urllib.quote_plus(folder_title)))])
            xbmcplugin.addDirectoryItem(handle=addon_handle, url=url,listitem=li, isFolder=mode!='play')
    elif mode[0]=='shows':     
        buildShowsList(globalvar.channels[channel][1].list_videos(channel,param))