Exemple #1
0
def read_favs(params):
    href = httpSiteUrl + "/myfavourites.aspx?ajax&section=" + params['section'] \
           + "&subsection=" + params['subsection'] \
           + "&rows=1&curpage=" + params['page'] \
           + "&action=get_list&setrows=1&page=" + params['type']

    favorites = read_fav_data(urllib.unquote_plus(href))
    if len(favorites) == 0:
        show_message('ОШИБКА', 'В избранном пусто', 3000)
        return False

    for item in favorites:
        additional = ''
        if item['season'] > 0:
            additional = ' (s%se%s)' % (item['season'], item['episode'])
        li = xbmcgui.ListItem(
            strutils.html_entities_decode(item['title']) + additional,
            iconImage=fs_ua.thumbnail(item['cover']),
            thumbnailImage=fs_ua.poster(item['cover'])
        )
        li.setProperty('IsPlayable', 'false')

        id = item['href'].split('/')[-1]
        li.addContextMenuItems([
            (
                __language__(50003), "XBMC.RunPlugin(%s)" % strutils.construct_request({
                    'mode': 'addto',
                    'section': 'favorites',
                    'id': id,
                    'title': item['title']
                })
            ),
            (
                __language__(50004), "XBMC.RunPlugin(%s)" % strutils.construct_request({
                    'mode': 'addto',
                    'section': 'playlist',
                    'id': id,
                    'title': item['title']
                })
            )
        ])

        uri = strutils.construct_request({
            'href': item['href'],
            'referer': href,
            'mode': 'read_dir',
            'cover': item['cover'],
            'folder': 0,
            'isMusic': item['isMusic']
        })
        xbmcplugin.addDirectoryItem(h, uri, li, True)

    li = xbmcgui.ListItem('[NEXT PAGE >]')
    li.setProperty('IsPlayable', 'false')
    params['page'] = int(params['page']) + 1
    uri = strutils.construct_request(params)
    xbmcplugin.addDirectoryItem(h, uri, li, True)

    xbmcplugin.endOfDirectory(h)
Exemple #2
0
def read_favs(params):
    href = httpSiteUrl + "/myfavourites.aspx?ajax&section=" + params['section'] \
           + "&subsection=" + params['subsection'] \
           + "&rows=1&curpage=" + params['page'] \
           + "&action=get_list&setrows=1&page=" + params['type']

    favorites = read_fav_data(urllib.unquote_plus(href))
    if len(favorites) == 0:
        show_message('ОШИБКА', 'В избранном пусто', 3000)
        return False

    for item in favorites:
        additional = ''
        if item['season'] > 0:
            additional = ' (s%se%s)' % (item['season'], item['episode'])
        li = xbmcgui.ListItem(strutils.html_entities_decode(item['title']) +
                              additional,
                              iconImage=fs_ua.thumbnail(item['cover']),
                              thumbnailImage=fs_ua.poster(item['cover']))
        li.setProperty('IsPlayable', 'false')

        id = item['href'].split('/')[-1]
        li.addContextMenuItems([
            (__language__(50003), "XBMC.RunPlugin(%s)" %
             strutils.construct_request({
                 'mode': 'addto',
                 'section': 'favorites',
                 'id': id,
                 'title': item['title']
             })),
            (__language__(50004), "XBMC.RunPlugin(%s)" %
             strutils.construct_request({
                 'mode': 'addto',
                 'section': 'playlist',
                 'id': id,
                 'title': item['title']
             }))
        ])

        uri = strutils.construct_request({
            'href': item['href'],
            'referer': href,
            'mode': 'read_dir',
            'cover': item['cover'],
            'folder': 0,
            'isMusic': item['isMusic']
        })
        xbmcplugin.addDirectoryItem(h, uri, li, True)

    li = xbmcgui.ListItem('[NEXT PAGE >]')
    li.setProperty('IsPlayable', 'false')
    params['page'] = int(params['page']) + 1
    uri = strutils.construct_request(params)
    xbmcplugin.addDirectoryItem(h, uri, li, True)

    xbmcplugin.endOfDirectory(h)
