Exemple #1
0
def mainWalk(ex_link, json_file, fname=''):
    items = []
    folders = []
    #print ex_link
    if ex_link == '' or ex_link.startswith('/'):  #jsonWalk
        data = cda.ReadJsonFile(json_file)
        items, folders = cda.jsconWalk(data, ex_link)
    if 'folder' in ex_link:
        items, folders = cda.get_UserFolder_content(urlF=ex_link,
                                                    recursive=True,
                                                    filtr_items={})
    elif 'obserwowani' in ex_link:
        items, folders = cda.get_UserFolder_obserwowani(ex_link)

    N_folders = len(items)
    for f in folders:
        tmp_json_file = f.get('jsonfile', json_file)  # use new json file
        title = f.get('title') + f.get('count', '')
        f['plot'] = f.get('plot', '') + '\n' + f.get('update', '')
        addDir(title,
               ex_link=f.get('url'),
               json_file=tmp_json_file,
               mode='walk',
               iconImage=f.get('img', ''),
               infoLabels=f,
               fanart=f.get('fanart', ''),
               totalItems=N_folders)

    # Item optional context menu
    contextO = ['F_ADD']
    if fname == '[COLOR khaki]Wybrane[/COLOR]':
        contextO = ['F_REM', 'F_DEL']
    N_items = len(items)
    list_of_items = []
    for item in items:
        item = updateMetadata_filmwebID(item)
        #addLinkItem(name=item.get('title').encode("utf-8"), url=item.get('url'), mode='decodeVideo',contextO=contextO, iconImage=item.get('img'), infoLabels=item, IsPlayable=True,fanart=item.get('img'),totalItems=N_items)
        list_of_items.append(
            add_Item(name=item.get('title').encode("utf-8"),
                     url=item.get('url'),
                     mode='decodeVideo',
                     contextO=contextO,
                     iconImage=item.get('img'),
                     infoLabels=item,
                     IsPlayable=True,
                     fanart=item.get('img')))
    xbmcplugin.addDirectoryItems(handle=addon_handle,
                                 items=list_of_items,
                                 totalItems=N_items)
    xbmcplugin.addSortMethod(addon_handle,
                             sortMethod=xbmcplugin.SORT_METHOD_UNSORTED,
                             label2Mask="%D, %P, %R")

    setView()
    return 1
Exemple #2
0
def mainWalk(ex_link='', json_file='', fname='', select=''):
    items = []
    folders = []
    contextmenu = []
    pagination = (False, False)
    contextO, contextI = ['F_ADD'], []
    if fname == 'Wybrane':
        contextO = ['F_REM', 'F_DEL']
    if ex_link == '' or ex_link.startswith('/'):
        data = cda.ReadJsonFile(json_file) if json_file else get_Root()
        itype = fragdict(json_file).get('info-type')
        if itype:
            xbmcplugin.setContent(addon_handle, itype)
        items, folders = cda.jsconWalk(data, ex_link)
    username = my_addon.getSetting('username')
    ure = re.escape(username) if username else r'[^/]+'
    if re.match(
            r'^.*?://[^/]+/[^/]+(?:/folder-glowny|/ulubione.*|/folder/.+)?(?:vfilm)?(?:/\d+)?(?:[?#].*)?$',
            ex_link):
        recursive = (my_addon.getSetting('UserFolder.content.paginatoin') !=
                     'true')
        items, folders, pagination, tree = cda.get_UserFolder_content(
            urlF=ex_link, recursive=recursive, filtr_items={})
        if tree:
            xbmcplugin.setProperty(addon_handle, 'FolderName', tree[-1].name)
            contextO += ['F_USER']
            if ex_link != tree[-1].url:
                contextO += ['F_USER', 'F_FOLDER']
            if len(tree) > 1:
                contextO += ['F_USER', 'F_FOLDER_UP']
        elif re.match(
                '^.*?://.*/[^/]+/?$',
                ex_link):  # user view (last added and link to root folder)
            contextI += ['F_FOLDER']
    # elif 'obserwowani' in ex_link:
    #     items, folders = cda.get_UserFolder_obserwowani(ex_link)
    # elif '/historia' in ex_link or '/obejrzyj-pozniej' in ex_link:
    elif re.match(
            r'^.*?://[^/]+/%s(?:/historia|/obejrzyj-pozniej)?(?:vfilm)?(?:/\d+)?(?:[?#].*)?$'
            % ure, ex_link):
        items, folders, pagination = cda.get_UserFolder_historia(ex_link)
    if pagination[0]:
        addDir(u'[COLOR gold]<< Poprzednia strona <<[/COLOR]',
               ex_link=pagination[0],
               mode='walk',
               iconImage=media('prev.png'),
               properties={'SpecialSort': 'top'})
    N_folders = len(items)
    N_items = len(items)
    for f in folders:
        tmp_json_file = f.get('jsonfile', json_file)
        title = f.get('title') + f.get('count', '')
        f['plot'] = '%s\n%s' % (f.get('plot', ''), f.get('update', ''))
        contextmenu = []
        if f.get('lib'):
            contextmenu.append(
                (u'[COLOR lightblue]Dodaj zawartość do Biblioteki[/COLOR]',
                 'RunPlugin(plugin://%s?mode=AddRootFolder&json_file=%s)' %
                 (my_addon_id, urllib.quote_plus(tmp_json_file))))
        if f.get('url'):
            contextmenu.extend(GetContextMenuFoldersXX(f, contextO))
        li = addDir(title,
                    ex_link=f.get('url'),
                    json_file=tmp_json_file,
                    mode='walk',
                    iconImage=f.get('img', ''),
                    infoLabels=f,
                    fanart=f.get('fanart', ''),
                    contextmenu=contextmenu,
                    totalItems=N_folders + N_items)
        if select and select == title:
            li.select(True)
            select = ''
    list_of_items = []
    for item in items:
        aitem = add_Item(name=item.get('title').encode('utf-8'),
                         url=item.get('url'),
                         mode='decodeVideo',
                         contextO=contextO + contextI,
                         iconImage=item.get('img'),
                         infoLabels=item,
                         IsPlayable=True,
                         fanart=item.get('img'))
        if select and select == item.get('title'):
            aitem.item.select(True)
            select = ''
        list_of_items.append(aitem)
    xbmcplugin.addDirectoryItems(handle=addon_handle,
                                 items=list_of_items,
                                 totalItems=N_folders + N_items)
    if pagination[1]:
        addDir(u'[COLOR gold]>> Następna strona >>[/COLOR]',
               ex_link=pagination[1],
               mode='walk',
               iconImage=media('next.png'),
               properties={'SpecialSort': 'bottom'})
    xbmcplugin.addSortMethod(addon_handle,
                             sortMethod=xbmcplugin.SORT_METHOD_UNSORTED,
                             label2Mask='%D, %P, %R')
    SelSort()
    return 1
