示例#1
0
def open_genre(_id, page):
    page = int(page)
    req = requests.get(
        API +
        '/series/list/{0}/page/{1}/perPage/100'.format(_id, page)).json()

    items = []
    for s in req['series']:
        label = s['heb']
        path = plugin.url_for('open_series',
                              sid=s['id'],
                              title=s['heb'].encode('utf8'))
        desc = s['description'].replace('<br />', '\n')
        items.append(
            sdarot.make_item(label,
                             path,
                             desc,
                             POSTER_PREFIX + s['poster'],
                             False,
                             fav=build_fav(label, path, s['id'], '0'),
                             year=s['year']))

    if not req['pages']['page'] == req['pages']['totalPages']:
        items.append(
            sdarot.make_item(
                '[COLOR yellow]{0}[/COLOR]'.format('הבא'),
                plugin.url_for('open_genre', _id=_id, page=page + 1), '',
                FANART, False))

    sdarot.set_dir(items, 504, 'tvshows', plugin)
    return []
示例#2
0
def open_series(sid, title):
    req = requests.get(API + '/series/info/{0}'.format(sid),
                       headers=HEADERS).json()
    serie = req['serie']

    episodes = serie['episodes']
    if not episodes:
        return []

    items = []
    for season in sorted(episodes.keys(), key=int):
        label = u'עונה {0}'.format(season)
        path = plugin.url_for('open_season',
                              sid=sid,
                              se=season,
                              title=title,
                              title_eng=serie['eng'].encode('utf8'))
        desc = serie['description'].replace('<br />', '\n')
        items.append(
            sdarot.make_item(label,
                             path,
                             desc,
                             POSTER_PREFIX + sid + '.jpg',
                             False,
                             fav=build_fav(label, path, sid, '0'),
                             genres=req['genres']))

    sdarot.set_dir(items, 504, 'episodes', plugin)
    return []
示例#3
0
def tracking_list():
    cookie = sdarot.get_user_cookie()
    if cookie:
        req = requests.get(API + '/tracking/list',
                           cookies=cookie,
                           headers=HEADERS)
        items = [{
            'label':
            u'{0}-{1}-{2}'.format(
                s['heb'], s['eng'],
                u'צפית ב {0} מתוך {1} פרקים'.format(s['watched'], s['total'])),
            'path':
            plugin.url_for('open_series',
                           sid=s['serieID'],
                           title=s['heb'].encode('utf8')),
            'icon':
            POSTER_PREFIX + s['poster'],
            'thumbnail':
            POSTER_PREFIX + s['poster'],
            'properties': {
                'Fanart_Image': FANART
            },
            'context_menu':
            [('הסרה ממעקב', 'XBMC.Container.Update({0})'.format(
                plugin.url_for('delete_tracking',
                               sid=s['serieID'],
                               cookie=cookie['Sdarot'])))]
        } for s in req.json()['list']]
        sdarot.set_dir(items, 504, 'episodes', plugin)
        return []
    else:
        plugin.notify('התחבר כדי להכנס לרשימת מעקב', image=ICON)
示例#4
0
def open_season(sid, se, title, title_eng):
    cookie = sdarot.get_user_cookie()
    req = requests.get(API + '/series/info/{0}'.format(sid), cookies=cookie, headers=HEADERS).json()['serie']

    updated_list = plugin.get_storage('updated_list')
    sync_sdarot_vids = plugin.get_storage('sync').get('vids')
    episodes = req['episodes'][str(se)]
    items = []
    for episode in episodes or []:
        label = u'פרק {0}'.format(episode['episode'])
        plot = episode['description'].encode('utf-8') or 'לא זמין'
        path = plugin.url_for('watch', sid=sid, season=se, episode=episode['episode'],
                              title=title, vid='None')
        item = sdarot.make_item(label, path, plot, POSTER_PREFIX + sid + '.jpg', True,
                                sid=sid, episode=episode['episode'], season=se,
                                fav=build_fav(label, path, sid, 1), watched=episode['watched'],
                                updated_list=updated_list, is_user=cookie != {},
                                sync_storage=sync_sdarot_vids)
        item['context_menu'].extend([
            ('בחירת איכות', 'XBMC.Container.Update({0})'.format
                (plugin.url_for('choose_quality', sid=sid, season=se, episode=episode['episode'],
                                title=title, title_eng=title_eng, plot=plot))),
            ('הורד פרק', 'XBMC.Container.Update({0})'.format
                (plugin.url_for('download_vid', sid=sid, season=se, ep=episode['episode'],
                                title=title_eng, quality='None')))])
        items.append(item)

    sdarot.set_dir(items, 504, 'episodes', plugin)
    return []