Exemple #3
0
def get_fav_categories(params):
    http = client.GET(httpSiteUrl + '/myfavourites.aspx?page=' + params['type'], httpSiteUrl)
    if http is None:
        return False

    beautifulSoup = BeautifulSoup(http)
    favSectionsContainer = beautifulSoup.find('div', 'b-tabpanels')
    if favSectionsContainer is None:
        show_message('ОШИБКА', 'В избранном пусто', 3000)
        return False

    favSections = favSectionsContainer.findAll('div', 'b-category')
    if len(favSections) == 0:
        show_message('ОШИБКА', 'В избранном пусто', 3000)
        return False
    sectionRegexp = re.compile("\s*\{\s*section:\s*'([^']+)")
    subsectionRegexp = re.compile("subsection:\s*'([^']+)")
    for favSection in favSections:
        rel = favSection.find('a', 'b-add')['rel'].encode('utf-8')
        section = sectionRegexp.findall(rel)[0]
        subsection = subsectionRegexp.findall(rel)[0]
        title = str(favSection.find('a', 'item').find('b').string)
        li = xbmcgui.ListItem(title)

        uri = strutils.construct_request({
            'mode': 'read_favs',
            'section': section,
            'subsection': subsection,
            'type': params['type'],
            'page': 0
        })
        xbmcplugin.addDirectoryItem(h, uri, li, True)
    xbmcplugin.endOfDirectory(h, True)
Exemple #4
0
def getGenreList(params):
    http = client.GET(urllib.unquote_plus(params['href']), httpSiteUrl)
    if http is None:
        return False

    beautifulSoup = BeautifulSoup(http)
    items = beautifulSoup.find('div', params['css']).findAll('a')

    if len(items) == 0:
        show_message('ОШИБКА', 'Неверная страница', 3000)
        return False
    else:
        for item in items:
            li = xbmcgui.ListItem(item.string)
            li.setProperty('IsPlayable', 'false')
            uri = strutils.construct_request({
                'href':
                client.get_full_url(item['href'].encode('utf-8')),
                'mode':
                'readcategory',
                'section':
                params['section'],
                'filter':
                '',
                'cleanUrl':
                urllib.unquote_plus(params['cleanUrl']),
                'start':
                0,
                'hideFirstPageData':
                1
            })
            xbmcplugin.addDirectoryItem(h, uri, li, True)
        xbmcplugin.endOfDirectory(h)
Exemple #5
0
def get_fav_categories(params):
    http = client.GET(
        httpSiteUrl + '/myfavourites.aspx?page=' + params['type'], httpSiteUrl)
    if http is None:
        return False

    beautifulSoup = BeautifulSoup(http)
    favSectionsContainer = beautifulSoup.find('div', 'b-tabpanels')
    if favSectionsContainer is None:
        show_message('ОШИБКА', 'В избранном пусто', 3000)
        return False

    favSections = favSectionsContainer.findAll('div', 'b-category')
    if len(favSections) == 0:
        show_message('ОШИБКА', 'В избранном пусто', 3000)
        return False
    sectionRegexp = re.compile("\s*\{\s*section:\s*'([^']+)")
    subsectionRegexp = re.compile("subsection:\s*'([^']+)")
    for favSection in favSections:
        rel = favSection.find('a', 'b-add')['rel'].encode('utf-8')
        section = sectionRegexp.findall(rel)[0]
        subsection = subsectionRegexp.findall(rel)[0]
        title = str(favSection.find('a', 'item').find('b').string)
        li = xbmcgui.ListItem(title)

        uri = strutils.construct_request({
            'mode': 'read_favs',
            'section': section,
            'subsection': subsection,
            'type': params['type'],
            'page': 0
        })
        xbmcplugin.addDirectoryItem(h, uri, li, True)
    xbmcplugin.endOfDirectory(h, True)
Exemple #6
0
def getGenreList(params):
    http = client.GET(urllib.unquote_plus(params['href']), httpSiteUrl)
    if http is None:
        return False

    beautifulSoup = BeautifulSoup(http)
    items = beautifulSoup.find('div', params['css']).findAll('a')

    if len(items) == 0:
        show_message('ОШИБКА', 'Неверная страница', 3000)
        return False
    else:
        for item in items:
            li = xbmcgui.ListItem(item.string)
            li.setProperty('IsPlayable', 'false')
            uri = strutils.construct_request({
                'href': client.get_full_url(item['href'].encode('utf-8')),
                'mode': 'readcategory',
                'section': params['section'],
                'filter': '',
                'cleanUrl': urllib.unquote_plus(params['cleanUrl']),
                'start': 0,
                'hideFirstPageData': 1
            })
            xbmcplugin.addDirectoryItem(h, uri, li, True)
        xbmcplugin.endOfDirectory(h)