Exemple #3
0
                    contextO=[],
                    iconImage=item.get('img'),
                    infoLabels=item,
                    IsPlayable=True,
                    fanart=item.get('img'),
                    totalItems=len(items))
    if params:
        addDir('[COLOR gold]Następna strona >> [/COLOR] ',
               ex_link=url,
               json_file=params,
               mode='premiumFilm',
               iconImage='next.png')
    xbmcplugin.endOfDirectory(addon_handle, succeeded=True, cacheToDisc=False)

elif mode[0] == 'favoritesADD':
    jdata = cda.ReadJsonFile(FAVORITE)
    new_item = json.loads(ex_link)
    # fix label/msg from title
    new_item['title'] = new_item.get('title', '').replace(
        new_item.get('label', ''), '').replace(new_item.get('msg', ''), '')
    dodac = [x for x in jdata if new_item['title'] == x.get('title', '')]
    if dodac:
        xbmc.executebuiltin(
            'Notification([COLOR pink]Już jest w Wybranych[/COLOR], ' +
            new_item.get('title', '').encode('utf-8') + ', 200)')
    else:
        jdata.append(new_item)
        with open(FAVORITE, 'w') as outfile:
            json.dump(jdata, outfile, indent=2, sort_keys=True)
            xbmc.executebuiltin('Notification(Dodano Do Wybranych, ' +
                                new_item.get('title', '').encode('utf-8') +
Exemple #4
0
                        iconImage=item.get('img'),
                        infoLabels=item,
                        IsPlayable=True,
                        fanart=item.get('img'),
                        totalItems=N_items)
    if pagination[1] is not False:
        addDir(u'[COLOR gold]>> Następna strona >>[/COLOR]',
               ex_link=url,
               json_file=pagination[1],
               mode='premiumFilm',
               iconImage=media('next.png'),
               properties={'SpecialSort': 'bottom'})
    xbmcplugin.endOfDirectory(addon_handle, succeeded=True, cacheToDisc=False)

elif mode[0] == 'favoritesADD':
    jdata = cda.ReadJsonFile(FAVORITE)
    new = json.loads(ex_link)
    new['title'] = new.get('title',
                           '').replace(new.get('label', ''),
                                       '').replace(new.get('msg', ''), '')
    if any(
            e.get('url', e.get('folder')) == new.get('url', new.get('folder'))
            for e in jdata):
        xbmcgui.Dialog().notification(
            u'[COLOR pink]Już jest w Wybranych[/COLOR]', new.get('title', ''),
            xbmcgui.NOTIFICATION_WARNING)
    else:
        jdata.append(new)
        if save_favorites(jdata):
            xbmcgui.Dialog().notification(u'Dodano Do Wybranych',
                                          new.get('title', ''),