示例#5
0
def main_menu():
    items = [
        {
            'label': folder['label'],
            'path': folder['path'],
            'icon': FANART,
            'info': {
                'plot': ' '
            },
            'properties': {
                'Fanart_Image': FANART
            }
        } for folder in [
            {
                'label': u'[COLOR blue] Clean cache - ניקוי מטמון[/COLOR]',
                'path': plugin.url_for('clean')
            },
            {
                'label': u'[COLOR red]Search - חפש[/COLOR]',
                'path': plugin.url_for('search', page=0)
            },
            {
                'label': u'הכל א-ת',
                'path': plugin.url_for('index', lang='heb', page='0')
            },
            {
                'label': u'הכל a-z',
                'path': plugin.url_for('index', lang='eng', page='0')
            },
            {
                'label': u'מועדפים',
                'path': plugin.url_for('favourites')
            },
            {
                'label': u'סדרות מעקב',
                'path': plugin.url_for('tracking_list')
            }
        ]
    ]

    req = requests.get(API + '/series/genres').json()

    for genre in req['genres']:
        label = genre['name']
        path = plugin.url_for('open_genre', _id=genre['id'], page=0)
        items.append(sdarot.make_item(label, path, '', FANART, False))

    sdarot.set_dir(items, 504, 'files', plugin)

    sync_storage = plugin.get_storage('sync')
    if not sync_storage.get('vids'):
        sync_storage['vids'] = {}
    return []
示例#6
0
def search(page):
    page = int(page)

    search_input = ''
    try:
        search_input = plugin.keyboard('', u'חפש כאן')
    except:
        kb = xbmc.Keyboard('', 'חפש כאן')
        kb.doModal()
        if kb.isConfirmed():
            search_input = kb.getText()

    try:
        if len(search_input) < 2:
            plugin.notify('מילת החיפוש חייבת להכיל לפחות שני תווים',
                          image=ICON)
        else:
            s = requests.Session()
            req = requests.Request(method='GET', url=API, headers=HEADERS)
            prep = req.prepare()
            prep.url = API + '/series/search/{0}/page/{1}/perPage/100'.format(
                search_input, page)
            req = s.send(prep)

            results = req.json()['series']
            if results:
                items = []
                for s in results:
                    label = u'{0}-{1}'.format(s['heb'], s['eng'])
                    path = plugin.url_for('open_series',
                                          sid=s['id'],
                                          title=s['heb'].encode('utf8'))
                    desc = s['description'].replace('<br />', '\n')
                    items.append(
                        sdarot.make_item(label,
                                         path,
                                         desc,
                                         POSTER_PREFIX + s['poster'],
                                         False,
                                         fav=build_fav(label, path, s['id'],
                                                       '0'),
                                         year=s['year']))

                sdarot.set_dir(items, 504, 'files', plugin)
                return []
            else:
                plugin.notify('לא נמצאו תוצאות לחיפוש', image=ICON)
    except:
        pass
示例#7
0
def choose_quality(sid, season, episode, title, title_eng, plot):
    qualities, cookie = sdarot.get_final_video_and_cookie(sid, season, episode, True)

    items = []
    for q in qualities.keys():
        label = '{0}, עונה {1}, פרק {2}, ({3}p)'.format(title, season, episode, q)
        path = plugin.url_for('watch', sid=sid, season=season, episode=episode, title=title,
                              vid=sdarot.build_final_url(qualities[q], cookie))

        item = sdarot.make_item(label, path, plot, POSTER_PREFIX + sid + '.jpg', True,
                                sid=sid, episode=episode, season=season, fav='')
        item['context_menu'].extend([('הורד פרק', 'XBMC.Container.Update({0})'.format(
            plugin.url_for('download_vid', sid=sid, season=season, ep=episode, title=title_eng, quality=q)))])
        items.append(item)

    sdarot.set_dir(items, 504, 'episodes', plugin)
    return []
示例#8
0
def favourites():
    favs = plugin.get_storage('favourites')
    items = [
        {
            'label': favs[f]['label'],
            'path': favs[f]['path'],
            'is_playable': True if favs[f]['is_playable'] == '1' else False,
            'icon': favs[f]['poster'],
            'thumbnail': favs[f]['poster'],
            'properties': {
                'Fanart_Image': FANART
            },
            'context_menu': [(
                'הסר ממועדפים סדרות', 'XBMC.Container.Update({0})'.format(plugin.url_for('remove_fav', _id=f))
            )]
        } for f in favs.keys()
    ]

    sdarot.set_dir(items, 504, 'episodes', plugin)
    return []