Exemple #7
0
def load_first_page_sections(href, params):
    #Add search list item
    li = xbmcgui.ListItem("[ПОИСК]")
    li.setProperty('IsPlayable', 'false')
    uri = strutils.construct_request({
        'mode': 'runsearch',
        'section': params['section'],
        'url': urllib.unquote_plus(params['cleanUrl'])
    })
    xbmcplugin.addDirectoryItem(h, uri, li, True)

    first_page_data = client.GET(href, httpSiteUrl)
    if first_page_data is None:
        return False

    beautifulSoup = BeautifulSoup(first_page_data)
    if beautifulSoup is None:
        return False

    groups = beautifulSoup.find('div', 'b-section-menu')
    if groups is not None:
        yearLink = groups.find('a', href=re.compile(r'year'))
        if yearLink is not None:
            li = xbmcgui.ListItem("[По годам]")
            li.setProperty('IsPlayable', 'false')
            uri = strutils.construct_request({
                'mode': 'getGenreList',
                'section': params['section'],
                'filter': params['filter'],
                'href': yearLink['href'],
                'cleanUrl': urllib.unquote_plus(params['cleanUrl']),
                'css': 'main'
            })
            xbmcplugin.addDirectoryItem(h, uri, li, True)
        genreLink = groups.find('a', href=re.compile(r'genre'))
        if genreLink is not None:
            li = xbmcgui.ListItem("[Жанры]")
            li.setProperty('IsPlayable', 'false')
            uri = strutils.construct_request({
                'mode': 'getGenreList',
                'section': params['section'],
                'filter': params['filter'],
                'href': genreLink['href'],
                'cleanUrl': urllib.unquote_plus(params['cleanUrl']),
                'css': 'b-list-subcategories'
            })
            xbmcplugin.addDirectoryItem(h, uri, li, True)
Exemple #8
0
def get_categories(params):
    section = params['category']
    categoryUrl = urllib.unquote_plus(params['href'])

    http = client.GET(categoryUrl, httpSiteUrl)
    if http is None:
        return False

    beautifulSoup = BeautifulSoup(http)

    submenuSelector = 'b-header__menu'
    submenuItemSelector = 'b-header__menu-section-link'
    if params['category'] == 'audio':
        submenuSelector = 'b-subsection-menu__items'
        submenuItemSelector = 'b-subsection-menu__item'

    categorySubmenu = beautifulSoup.find('div', submenuSelector)
    if categorySubmenu is None:
        show_message('ОШИБКА', 'Неверная страница', 3000)
        return False

    subcategories = categorySubmenu.findAll('a', submenuItemSelector)
    if len(subcategories) == 0:
        show_message('ОШИБКА', 'Неверная страница', 3000)
        return False

    for subcategory in subcategories:
        # label = subcategory.find('span')
        li = xbmcgui.ListItem('[' + subcategory.text + ']')
        uri = strutils.construct_request({
            'href':
            client.get_full_url(subcategory['href']),
            'mode':
            'readcategory',
            'cleanUrl':
            client.get_full_url(subcategory['href']),
            'section':
            section,
            'start':
            0,
            'filter':
            ''
        })
        xbmcplugin.addDirectoryItem(h, uri, li, True)
    loadMainPageItems = __settings__.getSetting('Load main page items')
    if loadMainPageItems == 'true':
        readcategory({
            'href': params['href'],
            'cleanUrl': params['href'],
            'section': section,
            'start': 0,
            'filter': '',
            'disableFilters': 'yes'
        })
    else:
        xbmcplugin.endOfDirectory(h)
Exemple #9
0
def add_folder_file(item):
    title = item['title']
    cover = item['cover']
    href = item['href']
    referer = item['referer']
    item_type = item['type']

    li = xbmcgui.ListItem(
        strutils.html_entities_decode(title),
        iconImage=fs_ua.thumbnail(cover),
        thumbnailImage=fs_ua.poster(cover),
        path=href
    )
    li.setProperty('IsPlayable', 'true')

    li.setInfo(type=item_type, infoLabels={'title': title})
    playCount = kodi.get_play_count(strutils.html_entities_decode(title))
    if playCount:
        li.setInfo(type=item_type, infoLabels={'title': title, 'playcount': 1})
        li.addContextMenuItems([
            (
            __language__(40001), "XBMC.RunPlugin(%s)" % strutils.construct_request({
                'mode': 'download',
                'file_url': str(href.encode('utf-8')),
                'file_name': strutils.html_entities_decode(title)
            })
            )
        ])

    if item_type == 'music' or (__settings__.getSetting('Autoplay next') == 'true'):
        uri = strutils.construct_request({
            'file': str(href.encode('utf-8')),
            'referer': referer,
            'mode': 'play',
            'playLink': item['playLink']
        })
    else:
        uri = client.get_full_url(href)

    xbmcplugin.addDirectoryItem(h, uri, li, False)
