def ns_serials_by_genre(params):
    items = []
    P.log_error(params.url)
    content = App.http_request(URL + params.url)
    if content:
        html = BeautifulSoup(content, 'html.parser')
        block = html.find(class_='serials-list')
        for serial in block.find_all('li'):
            link = serial.find('a')
            img = link.find('img')

            url = link.get('href')
            cover = img.get('src')
            label = img.get('title').strip()

            items.append({
                'label': label,
                'thumb': cover,
                'art': {
                    'poster': cover
                },
                'url': P.get_url(action='ns_serial_seasons', url=url)
            })

    return App.create_listing(items, content='tvshows')
Esempio n. 2
0
def nm_movie(params):
    items = []

    content = App.http_request('%s/movie/watch.php?%s' %
                               (URL, urllib.urlencode({'id': params.id})))
    if content:
        html = BeautifulSoup(content, 'html.parser')
        cover = html.find(class_='movie-cover')
        if cover is not None:
            cover = cover.find('img').get('src')

        description = App.bs_get_text_with_newlines(
            html.find(class_='description-text'))

        flashvars = re.compile(
            '<param value="config=.+?__(.+?)" name="flashvars">').findall(
                content)
        if flashvars:
            video_id = flashvars[0]
            items.append(create_movie_item(video_id, cover))
        else:
            video = html.find('source', {'type': 'video/mp4'})
            if video is not None:
                title = html.find(class_='panel-title')
                if title is not None:
                    title = title.get_text().split('/', 1)
                    P.log_error(title)
                    if len(title) == 2:
                        title = title[1]
                    else:
                        title = title[0]
                else:
                    title = 'Просмотр'

                items.append({
                    'label': App.remove_double_spaces(title),
                    'thumb': cover,
                    'art': {
                        'poster': cover
                    },
                    'info': {
                        'video': {
                            'plot':
                            '' if App.get_skin_name() == 'skin.confluence' else
                            description,
                        }
                    },
                    'url': video.get('src'),
                    'is_playable': True,
                })
            else:
                App.notification('Ошибка', 'Фильм не найден', 'info')

    return App.create_listing(items, content='movies')
Esempio n. 3
0
def get_news_item_badge(item):
    result = ''
    badge = item.find(class_='label')
    if badge is not None:
        try:
            text = badge.get_text()
            color = App.get_color(badge.get('class')[1])
            result = App.format_color(text, color)
        except:
            P.log_error(traceback.format_exc())

    return result
def ns_serial_season_episodes(params):
    items = []

    xbmc.executebuiltin('ActivateWindow(busydialog)')

    content = App.http_request(URL + params.url)
    if content:
        html = BeautifulSoup(content, 'html.parser')
        serial_name = App.bs_get_text(html.find('h1')).strip()
        season_headers = html.find_all(class_='panel-title')

        for season_header in season_headers:
            try:
                season_name = App.bs_get_text(season_header.find('h2'))
                season_number = season_name.split(' ')[1]
                if params.season_number == '-1' or params.season_number == season_number:
                    episodes_block = season_header.parent.find(
                        class_='videos-pane')
                    for episode in episodes_block.find_all('li'):
                        try:
                            link = episode.find('a').get('href')
                            cover = episode.find('img').get('src')
                            episode_number = App.bs_get_text(
                                episode.find(class_='grey')).split(' ')[0]
                            label = App.replace_html_codes(
                                '%s&emsp;%sx%s' %
                                (serial_name, season_number, episode_number))

                            items.append(create_movie_item(link, label, cover))
                        except:
                            P.log_error(traceback.format_exc())
            except:
                P.log_error(traceback.format_exc())

    xbmc.executebuiltin('Dialog.Close(busydialog)')

    if len(items) > 0:
        App.create_playlist(items)
        xbmc.executebuiltin('ActivateWindow(VideoPlaylist)')
    else:
        App.noty('playlist_empty')
def get_bigger_cover(path):
    url = ''
    if path != '':
        try:
            paths = path.split('_')
            nums = paths[1][:-4]
            nums = map(int, nums.split('x'))
            y = 200 * nums[1] / nums[0]

            url = get_cover_by_size(paths[0], 200, y)

            if url == '':
                url = get_cover_by_size(paths[0], 200, y - 1)
                if url == '':
                    url = get_cover_by_size(paths[0], 200, y + 1)
                    if url == '':
                        url = '{0}/{1}/image.jpg'.format(URL, paths[0]).replace('thumbnails', 'images')
                        (resp_headers, resp_content) = H.request(url, 'GET')
                        if resp_headers.status != 200:
                            url = ''
        except:
            P.log_error(traceback.format_exc)
    return url if url != '' else '{0}/{1}'.format(URL, path)
def ns_serial_season_episodes(params):
    items = []

    xbmc.executebuiltin('ActivateWindow(busydialog)')

    content = App.http_request(URL + params.url)
    if content:
        html = BeautifulSoup(content, 'html.parser')
        serial_name = App.bs_get_text(html.find('h1')).strip()
        season_headers = html.find_all(class_='panel-title')

        for season_header in season_headers:
            try:
                season_name = App.bs_get_text(season_header.find('h2'))
                season_number = season_name.split(' ')[1]
                if params.season_number == '-1' or params.season_number == season_number:
                    episodes_block = season_header.parent.find(class_='videos-pane')
                    for episode in episodes_block.find_all('li'):
                        try:
                            link = episode.find('a').get('href')
                            cover = episode.find('img').get('src')
                            episode_number = App.bs_get_text(episode.find(class_='grey')).split(' ')[0]
                            label = App.replace_html_codes('%s&emsp;%sx%s' % (serial_name, season_number, episode_number))

                            items.append(create_movie_item(link, label, cover))
                        except:
                            P.log_error(traceback.format_exc())
            except:
                P.log_error(traceback.format_exc())

    xbmc.executebuiltin('Dialog.Close(busydialog)')

    if len(items) > 0:
        App.create_playlist(items)
        xbmc.executebuiltin('ActivateWindow(VideoPlaylist)')
    else:
        App.noty('playlist_empty')
def get_bigger_cover(path):
    url = ''
    if path != '':
        try:
            paths = path.split('_')
            nums = paths[1][:-4]
            nums = map(int, nums.split('x'))
            y = 200 * nums[1] / nums[0]

            url = get_cover_by_size(paths[0], 200, y)

            if url == '':
                url = get_cover_by_size(paths[0], 200, y - 1)
                if url == '':
                    url = get_cover_by_size(paths[0], 200, y + 1)
                    if url == '':
                        url = '{0}/{1}/image.jpg'.format(
                            URL, paths[0]).replace('thumbnails', 'images')
                        (resp_headers, resp_content) = H.request(url, 'GET')
                        if resp_headers.status != 200:
                            url = ''
        except:
            P.log_error(traceback.format_exc)
    return url if url != '' else '{0}/{1}'.format(URL, path)