Exemple #10
0
def add_folder_file(item):
    title = item['title']
    cover = item['cover']
    href = item['href']
    referer = item['referer']
    item_type = item['type']

    li = xbmcgui.ListItem(strutils.html_entities_decode(title),
                          iconImage=fs_ua.thumbnail(cover),
                          thumbnailImage=fs_ua.poster(cover),
                          path=href)
    li.setProperty('IsPlayable', 'true')

    li.setInfo(type=item_type, infoLabels={'title': title})
    playCount = kodi.get_play_count(strutils.html_entities_decode(title))
    if playCount:
        li.setInfo(type=item_type, infoLabels={'title': title, 'playcount': 1})
        li.addContextMenuItems([
            (__language__(40001),
             "XBMC.RunPlugin(%s)" % strutils.construct_request(
                 {
                     'mode': 'download',
                     'file_url': str(href.encode('utf-8')),
                     'file_name': strutils.html_entities_decode(title)
                 }))
        ])

    if item_type == 'music' or (__settings__.getSetting('Autoplay next')
                                == 'true'):
        uri = strutils.construct_request({
            'file': str(href.encode('utf-8')),
            'referer': referer,
            'mode': 'play',
            'playLink': item['playLink']
        })
    else:
        uri = client.get_full_url(href)

    xbmcplugin.addDirectoryItem(h, uri, li, False)
Exemple #11
0
def get_categories(params):
    section = params['category']
    categoryUrl = urllib.unquote_plus(params['href'])

    http = client.GET(categoryUrl, httpSiteUrl)
    if http is None:
        return False

    beautifulSoup = BeautifulSoup(http)

    submenuSelector = 'b-header__menu'
    submenuItemSelector = 'b-header__menu-section-link'
    if params['category'] == 'audio':
        submenuSelector = 'b-subsection-menu__items'
        submenuItemSelector = 'b-subsection-menu__item'

    categorySubmenu = beautifulSoup.find('div', submenuSelector)
    if categorySubmenu is None:
        show_message('ОШИБКА', 'Неверная страница', 3000)
        return False

    subcategories = categorySubmenu.findAll('a', submenuItemSelector)
    if len(subcategories) == 0:
        show_message('ОШИБКА', 'Неверная страница', 3000)
        return False

    for subcategory in subcategories:
        # label = subcategory.find('span')
        li = xbmcgui.ListItem('[' + subcategory.text + ']')
        uri = strutils.construct_request({
            'href': client.get_full_url(subcategory['href']),
            'mode': 'readcategory',
            'cleanUrl': client.get_full_url(subcategory['href']),
            'section': section,
            'start': 0,
            'filter': ''
        })
        xbmcplugin.addDirectoryItem(h, uri, li, True)
    loadMainPageItems = __settings__.getSetting('Load main page items')
    if loadMainPageItems == 'true':
        readcategory({
            'href': params['href'],
            'cleanUrl': params['href'],
            'section': section,
            'start': 0,
            'filter': '',
            'disableFilters': 'yes'
        })
    else:
        xbmcplugin.endOfDirectory(h)
Exemple #12
0
def readcategory(params):
    start = int(params['start'])
    category_href = urllib.unquote_plus(params['href'])

    categoryUrl = category_href
    if 'disableFilters' not in params:
        categoryUrl = fs_ua.get_url_with_sort_by(
            category_href,
            params['section'],
            params['start'],
            'detailed'
        )

    http = client.GET(categoryUrl, httpSiteUrl)
    if http is None:
        return False

    try:
        params['filter']
    except:
        params['filter'] = ''

    beautifulSoup = BeautifulSoup(http)
    itemsClass = 'b-poster-detail'

    items = beautifulSoup.findAll('div', itemsClass)

    if len(items) == 0:
        show_message('ОШИБКА', 'Неверная страница', 3000)
        return False
    else:
        if start == 0 and 'hideFirstPageData' not in params:
            load_first_page_sections(category_href, params)

        for item in items:
            cover = None
            href = None

            img = item.find('img')
            link = item.find('a', itemsClass + '__link')
            title = item.find('span', 'b-poster-detail__title').contents[0]
            if img is not None:
                cover = img['src']
                href = client.get_full_url(link['href'])

            if title is not None:
                plot = []
                details = item.find('span', 'b-poster-detail__description').contents
                for detail in details:
                    try:
                        plot.append(detail.encode('utf8'))
                    except:
                        pass
                titleText = strutils.html_entities_decode(title.encode('utf8'))
                li = xbmcgui.ListItem(titleText, iconImage=fs_ua.thumbnail(cover),
                                      thumbnailImage=fs_ua.poster(cover))
                if plot != '':
                    li.setInfo(type=params['section'], infoLabels={'title': titleText, 'plot': plot})
                li.setProperty('IsPlayable', 'false')

                id = str(link['href'].split('/')[-1])
                li.addContextMenuItems([
                    (
                    __language__(50001), "XBMC.RunPlugin(%s)" % strutils.construct_request({
                            'mode': 'addto',
                            'section': 'favorites',
                            'id': id
                        })
                    ),
                    (
                    __language__(50002), "XBMC.RunPlugin(%s)" % strutils.construct_request({
                            'mode': 'addto',
                            'section': 'playlist',
                            'id': id
                        })
                    )
                ])

                isMusic = 'no'
                if params['section'] == 'audio':
                    isMusic = 'yes'

                uri = strutils.construct_request({
                    'href': href,
                    'referer': categoryUrl,
                    'mode': 'read_dir',
                    'cover': cover,
                    'folder': 0,
                    'isMusic': isMusic
                })

                xbmcplugin.addDirectoryItem(h, uri, li, True)

    li = xbmcgui.ListItem('[NEXT PAGE >]')
    li.setProperty('IsPlayable', 'false')
    uri = strutils.construct_request({
        'href': category_href,
        'mode': 'readcategory',
        'section': params['section'],
        'filter': params['filter'],
        'start': start + 1,
        'firstPage': 'no'
    })
    xbmcplugin.addDirectoryItem(h, uri, li, True)

    xbmcplugin.endOfDirectory(h)
Exemple #13
0
def main(params):
    li = xbmcgui.ListItem('[Видео]')
    uri = strutils.construct_request({
        'href': httpSiteUrl + '/video/',
        'mode': 'get_categories',
        'category': 'video',
        'filter': '',
        'firstPage': 'yes'
    })
    xbmcplugin.addDirectoryItem(h, uri, li, True)

    li = xbmcgui.ListItem('[Аудио]')
    uri = strutils.construct_request({
        'href': httpSiteUrl + '/audio/',
        'mode': 'get_categories',
        'category': 'audio',
        'filter': '',
        'firstPage': 'yes'
    })
    xbmcplugin.addDirectoryItem(h, uri, li, True)

    if check_login():
        li = xbmcgui.ListItem('В процессе')
        uri = strutils.construct_request({
            'mode': 'get_fav_categories',
            'type': 'inprocess'
        })
        xbmcplugin.addDirectoryItem(h, uri, li, True)

        li = xbmcgui.ListItem('Избранное')
        uri = strutils.construct_request({
            'mode': 'get_fav_categories',
            'type': 'favorites'
        })
        xbmcplugin.addDirectoryItem(h, uri, li, True)

        li = xbmcgui.ListItem('Рекомендуемое')
        uri = strutils.construct_request({
            'mode': 'get_fav_categories',
            'type': 'recommended'
        })
        xbmcplugin.addDirectoryItem(h, uri, li, True)

        li = xbmcgui.ListItem('На будущее')
        uri = strutils.construct_request({
            'mode': 'get_fav_categories',
            'type': 'forlater'
        })
        xbmcplugin.addDirectoryItem(h, uri, li, True)

        li = xbmcgui.ListItem('Я рекомендую')
        uri = strutils.construct_request({
            'mode': 'get_fav_categories',
            'type': 'irecommended'
        })
        xbmcplugin.addDirectoryItem(h, uri, li, True)

        li = xbmcgui.ListItem('Завершенное')
        uri = strutils.construct_request({
            'mode': 'get_fav_categories',
            'type': 'finished'
        })
        xbmcplugin.addDirectoryItem(h, uri, li, True)

    xbmcplugin.endOfDirectory(h, True)
Exemple #14
0
def add_directory_item(linkItem,
                       isFolder,
                       playLink,
                       playLinkClass,
                       cover,
                       folderUrl,
                       folder,
                       isMusic,
                       quality=None,
                       itemsCount=None):
    folderRegexp = re.compile('(\d+)')
    lang = None
    langRegexp = re.compile('\s*m\-(\w+)\s*')
    lang_data = langRegexp.findall(linkItem['class'])
    if len(lang_data) > 0:
        lang = str(lang_data[0])
    title = ""
    if isFolder:
        title = strutils.fix_string(linkItem.text)

        if (itemsCount):
            title = "%s (%s)" % (title, strutils.fix_string(itemsCount.text))

        lang_quality_el = linkItem.find('font')
        if lang_quality_el:
            lang_quality = strutils.fix_string(lang_quality_el.text)
            title = title.replace(lang_quality, ' ' + lang_quality)

        if quality is not None:
            title = "%s [%s]" % (title, quality)
    else:
        try:
            title = str(
                playLink.find('span', playLinkClass + '-filename-text').string)
        except:
            pass
    if lang is not None:
        title = lang.upper() + ' - ' + title

    if playLink is not None and playLink.name == 'a':
        if 'href' in playLink:
            playLink = client.get_full_url(str(playLink['href']))
        elif 'rel' in playLink:
            playLink = client.get_full_url(str(playLink['rel']))
        else:
            playLink = ''
    else:
        playLink = ''

    href = linkItem['href']
    try:
        folder = folderRegexp.findall(linkItem['rel'])[0]
    except:
        pass

    if isFolder:
        li = xbmcgui.ListItem(strutils.html_entities_decode(title),
                              iconImage=fs_ua.thumbnail(cover),
                              thumbnailImage=fs_ua.poster(cover))
        li.setProperty('IsPlayable', 'false')

        uri = strutils.construct_request({
            'cover': cover,
            'href': folderUrl,
            'referer': folderUrl,
            'mode': 'read_dir',
            'folder': folder,
            'isMusic': isMusic,
            'quality': quality
        })
        xbmcplugin.addDirectoryItem(h, uri, li, isFolder)
    else:
        item_type = 'video'
        if isMusic == 'yes':
            item_type = 'music'

        add_folder_file({
            'title': title,
            'cover': cover,
            'href': href,
            'referer': folderUrl,
            'type': item_type,
            'playLink': playLink
        })
Exemple #15
0
def load_first_page_sections(href, params):
    #Add search list item
    li = xbmcgui.ListItem("[ПОИСК]")
    li.setProperty('IsPlayable', 'false')
    uri = strutils.construct_request({
        'mode':
        'runsearch',
        'section':
        params['section'],
        'url':
        urllib.unquote_plus(params['cleanUrl'])
    })
    xbmcplugin.addDirectoryItem(h, uri, li, True)

    first_page_data = client.GET(href, httpSiteUrl)
    if first_page_data is None:
        return False

    beautifulSoup = BeautifulSoup(first_page_data)
    if beautifulSoup is None:
        return False

    groups = beautifulSoup.find('div', 'b-section-menu')
    if groups is not None:
        yearLink = groups.find('a', href=re.compile(r'year'))
        if yearLink is not None:
            li = xbmcgui.ListItem("[По годам]")
            li.setProperty('IsPlayable', 'false')
            uri = strutils.construct_request({
                'mode':
                'getGenreList',
                'section':
                params['section'],
                'filter':
                params['filter'],
                'href':
                yearLink['href'],
                'cleanUrl':
                urllib.unquote_plus(params['cleanUrl']),
                'css':
                'main'
            })
            xbmcplugin.addDirectoryItem(h, uri, li, True)
        genreLink = groups.find('a', href=re.compile(r'genre'))
        if genreLink is not None:
            li = xbmcgui.ListItem("[Жанры]")
            li.setProperty('IsPlayable', 'false')
            uri = strutils.construct_request({
                'mode':
                'getGenreList',
                'section':
                params['section'],
                'filter':
                params['filter'],
                'href':
                genreLink['href'],
                'cleanUrl':
                urllib.unquote_plus(params['cleanUrl']),
                'css':
                'b-list-subcategories'
            })
            xbmcplugin.addDirectoryItem(h, uri, li, True)
Exemple #16
0
def readcategory(params):
    start = int(params['start'])
    category_href = urllib.unquote_plus(params['href'])

    categoryUrl = fs_ua.get_url_with_sort_by(category_href, params['section'],
                                             params['start'], 'detailed')

    http = client.GET(categoryUrl, httpSiteUrl)
    if http is None:
        return False

    try:
        params['filter']
    except:
        params['filter'] = ''

    beautifulSoup = BeautifulSoup(http)
    itemsClass = 'b-poster-detail'

    items = beautifulSoup.findAll('div', itemsClass)

    if len(items) == 0:
        show_message('ОШИБКА', 'Неверная страница', 3000)
        return False
    else:
        if start == 0 and 'hideFirstPageData' not in params:
            load_first_page_sections(category_href, params)

        for item in items:
            cover = None
            href = None

            img = item.find('img')
            link = item.find('a', itemsClass + '__link')
            title = item.find('span', 'b-poster-detail__title').contents[0]
            if img is not None:
                cover = img['src']
                href = client.get_full_url(link['href'])

            if title is not None:
                plot = []
                details = item.find('span',
                                    'b-poster-detail__description').contents
                for detail in details:
                    try:
                        plot.append(detail.encode('utf8'))
                    except:
                        pass
                titleText = strutils.html_entities_decode(title.encode('utf8'))
                li = xbmcgui.ListItem(titleText,
                                      iconImage=fs_ua.thumbnail(cover),
                                      thumbnailImage=fs_ua.poster(cover))
                if plot != '':
                    li.setInfo(type=params['section'],
                               infoLabels={
                                   'title': titleText,
                                   'plot': plot
                               })
                li.setProperty('IsPlayable', 'false')

                id = str(link['href'].split('/')[-1])
                li.addContextMenuItems([
                    (__language__(50001), "XBMC.RunPlugin(%s)" %
                     strutils.construct_request({
                         'mode': 'addto',
                         'section': 'favorites',
                         'id': id
                     })),
                    (__language__(50002), "XBMC.RunPlugin(%s)" %
                     strutils.construct_request({
                         'mode': 'addto',
                         'section': 'playlist',
                         'id': id
                     }))
                ])

                isMusic = 'no'
                if params['section'] == 'audio':
                    isMusic = 'yes'

                uri = strutils.construct_request({
                    'href': href,
                    'referer': categoryUrl,
                    'mode': 'read_dir',
                    'cover': cover,
                    'folder': 0,
                    'isMusic': isMusic
                })

                xbmcplugin.addDirectoryItem(h, uri, li, True)

    li = xbmcgui.ListItem('[NEXT PAGE >]')
    li.setProperty('IsPlayable', 'false')
    uri = strutils.construct_request({
        'href': category_href,
        'mode': 'readcategory',
        'section': params['section'],
        'filter': params['filter'],
        'start': start + 1,
        'firstPage': 'no'
    })
    xbmcplugin.addDirectoryItem(h, uri, li, True)

    xbmcplugin.endOfDirectory(h)
Exemple #17
0
def add_directory_item(linkItem, isFolder, playLink, playLinkClass, cover, folderUrl, folder, isMusic, quality = None, itemsCount = None):
    lang = None
    langRegexp = re.compile('\s*m\-(\w+)\s*')
    lang_data = langRegexp.findall(linkItem['class'])
    if len(lang_data) > 0:
        lang = str(lang_data[0])
    title = ""
    if isFolder:
        title = strutils.fix_string(linkItem.text)

        if (itemsCount):
                title = "%s (%s)" % (title, strutils.fix_string(itemsCount.text))

        lang_quality_el = linkItem.find('font')
        if lang_quality_el:
            lang_quality = strutils.fix_string(lang_quality_el.text)
            title = title.replace(lang_quality, ' ' + lang_quality)

        if quality is not None:
            title = "%s [%s]" % (title, quality)
    else:
        try:
            title = str(playLink.find('span', playLinkClass + '-filename-text').string)
        except:
            pass
    if lang is not None:
        title = lang.upper() + ' - ' + title

    if playLink is not None and playLink.name == 'a':
        if 'href' in playLink:
            playLink = client.get_full_url(str(playLink['href']))
        elif 'rel' in playLink:
            playLink = client.get_full_url(str(playLink['rel']))
        else:
            playLink = ''
    else:
        playLink = ''

    href = linkItem['href']
    try:
        folderRegexp = re.compile("parent_id:\s*'([^']+)")
        folder = folderRegexp.findall(linkItem['rel'])[0]
    except:
        pass

    if isFolder:
        li = xbmcgui.ListItem(
            strutils.html_entities_decode(title),
            iconImage=fs_ua.thumbnail(cover),
            thumbnailImage=fs_ua.poster(cover)
        )
        li.setProperty('IsPlayable', 'false')

        uri = strutils.construct_request({
            'cover': cover,
            'href': folderUrl,
            'referer': folderUrl,
            'mode': 'read_dir',
            'folder': folder,
            'isMusic': isMusic,
            'quality': quality
        })
        xbmcplugin.addDirectoryItem(h, uri, li, isFolder)
    else:
        item_type = 'video'
        if isMusic == 'yes':
            item_type = 'music'

        add_folder_file({
            'title': title,
            'cover': cover,
            'href': href,
            'referer': folderUrl,
            'type': item_type,
            'playLink': playLink
        })
Exemple #18
0
def render_search_results(params):
    searchUrl = urllib.unquote_plus(params['href'])
    http = client.GET(searchUrl, httpSiteUrl)
    if http is None:
        return False

    beautifulSoup = BeautifulSoup(http)
    results = beautifulSoup.find('div', 'b-search-page__results')

    if results is None:
        show_message('ОШИБКА', 'Ничего не найдено', 3000)
        return False
    else:
        items = results.findAll('a', 'b-search-page__results-item')
        if len(items) == 0:
            show_message('ОШИБКА', 'Ничего не найдено', 3000)
            return False

        for item in items:
            title = str(
                item.find(
                    'span',
                    'b-search-page__results-item-title').text.encode('utf-8'))
            href = client.get_full_url(item['href'])
            cover = item.find(
                'span', 'b-search-page__results-item-image').find('img')['src']
            section = item.find('span',
                                'b-search-page__results-item-subsection').text

            if title is not None:
                li = xbmcgui.ListItem('[%s] %s' %
                                      (strutils.html_entities_decode(section),
                                       strutils.html_entities_decode(title)),
                                      iconImage=fs_ua.thumbnail(cover),
                                      thumbnailImage=fs_ua.poster(cover))
                li.setProperty('IsPlayable', 'false')
                id = item['href'].split('/')[-1]
                li.addContextMenuItems([
                    (__language__(50001), "XBMC.RunPlugin(%s)" %
                     strutils.construct_request({
                         'mode': 'addto',
                         'section': 'favorites',
                         'id': id
                     })),
                    (__language__(50002), "XBMC.RunPlugin(%s)" %
                     strutils.construct_request({
                         'mode': 'addto',
                         'section': 'playlist',
                         'id': id
                     }))
                ])

                isMusic = 'no'
                if params['section'] == 'audio':
                    isMusic = 'yes'

                uri = strutils.construct_request({
                    'href': href,
                    'referer': searchUrl,
                    'mode': 'read_dir',
                    'cover': cover,
                    'folder': 0,
                    'isMusic': isMusic
                })

                xbmcplugin.addDirectoryItem(h, uri, li, True)

    xbmcplugin.endOfDirectory(h)
Exemple #19
0
def render_search_results(params):
    searchUrl = urllib.unquote_plus(params['href'])
    http = client.GET(searchUrl, httpSiteUrl)
    if http is None:
        return False

    beautifulSoup = BeautifulSoup(http)
    results = beautifulSoup.find('div', 'b-search-page__results')

    if results is None:
        show_message('ОШИБКА', 'Ничего не найдено', 3000)
        return False
    else:
        items = results.findAll('a','b-search-page__results-item')
        if len(items) == 0:
            show_message('ОШИБКА', 'Ничего не найдено', 3000)
            return False

        for item in items:
            title = str(item.find('span', 'b-search-page__results-item-title').text.encode('utf-8'))
            href = client.get_full_url(item['href'])
            cover = item.find('span', 'b-search-page__results-item-image').find('img')['src']
            section = item.find('span', 'b-search-page__results-item-subsection').text

            if title is not None:
                li = xbmcgui.ListItem('[%s] %s' % (strutils.html_entities_decode(section), strutils.html_entities_decode(title)), iconImage=fs_ua.thumbnail(cover),
                                      thumbnailImage=fs_ua.poster(cover))
                li.setProperty('IsPlayable', 'false')
                id = item['href'].split('/')[-1]
                li.addContextMenuItems([
                    (
                    __language__(50001), "XBMC.RunPlugin(%s)" % strutils.construct_request({
                            'mode': 'addto',
                            'section': 'favorites',
                            'id': id
                        })
                    ),
                    (
                    __language__(50002), "XBMC.RunPlugin(%s)" % strutils.construct_request({
                            'mode': 'addto',
                            'section': 'playlist',
                            'id': id
                        })
                    )
                ])

                isMusic = 'no'
                if params['section'] == 'audio':
                    isMusic = 'yes'

                uri = strutils.construct_request({
                    'href': href,
                    'referer': searchUrl,
                    'mode': 'read_dir',
                    'cover': cover,
                    'folder': 0,
                    'isMusic': isMusic
                })

                xbmcplugin.addDirectoryItem(h, uri, li, True)

    xbmcplugin.endOfDirectory(h)
Exemple #20
0
def main(params):
    li = xbmcgui.ListItem('[Видео]')
    uri = strutils.construct_request({
        'href': httpSiteUrl + '/video/',
        'mode': 'get_categories',
        'category': 'video',
        'filter': '',
        'firstPage': 'yes'
    })
    xbmcplugin.addDirectoryItem(h, uri, li, True)

    li = xbmcgui.ListItem('[Аудио]')
    uri = strutils.construct_request({
        'href': 'http://brb.to/audio/',
        'mode': 'get_categories',
        'category': 'audio',
        'filter': '',
        'firstPage': 'yes'
    })
    xbmcplugin.addDirectoryItem(h, uri, li, True)

    if check_login():
        li = xbmcgui.ListItem('В процессе')
        uri = strutils.construct_request({
            'mode': 'get_fav_categories',
            'type': 'inprocess'
        })
        xbmcplugin.addDirectoryItem(h, uri, li, True)

        li = xbmcgui.ListItem('Избранное')
        uri = strutils.construct_request({
            'mode': 'get_fav_categories',
            'type': 'favorites'
        })
        xbmcplugin.addDirectoryItem(h, uri, li, True)

        li = xbmcgui.ListItem('Рекомендуемое')
        uri = strutils.construct_request({
            'mode': 'get_fav_categories',
            'type': 'recommended'
        })
        xbmcplugin.addDirectoryItem(h, uri, li, True)

        li = xbmcgui.ListItem('На будущее')
        uri = strutils.construct_request({
            'mode': 'get_fav_categories',
            'type': 'forlater'
        })
        xbmcplugin.addDirectoryItem(h, uri, li, True)

        li = xbmcgui.ListItem('Я рекомендую')
        uri = strutils.construct_request({
            'mode': 'get_fav_categories',
            'type': 'irecommended'
        })
        xbmcplugin.addDirectoryItem(h, uri, li, True)

        li = xbmcgui.ListItem('Завершенное')
        uri = strutils.construct_request({
            'mode': 'get_fav_categories',
            'type': 'finished'
        })
        xbmcplugin.addDirectoryItem(h, uri, li, True)

    xbmcplugin.endOfDirectory(h, True)