Ejemplo n.º 1
0
def trailer(title, video_type):
    trailers = []
    content = get.trailer(video_type, title)
    if content:
        for match in content['results']:
            if match['site'] == 'YouTube':
                if match['iso_639_1']:
                    name = match['name'] + ' (' + match['iso_639_1'] + ')'
                else:
                    name = match['name']
                match = {'name': name, 'key': match['key']}
                trailers.append(match)
        if len(trailers) > 0:
            dialog = xbmcgui.Dialog()
            nr = dialog.select('Trailer',
                               [match['name'] for match in trailers])
            if nr >= 0:
                selected_trailer = trailers[nr]
                match = 'PlayMedia(plugin://plugin.video.youtube/play/?video_id=%s)' % selected_trailer[
                    'key']
                xbmc.executebuiltin(match)
        else:
            utility.notification(utility.get_string(30305))
    else:
        utility.notification(utility.get_string(30305))
        pass
Ejemplo n.º 2
0
def search(search_string, video_type, run_as_widget=False):
    i = 1
    loading_progress = None
    if not run_as_widget:
        loading_progress = xbmcgui.DialogProgress()
        loading_progress.create('Netflix', utility.get_string(30205) + '...')
        utility.progress_window(loading_progress, 0, '...')
    xbmcplugin.setContent(plugin_handle, 'movies')
    if not xbmcvfs.exists(utility.session_file()):
        login.login()
    post_data = '{"paths":[["search","%s",{"from":0,"to":48},["summary","title"]],["search","%s",["id","length",' \
                '"name","trackIds","requestId"]]],"authURL":"%s"}' % (search_string, search_string,
                                                                      utility.get_setting('authorization_url'))
    content = utility.decode(
        connect.load_site(utility.evaluator_url %
                          (utility.get_setting('netflix_application'),
                           utility.get_setting('netflix_version')),
                          post=post_data))
    try:
        matches = json.loads(content)['value']['videos']
        for k in matches:
            if not run_as_widget:
                utility.progress_window(loading_progress,
                                        i * 100 / len(matches), '...')
            video(unicode(matches[k]['summary']['id']), '', '', False, False,
                  video_type, '')
            i += 1
        if utility.get_setting('force_view') and not run_as_widget:
            xbmc.executebuiltin('Container.SetViewMode(' +
                                utility.get_setting('view_id_videos') + ')')
        xbmcplugin.endOfDirectory(plugin_handle)
    except Exception:
        utility.notification(utility.get_string(30306))
        pass
Ejemplo n.º 3
0
def search(search_string, video_type, run_as_widget=False):
    i = 1
    loading_progress = None
    if not run_as_widget:
        loading_progress = xbmcgui.DialogProgress()
        loading_progress.create('Netflix', utility.get_string(30205) + '...')
        utility.progress_window(loading_progress, 0, '...')
    xbmcplugin.setContent(plugin_handle, 'movies')
    if not xbmcvfs.exists(utility.session_file()):
        login.login()
    post_data = '{"paths":[["search","%s",{"from":0,"to":48},["summary","title"]],["search","%s",["id","length",' \
                '"name","trackIds","requestId"]]],"authURL":"%s"}' % (search_string, search_string,
                                                                      utility.get_setting('authorization_url'))
    content = utility.decode(connect.load_site(utility.evaluator(), post=post_data))
    try:
        matches = json.loads(content)['value']['videos']
        for k in matches:
            if not run_as_widget:
                utility.progress_window(loading_progress, i * 100 / len(matches), '...')
            video(unicode(matches[k]['summary']['id']), '', '', False, False, video_type, '')
            i += 1
        if utility.get_setting('force_view') and not run_as_widget:
            xbmc.executebuiltin('Container.SetViewMode(' + utility.get_setting('view_id_videos') + ')')
        xbmcplugin.endOfDirectory(plugin_handle)
    except Exception:
        utility.notification(utility.get_string(30306))
        pass
Ejemplo n.º 4
0
def addon():
    dialog = xbmcgui.Dialog()
    if dialog.yesno(utility.addon_name + ':', utility.get_string(30307)):
        try:
            xbmcvfs.rmdir(utility.data_dir(), force=True)
            utility.log('Addon userdata folder deleted.')
            utility.notification(utility.get_string(30308))
        except Exception:
            pass
Ejemplo n.º 5
0
def index():
    if login.login():
        add.directory(utility.get_string(30100), '', 'main', '', 'movie')
        add.directory(utility.get_string(30101), '', 'main', '', 'tv')
        add.directory(utility.get_string(30102), '', 'wi_home', '', 'both')
        if not utility.get_setting('single_profile') == 'true':
            add.directory(
                utility.get_string(30103) + ' - [COLOR FF8E0000]' + utility.get_setting('profile_name') + '[/COLOR]',
                '', 'update_displayed_profile', 'DefaultAddonService.png', '', context_enable=False)
        xbmcplugin.endOfDirectory(plugin_handle)
Ejemplo n.º 6
0
def video(name, url, mode, thumb, video_type='', description='', duration='', year='', mpaa='', director='', genre='',
          rating=0.0, playcount=0, remove=False):
    entries = []
    filename = utility.clean_filename(url) + '.jpg'
    cover_file = xbmc.translatePath(utility.cover_cache_dir() + filename)
    fanart_file = xbmc.translatePath(utility.fanart_cache_dir() + filename)
    if xbmcvfs.exists(cover_file):
        thumb = cover_file
    u = sys.argv[0]
    u += '?url=' + urllib.quote_plus(url)
    u += '&mode=' + mode
    u += '&name=' + urllib.quote_plus(utility.encode(name))
    u += '&thumb=' + urllib.quote_plus(thumb)
    list_item = xbmcgui.ListItem(name)
    list_item.setArt({'icon': 'DefaultTVShows.png', 'thumb': thumb})
    list_item.setInfo(type='video',
                      infoLabels={'title': name, 'plot': description, 'duration': duration, 'year': int(year),
                                  'mpaa': mpaa, 'director': director, 'genre': genre, 'rating': rating,
                                  'playcount': playcount})
    if xbmcvfs.exists(fanart_file):
        list_item.setProperty('fanart_image', fanart_file)
    elif xbmcvfs.exists(cover_file):
        list_item.setProperty('fanart_image', cover_file)
    else:
        list_item.setProperty('fanart_image', utility.addon_fanart())
    if video_type == 'tvshow':
        if utility.get_setting('browse_tv_shows') == 'true':
            entries.append((utility.get_string(30151),
                            'Container.Update(plugin://%s/?mode=play_video_main&url=%s&thumb=%s)' % (
                                utility.addon_id, urllib.quote_plus(url), urllib.quote_plus(thumb))))
        else:
            entries.append((utility.get_string(30152),
                            'Container.Update(plugin://%s/?mode=list_seasons&url=%s&thumb=%s)' % (
                                utility.addon_id, urllib.quote_plus(url), urllib.quote_plus(thumb))))
    if video_type != 'episode':
        entries.append((utility.get_string(30153), 'RunPlugin(plugin://%s/?mode=play_trailer&url=%s&type=%s)' % (
            utility.addon_id, urllib.quote_plus(utility.encode(name)), video_type)))
        if remove:
            entries.append((utility.get_string(30154), 'RunPlugin(plugin://%s/?mode=remove_from_queue&url=%s)' % (
                utility.addon_id, urllib.quote_plus(url))))
        else:
            entries.append((utility.get_string(30155), 'RunPlugin(plugin://%s/?mode=add_to_queue&url=%s)' % (
                utility.addon_id, urllib.quote_plus(url))))
        entries.append((utility.get_string(30156),
                        'Container.Update(plugin://%s/?mode=list_videos&url=%s&type=movie)' % (
                            utility.addon_id, urllib.quote_plus(utility.main_url + '/WiMovie/' + url))))
        entries.append((utility.get_string(30157), 'Container.Update(plugin://%s/?mode=list_videos&url=%s&type=tv)' % (
            utility.addon_id, urllib.quote_plus(utility.main_url + '/WiMovie/' + url))))
    if video_type == 'tvshow':
        entries.append((utility.get_string(30150),
                        'RunPlugin(plugin://%s/?mode=add_series_to_library&url=&name=%s&series_id=%s)' % (
                            utility.addon_id, urllib.quote_plus(utility.encode(name.strip())), urllib.quote_plus(url))))
    elif video_type == 'movie':
        entries.append((utility.get_string(30150),
                        'RunPlugin(plugin://%s/?mode=add_movie_to_library&url=%s&name=%s)' % (
                            utility.addon_id, urllib.quote_plus(url),
                            urllib.quote_plus(utility.encode(name.strip())) + ' (' + unicode(year) + ')')))
    list_item.addContextMenuItems(entries)
    directory_item = xbmcplugin.addDirectoryItem(handle=plugin_handle, url=u, listitem=list_item, isFolder=True)
    return directory_item
Ejemplo n.º 7
0
def index():
    if login.login():
        add.directory(utility.get_string(30100), '', 'main', '', 'movie')
        add.directory(utility.get_string(30101), '', 'main', '', 'tv')
        add.directory(utility.get_string(30102), '', 'wi_home', '', 'both')
        if not utility.get_setting('single_profile') == 'true':
            add.directory(utility.get_string(30103) + ' - [COLOR FF8E0000]' +
                          utility.get_setting('profile_name') + '[/COLOR]',
                          '',
                          'update_displayed_profile',
                          'DefaultAddonService.png',
                          '',
                          context_enable=False)
        xbmcplugin.endOfDirectory(plugin_handle)
Ejemplo n.º 8
0
def view_activity(video_type, run_as_widget=False):
    count = 0
    loading_progress = None
    if not run_as_widget:
        loading_progress = xbmcgui.DialogProgress()
        loading_progress.create('Netflix', utility.get_string(30205) + '...')
        utility.progress_window(loading_progress, 0, '...')
    xbmcplugin.setContent(plugin_handle, 'movies')
    if not xbmcvfs.exists(utility.session_file()):
        login.login()
    content = utility.decode(
        connect.load_site(utility.activity_url %
                          (utility.get_setting('api_url'),
                           utility.get_setting('authorization_url'))))
    matches = json.loads(content)['viewedItems']
    try:
        for item in matches:
            series_id = 0
            is_episode = False
            video_id = unicode(item['movieID'])
            date = item['dateStr']
            try:
                series_id = item['series']
                series_title = item['seriesTitle']
                title = item['title']
                title = series_title + ' ' + title
            except Exception:
                title = item['title']
            if not run_as_widget:
                utility.progress_window(loading_progress,
                                        (count + 1) * 500 / len(matches),
                                        title)
            title = date + ' - ' + title
            if series_id > 0:
                is_episode = True
            added = video(video_id, title, '', is_episode, False, video_type,
                          '')
            if added:
                count += 1
            if count == 20:
                break
    except Exception:
        utility.notification(utility.get_string(30306))
        pass
    if utility.get_setting('force_view') and not run_as_widget:
        xbmc.executebuiltin('Container.SetViewMode(' +
                            utility.get_setting('view_id_activity') + ')')
    xbmcplugin.endOfDirectory(plugin_handle)
Ejemplo n.º 9
0
def videos(url, video_type, run_as_widget=False):
    post_data = ''
    i = 1
    loading_progress = None
    if not run_as_widget:
        loading_progress = xbmcgui.DialogProgress()
        loading_progress.create('Netflix', utility.get_string(30205) + '...')
        utility.progress_window(loading_progress, 0, '...')
    xbmcplugin.setContent(plugin_handle, 'movies')
    if not xbmcvfs.exists(utility.session_file()):
        login.login()
    if 'recently-added' in url:
        post_data = utility.recently_added % utility.get_setting(
            'authorization_url')
    elif 'genre' in url:
        post_data = utility.genre % (url.split('?')[1],
                                     utility.get_setting('authorization_url'))
    elif 'my-list' in url:
        post_data = utility.my_list % utility.get_setting('authorization_url')
    content = utility.decode(
        connect.load_site(utility.evaluator(), post=post_data))
    matches = json.loads(content)['value']['videos']
    for video_id in matches:
        if not run_as_widget:
            utility.progress_window(loading_progress, i * 100 / len(matches),
                                    matches[video_id]['title'])
        video(unicode(video_id), '', '', False, False, video_type, url)
        i += 1
    if utility.get_setting('force_view') == 'true' and not run_as_widget:
        xbmc.executebuiltin('Container.SetViewMode(' +
                            utility.get_setting('view_id_videos') + ')')
    xbmcplugin.endOfDirectory(plugin_handle)
Ejemplo n.º 10
0
def videos(url, video_type, run_as_widget=False):
    post_data = ''
    i = 1
    loading_progress = None
    if not run_as_widget:
        loading_progress = xbmcgui.DialogProgress()
        loading_progress.create('Netflix', utility.get_string(30205) + '...')
        utility.progress_window(loading_progress, 0, '...')
    xbmcplugin.setContent(plugin_handle, 'movies')
    if not xbmcvfs.exists(utility.session_file()):
        login.login()
    if 'recently-added' in url:
        post_data = utility.recently_added % utility.get_setting('authorization_url')
    elif 'genre' in url:
        post_data = utility.genre % (url.split('?')[1], utility.get_setting('authorization_url'))
    elif 'my-list' in url:
        post_data = utility.my_list % utility.get_setting('authorization_url')
    content = utility.decode(connect.load_site(utility.evaluator(), post=post_data))
    matches = json.loads(content)['value']['videos']
    for video_id in matches:
        if not run_as_widget:
            utility.progress_window(loading_progress, i * 100 / len(matches), matches[video_id]['title'])
        video(unicode(video_id), '', '', False, False, video_type, url)
        i += 1
    if utility.get_setting('force_view') == 'true' and not run_as_widget:
        xbmc.executebuiltin('Container.SetViewMode(' + utility.get_setting('view_id_videos') + ')')
    xbmcplugin.endOfDirectory(plugin_handle)
Ejemplo n.º 11
0
def choose():
    profiles = []
    content = utility.decode(connect.load_site(utility.profile_url))
    match = json.loads(content)['profiles']
    for item in match:
        profile = {
            'name': item['firstName'],
            'token': item['guid'],
            'is_kid': item['experience'] == 'jfk'
        }
        profiles.append(profile)
    if len(match) > 0:
        dialog = xbmcgui.Dialog()
        nr = dialog.select(utility.get_string(30103),
                           [profile['name'] for profile in profiles])
        if nr >= 0:
            selected_profile = profiles[nr]
        else:
            selected_profile = profiles[0]
        connect.load_site(utility.profile_switch_url +
                          selected_profile['token'])
        utility.set_setting('selected_profile', selected_profile['token'])
        utility.set_setting('is_kid',
                            'true' if selected_profile['is_kid'] else 'false')
        utility.set_setting('profile_name', selected_profile['name'])
        connect.save_session()
    else:
        utility.log('Choose profile: no profiles were found!',
                    loglevel=xbmc.LOGERROR)
Ejemplo n.º 12
0
def season(name, url, mode, thumb, series_name, series_id):
    entries = []
    filename = series_id + '.jpg'
    cover_file = xbmc.translatePath(utility.cover_cache_dir() + filename)
    fanart_file = xbmc.translatePath(utility.fanart_cache_dir() + filename)
    u = sys.argv[0]
    u += '?url=' + urllib.quote_plus(unicode(url))
    u += '&mode=' + mode
    u += '&series_id=' + urllib.quote_plus(series_id)
    list_item = xbmcgui.ListItem(name)
    list_item.setArt({'icon': 'DefaultTVShows.png', 'thumb': thumb})
    list_item.setInfo(type='video', infoLabels={'title': name})
    if xbmcvfs.exists(fanart_file):
        list_item.setProperty('fanart_image', fanart_file)
    elif xbmcvfs.exists(cover_file):
        list_item.setProperty('fanart_image', cover_file)
    else:
        list_item.setProperty('fanart_image', utility.addon_fanart())
    entries.append((utility.get_string(30150),
                    'RunPlugin(plugin://%s/?mode=add_series_to_library&url=%s&name=%s&series_id=%s)' % (
                        utility.addon_id, urllib.quote_plus(unicode(url)),
                        urllib.quote_plus(utility.encode(series_name.strip())),
                        series_id)))
    list_item.addContextMenuItems(entries)
    directory_item = xbmcplugin.addDirectoryItem(handle=plugin_handle, url=u, listitem=list_item, isFolder=True)
    return directory_item
Ejemplo n.º 13
0
def directory(name, url, mode, thumb, type='', context_enable=True):
    entries = []
    name = utility.unescape(name)
    u = sys.argv[0]
    u += '?url=' + urllib.quote_plus(url)
    u += '&mode=' + mode
    u += '&thumb=' + urllib.quote_plus(thumb)
    u += '&type=' + type
    list_item = xbmcgui.ListItem(name)
    list_item.setArt({'icon': 'DefaultTVShows.png', 'thumb': thumb})
    list_item.setInfo(type='video', infoLabels={'title': name})
    if "/my-list" in url:
        entries.append((utility.get_string(30150),
                        'RunPlugin(plugin://%s/?mode=add_my_list_to_library)' %
                        utility.addon_id))
    list_item.setProperty('fanart_image', utility.addon_fanart())
    if context_enable:
        list_item.addContextMenuItems(entries)
    else:
        list_item.addContextMenuItems([], replaceItems=True)
    directory_item = xbmcplugin.addDirectoryItem(handle=plugin_handle,
                                                 url=u,
                                                 listitem=list_item,
                                                 isFolder=True)
    return directory_item
Ejemplo n.º 14
0
def choose():
    profiles = []
    content = utility.decode(connect.load_site(utility.profile_url))
    match = re.compile(
        '"experience":"(.+?)".+?guid":"(.+?)".+?profileName":"(.+?)"',
        re.DOTALL).findall(content)
    for is_kid, token, name in match:
        profile = {
            'name': utility.unescape(name),
            'token': token,
            'is_kid': is_kid == 'jfk'
        }
        profiles.append(profile)
    if len(match) > 0:
        dialog = xbmcgui.Dialog()
        nr = dialog.select(utility.get_string(30103),
                           [profile['name'] for profile in profiles])
        if nr >= 0:
            selected_profile = profiles[nr]
        else:
            selected_profile = profiles[0]
        connect.load_site(utility.profile_switch_url +
                          selected_profile['token'])
        utility.set_setting('selected_profile', selected_profile['token'])
        utility.set_setting('is_kid',
                            'true' if selected_profile['is_kid'] else 'false')
        utility.set_setting('profile_name', selected_profile['name'])
        connect.save_session()
        get_my_list_change_authorisation()
    else:
        utility.log('Choose profile: no profiles were found!',
                    loglevel=xbmc.LOGERROR)
Ejemplo n.º 15
0
def season(name, url, mode, thumb, series_name, series_id):
    entries = []
    cover_file, fanart_file = utility.cover_fanart(series_id)
    u = sys.argv[0]
    u += '?url=' + urllib.quote_plus(unicode(url))
    u += '&mode=' + mode
    u += '&series_id=' + urllib.quote_plus(series_id)
    list_item = xbmcgui.ListItem(name)
    list_item.setArt({'icon': 'DefaultTVShows.png', 'thumb': thumb})
    list_item.setInfo(type='video', infoLabels={'title': name})
    if xbmcvfs.exists(fanart_file):
        list_item.setProperty('fanart_image', fanart_file)
    elif xbmcvfs.exists(cover_file):
        list_item.setProperty('fanart_image', cover_file)
    else:
        list_item.setProperty('fanart_image', utility.addon_fanart())
    entries.append((utility.get_string(
        30150
    ), 'RunPlugin(plugin://%s/?mode=add_series_to_library&url=%s&name=%s&series_id=%s)'
                    % (utility.addon_id, urllib.quote_plus(unicode(url)),
                       urllib.quote_plus(utility.encode(
                           series_name.strip())), series_id)))
    list_item.addContextMenuItems(entries)
    directory_item = xbmcplugin.addDirectoryItem(handle=plugin_handle,
                                                 url=u,
                                                 listitem=list_item,
                                                 isFolder=True)
    return directory_item
Ejemplo n.º 16
0
def cache():
    try:
        xbmcvfs.rmdir(utility.cache_dir(), force=True)
        utility.log('Cache folder deleted.')
        utility.notification(utility.get_string(30309))
    except Exception:
        pass
Ejemplo n.º 17
0
def view_activity(video_type, run_as_widget=False):
    count = 0
    loading_progress = None
    if not run_as_widget:
        loading_progress = xbmcgui.DialogProgress()
        loading_progress.create('Netflix', utility.get_string(30205) + '...')
        utility.progress_window(loading_progress, 0, '...')
    xbmcplugin.setContent(plugin_handle, 'movies')
    if not xbmcvfs.exists(utility.session_file()):
        login.login()
    content = utility.decode(connect.load_site(utility.activity_url % (
    utility.get_setting('netflix_application'), utility.get_setting('netflix_id'),
    utility.get_setting('authorization_url'))))
    matches = json.loads(content)['viewedItems']
    try:
        for item in matches:
            series_id = 0
            is_episode = False
            video_id = unicode(item['movieID'])
            date = item['dateStr']
            try:
                series_id = item['series']
                series_title = item['seriesTitle']
                title = item['title']
                title = series_title + ' ' + title
            except Exception:
                title = item['title']
            if not run_as_widget:
                utility.progress_window(loading_progress, (count + 1) * 500 / len(matches), title)
            title = date + ' - ' + title
            if series_id > 0:
                is_episode = True
            added = video(video_id, title, '', is_episode, False, video_type, '')
            if added:
                count += 1
            if count == 20:
                break
    except Exception:
        utility.notification(utility.get_string(30306))
        pass
    if utility.get_setting('force_view') and not run_as_widget:
        xbmc.executebuiltin('Container.SetViewMode(' + utility.get_setting('view_id_activity') + ')')
    xbmcplugin.endOfDirectory(plugin_handle)
Ejemplo n.º 18
0
def trailer(video_type, title):
    content = search.tmdb(video_type, title)
    if content['total_results'] > 0:
        content = content['results'][0]
        tmdb_id = content['id']
        content = search.trailer(video_type, tmdb_id)
    else:
        utility.notification(utility.get_string(30305))
        content = None
    return content
Ejemplo n.º 19
0
def trailer(video_type, title):
    content = search.tmdb(video_type, title)
    if content['total_results'] > 0:
        content = content['results'][0]
        tmdb_id = content['id']
        content = search.trailer(video_type, tmdb_id)
    else:
        utility.notification(utility.get_string(30305))
        content = None
    return content
Ejemplo n.º 20
0
def main(video_type):
    add.directory(utility.get_string(30104), utility.main_url + '/browse/my-list', 'list_videos', '', video_type)
    add.directory(utility.get_string(30105), '', 'list_viewing_activity', '', video_type)
    add.directory(utility.get_string(30106), utility.main_url + '/browse/recently-added', 'list_videos', '', video_type)
    if video_type == 'tv':
        add.directory(utility.get_string(30107), utility.main_url + '/browse/genre/83', 'list_videos', '', video_type)
        add.directory(utility.get_string(30108), '', 'list_genres', '', video_type)
    else:
        add.directory(utility.get_string(30108), '', 'list_genres', '', video_type)
    add.directory(utility.get_string(30109), '', 'search', '', video_type)
    xbmcplugin.endOfDirectory(plugin_handle)
Ejemplo n.º 21
0
def login():
    login_progress = xbmcgui.DialogProgress()
    login_progress.create('Netflix', utility.get_string(30200) + '...')
    utility.progress_window(login_progress, 25, utility.get_string(30201))
    connect.session.cookies.clear()
    content = utility.decode(connect.load_site(utility.main_url + 'Login'))
    if not 'Sorry, Netflix ' in content:
        match = re.compile('name="authURL" value="(.+?)"', re.DOTALL).findall(content)
        utility.log('Setting authorization url: ' + match[0])
        utility.set_setting('authorization_url', match[0])
        match = re.compile('locale: "(.+?)"', re.DOTALL).findall(content)
        utility.set_setting('language', match[0])
        post_data = {'authURL': utility.get_setting('authorization_url'), 'email': utility.get_setting('username'),
                     'password': utility.get_setting('password'), 'RememberMe': 'on'}
        utility.progress_window(login_progress, 50, utility.get_string(30202))
        content = utility.decode(connect.load_site(utility.main_url + 'Login?locale=' +
                                                   utility.get_setting('language'), post=post_data))
        if 'id="page-LOGIN"' in content:
            utility.notification(utility.get_string(30303))
            return False
        match = re.compile('"apiUrl":"(.+?)",').findall(content)
        utility.set_setting('api_url', match[0])
        post_data = utility.my_list % utility.get_setting('authorization_url')
        content = utility.decode(connect.load_site(utility.evaluator(), post=post_data))
        matches = json.loads(content)['value']
        match = matches['lolomos'].keys()
        utility.set_setting('root_list', match[0])
        match = matches['lists'].keys()
        utility.set_setting('my_list', match[1])
        match = matches['lists'][utility.get_setting('my_list')]['trackIds']['trackId']
        utility.set_setting('track_id', unicode(match))
        connect.save_session()
        utility.progress_window(login_progress, 75, utility.get_string(30203))
        if not (utility.get_setting('selected_profile') or (utility.get_setting('single_profile') == 'true')):
            profiles.choose()
        elif not (utility.get_setting('single_profile') == 'true') and (utility.get_setting('show_profiles') == 'true'):
            profiles.choose()
        elif not ((utility.get_setting('single_profile') and utility.get_setting('show_profiles')) == 'true'):
            profiles.load()
        #if not utility.get_setting('is_kid') == 'true':
            #match = re.compile('"version":{"app":"(.+?)"').findall(content)
            #utility.set_setting('lolomos', match[0])
            #3a5922fa-a4a9-41d8-a08c-9e84c2d32be4_ROOT
        if login_progress:
            if not utility.progress_window(login_progress, 100, utility.get_string(30204)):
                return False
            xbmc.sleep(500)
            login_progress.close()
        return True
    else:
        utility.notification(utility.get_string(30300))
        if login_progress:
            login_progress.close()
        return False
Ejemplo n.º 22
0
def view_activity(video_type, run_as_widget=False):
    count = 0
    video_ids = []
    loading_progress = None
    if not run_as_widget:
        loading_progress = xbmcgui.DialogProgress()
        loading_progress.create('Netflix', utility.get_string(30205) + '...')
        utility.progress_window(loading_progress, 0, '...')
    xbmcplugin.setContent(plugin_handle, 'movies')
    if not xbmcvfs.exists(utility.session_file()):
        login.login()
    content = utility.decode(
        connect.load_site(utility.main_url + '/WiViewingActivity'))
    series_id = re.compile('(<li .*?data-series=.*?</li>)',
                           re.DOTALL).findall(content)
    for i in range(1, len(series_id), 1):
        entry = series_id[i]
        if not run_as_widget:
            utility.progress_window(loading_progress,
                                    (count + 1) * 100 / len(series_id), '...')
        match_id = re.compile('data-movieid="(.*?)"', re.DOTALL).findall(entry)
        if match_id:
            video_id = match_id[0]
        match = re.compile('class="col date nowrap">(.+?)<',
                           re.DOTALL).findall(entry)
        date = match[0]
        match_title1 = re.compile('class="seriestitle">(.+?)</a>',
                                  re.DOTALL).findall(entry)
        match_title2 = re.compile('class="col title">.+?>(.+?)<',
                                  re.DOTALL).findall(entry)
        if match_title1:
            title = utility.unescape(match_title1[0]).replace('</span>', '')
        elif match_title2:
            title = match_title2[0]
        else:
            title = ''
        title = date + ' - ' + title
        if video_id not in video_ids:
            video_ids.append(video_id)
            # due to limitations in the netflix api, there is no way to get the series_id of an
            # episode, so the 4 param is set to True to treat tv episodes the same as movies.
            added = video(video_id, title, '', True, False, video_type, '')
            if added:
                count += 1
            if count == 20:
                break
    if utility.get_setting('force_view') and not run_as_widget:
        xbmc.executebuiltin('Container.SetViewMode(' +
                            utility.get_setting('view_id_activity') + ')')
    xbmcplugin.endOfDirectory(plugin_handle)
Ejemplo n.º 23
0
def trailer(title, video_type):
    trailers = []
    content = get.trailer(video_type, title)
    if content:
        for match in content["results"]:
            if match["site"] == "YouTube":
                if match["iso_639_1"]:
                    name = match["name"] + " (" + match["iso_639_1"] + ")"
                else:
                    name = match["name"]
                match = {"name": name, "key": match["key"]}
                trailers.append(match)
        if len(trailers) > 0:
            dialog = xbmcgui.Dialog()
            nr = dialog.select("Trailer", [match["name"] for match in trailers])
            if nr >= 0:
                selected_trailer = trailers[nr]
                match = "PlayMedia(plugin://plugin.video.youtube/play/?video_id=%s)" % selected_trailer["key"]
                xbmc.executebuiltin(match)
        else:
            utility.notification(utility.get_string(30305))
    else:
        utility.notification(utility.get_string(30305))
        pass
Ejemplo n.º 24
0
def load_site(url, post=None):
    utility.log('Loading url: ' + url)
    try:
        if post:
            response = session.post(url, verify=True, data=post)
        else:
            response = session.get(url, verify=True)
    except AttributeError:
        utility.log('Session is missing', loglevel=xbmc.LOGERROR)
        utility.notification(utility.get_string(30301))
        new_session()
        save_session()
        if post:
            response = session.post(url, verify=True, data=post)
        else:
            response = session.get(url, verify=True)
    return response.content
Ejemplo n.º 25
0
def load_site(url, post=None):
    utility.log('Loading url: ' + url)
    try:
        if post:
            response = session.post(url, data=post)
        else:
            response = session.get(url)
    except AttributeError:
        utility.log('Session is missing', loglevel=xbmc.LOGERROR)
        utility.notification(utility.get_string(30301))
        new_session()
        save_session()
        if post:
            response = session.post(url, data=post)
        else:
            response = session.get(url)
    return response.content
Ejemplo n.º 26
0
def main(video_type):
    add.directory(utility.get_string(30104), 'my-list', 'list_videos', '',
                  video_type)
    add.directory(utility.get_string(30105), '', 'list_viewing_activity', '',
                  video_type)
    add.directory(utility.get_string(30106), 'recently-added', 'list_videos',
                  '', video_type)
    if video_type == 'tv':
        add.directory(utility.get_string(30107), 'genre?83', 'list_videos', '',
                      video_type)
        add.directory(utility.get_string(30108), '', 'list_genres', '',
                      video_type)
    else:
        add.directory(utility.get_string(30108), '', 'list_genres', '',
                      video_type)
    add.directory(utility.get_string(30109), '', 'search', '', video_type)
    xbmcplugin.endOfDirectory(plugin_handle)
Ejemplo n.º 27
0
def view_activity(video_type, run_as_widget=False):
    count = 0
    video_ids = []
    loading_progress = None
    if not run_as_widget:
        loading_progress = xbmcgui.DialogProgress()
        loading_progress.create('Netflix', utility.get_string(30205) + '...')
        utility.progress_window(loading_progress, 0, '...')
    xbmcplugin.setContent(plugin_handle, 'movies')
    if not xbmcvfs.exists(utility.session_file()):
        login.login()
    content = utility.decode(connect.load_site(utility.main_url + '/WiViewingActivity'))
    series_id = re.compile('(<li .*?data-series=.*?</li>)', re.DOTALL).findall(content)
    for i in range(1, len(series_id), 1):
        entry = series_id[i]
        if not run_as_widget:
            utility.progress_window(loading_progress, (count + 1) * 100 / len(series_id), '...')
        match_id = re.compile('data-movieid="(.*?)"', re.DOTALL).findall(entry)
        if match_id:
            video_id = match_id[0]
        match = re.compile('class="col date nowrap">(.+?)<', re.DOTALL).findall(entry)
        date = match[0]
        match_title1 = re.compile('class="seriestitle">(.+?)</a>', re.DOTALL).findall(entry)
        match_title2 = re.compile('class="col title">.+?>(.+?)<', re.DOTALL).findall(entry)
        if match_title1:
            title = utility.unescape(match_title1[0]).replace('</span>', '')
        elif match_title2:
            title = match_title2[0]
        else:
            title = ''
        title = date + ' - ' + title
        if video_id not in video_ids:
            video_ids.append(video_id)
            # due to limitations in the netflix api, there is no way to get the series_id of an
            # episode, so the 4 param is set to True to treat tv episodes the same as movies.
            added = video(video_id, title, '', True, False, video_type, '')
            if added:
                count += 1
            if count == 20:
                break
    if utility.get_setting('force_view') and not run_as_widget:
        xbmc.executebuiltin('Container.SetViewMode(' + utility.get_setting('view_id_activity') + ')')
    xbmcplugin.endOfDirectory(plugin_handle)
Ejemplo n.º 28
0
def load_site(url, headers=None, post=None, options=False, cookies=None):
    utility.log('Loading url: ' + url)
    try:
        if post:
            response = session.post(url,
                                    headers=headers,
                                    cookies=cookies,
                                    data=post,
                                    verify=certifi.where())
        elif options:
            response = session.options(url,
                                       headers=headers,
                                       cookies=cookies,
                                       verify=certifi.where())
        else:
            response = session.get(url,
                                   headers=headers,
                                   cookies=cookies,
                                   verify=certifi.where())
    except AttributeError:
        utility.log('Session is missing', loglevel=xbmc.LOGERROR)
        utility.notification(utility.get_string(30301))
        new_session()
        save_session()
        if post:
            response = session.post(url,
                                    headers=headers,
                                    cookies=cookies,
                                    data=post,
                                    verify=certifi.where())
        elif options:
            response = session.options(url,
                                       headers=headers,
                                       cookies=cookies,
                                       verify=certifi.where())
        else:
            response = session.get(url,
                                   headers=headers,
                                   cookies=cookies,
                                   verify=certifi.where())
    return response.content
Ejemplo n.º 29
0
def choose():
    profiles = []
    content = utility.decode(connect.load_site(utility.profile_url))
    match = json.loads(content)['profiles']
    for item in match:
        profile = {'name': item['firstName'], 'token': item['guid'], 'is_kid': item['experience'] == 'jfk'}
        profiles.append(profile)
    if len(match) > 0:
        dialog = xbmcgui.Dialog()
        nr = dialog.select(utility.get_string(30103), [profile['name'] for profile in profiles])
        if nr >= 0:
            selected_profile = profiles[nr]
        else:
            selected_profile = profiles[0]
        connect.load_site(utility.profile_switch_url + selected_profile['token'])
        utility.set_setting('selected_profile', selected_profile['token'])
        utility.set_setting('is_kid', 'true' if selected_profile['is_kid'] else 'false')
        utility.set_setting('profile_name', selected_profile['name'])
        connect.save_session()
    else:
        utility.log('Choose profile: no profiles were found!', loglevel=xbmc.LOGERROR)
Ejemplo n.º 30
0
def directory(name, url, mode, thumb, type='', context_enable=True):
    entries = []
    name = utility.unescape(name)
    u = sys.argv[0]
    u += '?url=' + urllib.quote_plus(url)
    u += '&mode=' + mode
    u += '&thumb=' + urllib.quote_plus(thumb)
    u += '&type=' + type
    list_item = xbmcgui.ListItem(name)
    list_item.setArt({'icon': 'DefaultTVShows.png', 'thumb': thumb})
    list_item.setInfo(type='video', infoLabels={'title': name})
    if "/my-list" in url:
        entries.append(
            (utility.get_string(30150), 'RunPlugin(plugin://%s/?mode=add_my_list_to_library)' % utility.addon_id))
    list_item.setProperty('fanart_image', utility.addon_fanart())
    if context_enable:
        list_item.addContextMenuItems(entries)
    else:
        list_item.addContextMenuItems([], replaceItems=True)
    directory_item = xbmcplugin.addDirectoryItem(handle=plugin_handle, url=u, listitem=list_item, isFolder=True)
    return directory_item
Ejemplo n.º 31
0
def choose():
    profiles = []
    content = utility.decode(connect.load_site(utility.profile_url))
    match = re.compile('"experience":"(.+?)".+?guid":"(.+?)".+?profileName":"(.+?)"', re.DOTALL).findall(content)
    for is_kid, token, name in match:
        profile = {"name": utility.unescape(name), "token": token, "is_kid": is_kid == "jfk"}
        profiles.append(profile)
    if len(match) > 0:
        dialog = xbmcgui.Dialog()
        nr = dialog.select(utility.get_string(30103), [profile["name"] for profile in profiles])
        if nr >= 0:
            selected_profile = profiles[nr]
        else:
            selected_profile = profiles[0]
        connect.load_site(utility.profile_switch_url + selected_profile["token"])
        utility.set_setting("selected_profile", selected_profile["token"])
        utility.set_setting("is_kid", "true" if selected_profile["is_kid"] else "false")
        utility.set_setting("profile_name", selected_profile["name"])
        connect.save_session()
        get_my_list_change_authorisation()
    else:
        utility.log("Choose profile: no profiles were found!", loglevel=xbmc.LOGERROR)
Ejemplo n.º 32
0
def choose():
    profiles = []
    content = utility.decode(connect.load_site(utility.profile_url))
    match = re.compile('"experience":"(.+?)".+?guid":"(.+?)".+?firstName":"(.+?)"', re.DOTALL).findall(content)
    for is_kid, token, name in match:
        profile = {'name': utility.unescape(name), 'token': token, 'is_kid': is_kid == 'jfk'}
        profiles.append(profile)
    if len(match) > 0:
        dialog = xbmcgui.Dialog()
        nr = dialog.select(utility.get_string(30103), [profile['name'] for profile in profiles])
        if nr >= 0:
            selected_profile = profiles[nr]
        else:
            selected_profile = profiles[0]
        connect.load_site(utility.profile_switch_url + selected_profile['token'])
        utility.set_setting('selected_profile', selected_profile['token'])
        utility.set_setting('is_kid', 'true' if selected_profile['is_kid'] else 'false')
        utility.set_setting('profile_name', selected_profile['name'])
        connect.save_session()
        get_my_list_change_authorisation()
    else:
        utility.log('Choose profile: no profiles were found!', loglevel=xbmc.LOGERROR)
Ejemplo n.º 33
0
def video(name,
          url,
          mode,
          thumb,
          video_type='',
          description='',
          duration='',
          year='',
          mpaa='',
          director='',
          genre='',
          rating=0.0,
          playcount=0,
          remove=False):
    entries = []
    cover_file, fanart_file = utility.cover_fanart(url)
    if xbmcvfs.exists(cover_file):
        thumb = cover_file
    u = sys.argv[0]
    u += '?url=' + urllib.quote_plus(url)
    u += '&mode=' + mode
    u += '&name=' + urllib.quote_plus(utility.encode(name))
    u += '&thumb=' + urllib.quote_plus(thumb)
    list_item = xbmcgui.ListItem(name)
    list_item.setArt({'icon': 'DefaultTVShows.png', 'thumb': thumb})
    list_item.setInfo(type='video',
                      infoLabels={
                          'title': name,
                          'plot': description,
                          'duration': duration,
                          'year': int(year),
                          'mpaa': mpaa,
                          'director': director,
                          'genre': genre,
                          'rating': rating,
                          'playcount': playcount
                      })
    if xbmcvfs.exists(fanart_file):
        list_item.setProperty('fanart_image', fanart_file)
    elif xbmcvfs.exists(cover_file):
        list_item.setProperty('fanart_image', cover_file)
    else:
        list_item.setProperty('fanart_image', utility.addon_fanart())
    if video_type == 'tvshow':
        if utility.get_setting('browse_tv_shows') == 'true':
            entries.append((utility.get_string(
                30151
            ), 'Container.Update(plugin://%s/?mode=play_video_main&url=%s&thumb=%s)'
                            % (utility.addon_id, urllib.quote_plus(url),
                               urllib.quote_plus(thumb))))
        else:
            entries.append((utility.get_string(
                30152
            ), 'Container.Update(plugin://%s/?mode=list_seasons&url=%s&thumb=%s)'
                            % (utility.addon_id, urllib.quote_plus(url),
                               urllib.quote_plus(thumb))))
    if video_type != 'episode':
        entries.append(
            (utility.get_string(30153),
             'RunPlugin(plugin://%s/?mode=play_trailer&url=%s&type=%s)' %
             (utility.addon_id, urllib.quote_plus(
                 utility.encode(name)), video_type)))
        if remove:
            entries.append(
                (utility.get_string(30154),
                 'RunPlugin(plugin://%s/?mode=remove_from_queue&url=%s)' %
                 (utility.addon_id, urllib.quote_plus(url))))
        else:
            entries.append(
                (utility.get_string(30155),
                 'RunPlugin(plugin://%s/?mode=add_to_queue&url=%s)' %
                 (utility.addon_id, urllib.quote_plus(url))))
        entries.append((
            utility.get_string(30156),
            'Container.Update(plugin://%s/?mode=list_videos&url=%s&type=movie)'
            % (utility.addon_id,
               urllib.quote_plus(utility.main_url + 'WiMovie/' + url))))
        entries.append(
            (utility.get_string(30157),
             'Container.Update(plugin://%s/?mode=list_videos&url=%s&type=tv)' %
             (utility.addon_id,
              urllib.quote_plus(utility.main_url + 'WiMovie/' + url))))
    if video_type == 'tvshow':
        entries.append((
            utility.get_string(30150),
            'RunPlugin(plugin://%s/?mode=add_series_to_library&url=&name=%s&series_id=%s)'
            % (utility.addon_id, urllib.quote_plus(utility.encode(
                name.strip())), urllib.quote_plus(url))))
    elif video_type == 'movie':
        entries.append(
            (utility.get_string(30150),
             'RunPlugin(plugin://%s/?mode=add_movie_to_library&url=%s&name=%s)'
             % (utility.addon_id, urllib.quote_plus(url),
                urllib.quote_plus(utility.encode(name.strip())) + ' (' +
                unicode(year) + ')')))
    list_item.addContextMenuItems(entries)
    directory_item = xbmcplugin.addDirectoryItem(handle=plugin_handle,
                                                 url=u,
                                                 listitem=list_item,
                                                 isFolder=True)
    return directory_item
Ejemplo n.º 34
0
def login():
    login_progress = xbmcgui.DialogProgress()
    login_progress.create('Netflix', utility.get_string(30200) + '...')
    utility.progress_window(login_progress, 25, utility.get_string(30201))
    connect.session.cookies.clear()
    content = utility.decode(connect.load_site(utility.main_url + '/Login'))
    match = re.compile('"locale":"(.+?)"', re.DOTALL | re.IGNORECASE).findall(content)
    if match and not utility.get_setting('language'):
        utility.log('Setting language: ' + match[0])
        utility.set_setting('language', match[0])
    if not 'Sorry, Netflix ' in content:
        match = re.compile('id="signout".+?authURL=(.+?)"', re.DOTALL).findall(content)
        if match:
            utility.log('Setting authorization url: ' + match[0])
            utility.set_setting('authorization_url', match[0])
        if 'id="page-LOGIN"' in content:
            match = re.compile('name="authURL" value="(.+?)"', re.DOTALL).findall(content)
            utility.log('Setting authorization url: ' + match[0])
            utility.set_setting('authorization_url', match[0])
            post_data = {'authURL': match[0], 'email': utility.get_setting('username'),
                         'password': utility.get_setting('password'), 'RememberMe': 'on'}
            utility.progress_window(login_progress, 50, utility.get_string(30202))
            content = utility.decode(connect.load_site(utility.main_url + '/Login?locale=' +
                                                       utility.get_setting('language'), post=post_data))
            if 'id="page-LOGIN"' in content:
                utility.notification(utility.get_string(30303))
                return False
            match = re.compile('"locale":"(.+?)"', re.DOTALL | re.IGNORECASE).findall(content)
            if match and not utility.get_setting('language'):
                utility.log('Setting language: ' + match[0])
                utility.set_setting('language', match[0])
            match = re.compile('"country":"(.+?)"', re.DOTALL | re.IGNORECASE).findall(content)
            if match:
                utility.log('Setting country code: ' + match[0])
                utility.set_setting('country_code', match[0])
            connect.save_session()
            utility.progress_window(login_progress, 75, utility.get_string(30203))
        if not (utility.get_setting('selected_profile') or (utility.get_setting('single_profile') == 'true')):
            profiles.choose()
        elif not (utility.get_setting('single_profile') == 'true') and (utility.get_setting('show_profiles') == 'true'):
            profiles.choose()
        elif not (
                    (utility.get_setting('single_profile') == 'true') and (
                            utility.get_setting('show_profiles') == 'true')):
            profiles.load()
        else:
            profiles.get_my_list_change_authorisation()
        if not utility.get_setting('is_kid') == 'true':
            content = utility.decode(connect.load_site(utility.main_url + '/browse'))
            match = re.compile('"version":{"app":"(.+?)"').findall(content)
            netflix_application, netflix_id = match[0].split('-')
            utility.set_setting('netflix_application', netflix_application)
            utility.set_setting('netflix_id', netflix_id)
        if login_progress:
            if not utility.progress_window(login_progress, 100, utility.get_string(30204)):
                return False
            xbmc.sleep(500)
            login_progress.close()
        return True
    else:
        utility.notification(utility.get_string(30300))
        if login_progress:
            login_progress.close()
        return False
Ejemplo n.º 35
0
def login():
    login_progress = xbmcgui.DialogProgress()
    login_progress.create('Netflix', utility.get_string(30200) + '...')
    utility.progress_window(login_progress, 25, utility.get_string(30201))
    connect.session.cookies.clear()
    content = utility.decode(connect.load_site(utility.main_url + 'Login'))
    if not 'Sorry, Netflix ' in content:
        match = re.compile('name="authURL" value="(.+?)"',
                           re.DOTALL).findall(content)
        utility.log('Setting authorization url: ' + match[0])
        utility.set_setting('authorization_url', match[0])
        match = re.compile('locale: "(.+?)"', re.DOTALL).findall(content)
        utility.set_setting('language', match[0])
        post_data = {
            'authURL': utility.get_setting('authorization_url'),
            'email': utility.get_setting('username'),
            'password': utility.get_setting('password'),
            'RememberMe': 'on'
        }
        utility.progress_window(login_progress, 50, utility.get_string(30202))
        content = utility.decode(
            connect.load_site(utility.main_url + 'Login?locale=' +
                              utility.get_setting('language'),
                              post=post_data))
        if 'id="page-LOGIN"' in content:
            utility.notification(utility.get_string(30303))
            return False
        match = re.compile('"apiUrl":"(.+?)",').findall(content)
        utility.set_setting('api_url', match[0])
        post_data = utility.my_list % utility.get_setting('authorization_url')
        content = utility.decode(
            connect.load_site(utility.evaluator(), post=post_data))
        matches = json.loads(content)['value']
        match = matches['lolomos'].keys()
        utility.set_setting('root_list', match[0])
        match = matches['lists'].keys()
        utility.set_setting('my_list', match[1])
        match = matches['lists'][utility.get_setting(
            'my_list')]['trackIds']['trackId']
        utility.set_setting('track_id', unicode(match))
        connect.save_session()
        utility.progress_window(login_progress, 75, utility.get_string(30203))
        if not (utility.get_setting('selected_profile') or
                (utility.get_setting('single_profile') == 'true')):
            profiles.choose()
        elif not (utility.get_setting('single_profile') == 'true') and (
                utility.get_setting('show_profiles') == 'true'):
            profiles.choose()
        elif not ((utility.get_setting('single_profile')
                   and utility.get_setting('show_profiles')) == 'true'):
            profiles.load()
        #if not utility.get_setting('is_kid') == 'true':
        #match = re.compile('"version":{"app":"(.+?)"').findall(content)
        #utility.set_setting('lolomos', match[0])
        #3a5922fa-a4a9-41d8-a08c-9e84c2d32be4_ROOT
        if login_progress:
            if not utility.progress_window(login_progress, 100,
                                           utility.get_string(30204)):
                return False
            xbmc.sleep(500)
            login_progress.close()
        return True
    else:
        utility.notification(utility.get_string(30300))
        if login_progress:
            login_progress.close()
        return False
Ejemplo n.º 36
0
def videos(url, video_type, run_as_widget=False):
    loading_progress = None
    if not run_as_widget:
        loading_progress = xbmcgui.DialogProgress()
        loading_progress.create('Netflix', utility.get_string(30205) + '...')
        utility.progress_window(loading_progress, 0, '...')
    xbmcplugin.setContent(plugin_handle, 'movies')
    if not xbmcvfs.exists(utility.session_file()):
        login.login()
    '''
    the next part is necessary during the changing phase. Otherwise data are not available.
    '''
    if 'recently-added' in url:
        postdata = utility.recently_added % utility.get_setting('authorization_url')
        content = utility.decode(connect.load_site(utility.evaluator(), post=postdata))
    else:
        content = utility.decode(connect.load_site(url))
    if not 'id="page-LOGIN"' in content or url == 'recently-added':
        if utility.get_setting('single_profile') == 'true' and 'id="page-ProfilesGate"' in content:
            profiles.force_choose()
        else:
            if '<div id="queue"' in content:
                content = content[content.find('<div id="queue"'):]
            if not 'recently-added' in url:
                content = utility.clean_content(content)
            match = None
            if not match: match = re.compile('"\$type":"leaf",.*?"id":([0-9]+)', re.DOTALL).findall(content)
            print '1: ' + str(match)
            if not match: match = re.compile('<a href="\/watch\/([0-9]+)', re.DOTALL).findall(content)
            print '2: ' + str(match)
            if not match: match = re.compile('<span id="dbs(.+?)_.+?alt=".+?"', re.DOTALL).findall(content)
            print '3: ' + str(match)
            if not match: match = re.compile('<span class="title.*?"><a id="b(.+?)_', re.DOTALL).findall(content)
            print '4: ' + str(match)
            if not match: match = re.compile('"boxart":".+?","titleId":(.+?),', re.DOTALL).findall(content)
            print '5: ' + str(match)
            if not match: match = re.compile('WiPlayer\?movieid=([0-9]+?)&', re.DOTALL).findall(content)
            print '6: ' + str(match)
            if 'recently-added' in url:
                matches = json.loads(content)['value']['videos']
                for video_id in matches:
                    match.append(unicode(video_id))
            print '7: ' + str(match)
            print len(match)
            i = 1
            for video_id in match:
                if int(video_id) > 10000000 or 'recently-added' in url:
                    if not run_as_widget:
                        utility.progress_window(loading_progress, i * 100 / len(match), '...')
                    video(video_id, '', '', False, False, video_type, url)
                i += 1
            match1 = re.compile('&pn=(.+?)&', re.DOTALL).findall(url)
            match2 = re.compile('&from=(.+?)&', re.DOTALL).findall(url)
            match_api_root = re.compile('"API_ROOT":"(.+?)"', re.DOTALL).findall(content)
            match_api_base = re.compile('"API_BASE_URL":"(.+?)"', re.DOTALL).findall(content)
            match_identifier = re.compile('"BUILD_IDENTIFIER":"(.+?)"', re.DOTALL).findall(content)
            if 'agid=' in url and match_api_root and match_api_base and match_identifier:
                genre_id = url[url.find('agid=') + 5:]
                add.directory(utility.get_string(30110), match_api_root[0] + match_api_base[0] + '/' + match_identifier[
                    0] + '/wigenre?genreId=' + genre_id + '&full=false&from=51&to=100&_retry=0', 'list_videos', '',
                              video_type)
            elif match1:
                current_page = match1[0]
                next_page = str(int(current_page) + 1)
                add.directory(utility.get_string(30110),
                              url.replace('&pn=' + current_page + '&', '&pn=' + next_page + '&'), 'list_videos', '',
                              video_type)
            elif match2:
                current_from = match2[0]
                next_from = str(int(current_from) + 50)
                current_to = str(int(current_from) + 49)
                next_to = str(int(current_from) + 99)
                add.directory(utility.get_string(30110),
                              url.replace('&from=' + current_from + '&', '&from=' + next_from + '&').replace(
                                  '&to=' + current_to + '&', '&to=' + next_to + '&'), 'list_videos', '', video_type)
            if utility.get_setting('force_view') == 'true' and not run_as_widget:
                xbmc.executebuiltin('Container.SetViewMode(' + utility.get_setting('view_id_videos') + ')')
        xbmcplugin.endOfDirectory(plugin_handle)
    else:
        delete.cookies()
        utility.log('User is not logged in.', loglevel=xbmc.LOGERROR)
        utility.notification(utility.get_string(30303))
Ejemplo n.º 37
0
def videos(url, video_type, run_as_widget=False):
    loading_progress = None
    if not run_as_widget:
        loading_progress = xbmcgui.DialogProgress()
        loading_progress.create('Netflix', utility.get_string(30205) + '...')
        utility.progress_window(loading_progress, 0, '...')
    xbmcplugin.setContent(plugin_handle, 'movies')
    if not xbmcvfs.exists(utility.session_file()):
        login.login()
    content = utility.decode(connect.load_site(url))
    if not 'id="page-LOGIN"' in content:
        if utility.get_setting(
                'single_profile'
        ) == 'true' and 'id="page-ProfilesGate"' in content:
            profiles.force_choose()
        else:
            if '<div id="queue"' in content:
                content = content[content.find('<div id="queue"'):]
            content = utility.clean_content(content)
            match = None
            if not match:
                match = re.compile('"\$type":"leaf",.*?"id":([0-9]+)',
                                   re.DOTALL).findall(content)
            print '1: ' + str(match)
            if not match:
                match = re.compile('<a href="\/watch\/([0-9]+)',
                                   re.DOTALL).findall(content)
            print '2: ' + str(match)
            if not match:
                match = re.compile('<span id="dbs(.+?)_.+?alt=".+?"',
                                   re.DOTALL).findall(content)
            print '3: ' + str(match)
            if not match:
                match = re.compile('<span class="title.*?"><a id="b(.+?)_',
                                   re.DOTALL).findall(content)
            print '4: ' + str(match)
            if not match:
                match = re.compile('"boxart":".+?","titleId":(.+?),',
                                   re.DOTALL).findall(content)
            print '5: ' + str(match)
            if not match:
                match = re.compile('WiPlayer\?movieid=([0-9]+?)&',
                                   re.DOTALL).findall(content)
            print '6: ' + str(match)
            print len(match)
            i = 1
            for video_id in match:
                if int(video_id) > 10000000:
                    if not run_as_widget:
                        utility.progress_window(loading_progress,
                                                i * 100 / len(match), '...')
                    video(video_id, '', '', False, False, video_type, url)
                i += 1
            match1 = re.compile('&pn=(.+?)&', re.DOTALL).findall(url)
            match2 = re.compile('&from=(.+?)&', re.DOTALL).findall(url)
            match_api_root = re.compile('"API_ROOT":"(.+?)"',
                                        re.DOTALL).findall(content)
            match_api_base = re.compile('"API_BASE_URL":"(.+?)"',
                                        re.DOTALL).findall(content)
            match_identifier = re.compile('"BUILD_IDENTIFIER":"(.+?)"',
                                          re.DOTALL).findall(content)
            if 'agid=' in url and match_api_root and match_api_base and match_identifier:
                genre_id = url[url.find('agid=') + 5:]
                add.directory(
                    utility.get_string(30110),
                    match_api_root[0] + match_api_base[0] + '/' +
                    match_identifier[0] + '/wigenre?genreId=' + genre_id +
                    '&full=false&from=51&to=100&_retry=0', 'list_videos', '',
                    video_type)
            elif match1:
                current_page = match1[0]
                next_page = str(int(current_page) + 1)
                add.directory(
                    utility.get_string(30110),
                    url.replace('&pn=' + current_page + '&',
                                '&pn=' + next_page + '&'), 'list_videos', '',
                    video_type)
            elif match2:
                current_from = match2[0]
                next_from = str(int(current_from) + 50)
                current_to = str(int(current_from) + 49)
                next_to = str(int(current_from) + 99)
                add.directory(
                    utility.get_string(30110),
                    url.replace('&from=' + current_from + '&',
                                '&from=' + next_from + '&').replace(
                                    '&to=' + current_to + '&',
                                    '&to=' + next_to + '&'), 'list_videos', '',
                    video_type)
            if utility.get_setting(
                    'force_view') == 'true' and not run_as_widget:
                xbmc.executebuiltin('Container.SetViewMode(' +
                                    utility.get_setting('view_id_videos') +
                                    ')')
        xbmcplugin.endOfDirectory(plugin_handle)
    else:
        delete.cookies()
        utility.log('User is not logged in.', loglevel=xbmc.LOGERROR)
        utility.notification(utility.get_string(30303))
Ejemplo n.º 38
0
def login():
    login_progress = xbmcgui.DialogProgress()
    login_progress.create('Netflix', utility.get_string(30200) + '...')
    utility.progress_window(login_progress, 25, utility.get_string(30201))
    connect.session.cookies.clear()
    content = utility.decode(connect.load_site(utility.main_url + '/Login'))
    match = re.compile('"locale":"(.+?)"',
                       re.DOTALL | re.IGNORECASE).findall(content)
    if match and not utility.get_setting('language'):
        utility.log('Setting language: ' + match[0])
        utility.set_setting('language', match[0])
    if not 'Sorry, Netflix ' in content:
        match = re.compile('id="signout".+?authURL=(.+?)"',
                           re.DOTALL).findall(content)
        if match:
            utility.log('Setting authorization url: ' + match[0])
            utility.set_setting('authorization_url', match[0])
        if 'id="page-LOGIN"' in content:
            match = re.compile('name="authURL" value="(.+?)"',
                               re.DOTALL).findall(content)
            utility.log('Setting authorization url: ' + match[0])
            utility.set_setting('authorization_url', match[0])
            post_data = {
                'authURL': match[0],
                'email': utility.get_setting('username'),
                'password': utility.get_setting('password'),
                'RememberMe': 'on'
            }
            utility.progress_window(login_progress, 50,
                                    utility.get_string(30202))
            content = utility.decode(
                connect.load_site(utility.main_url + '/Login?locale=' +
                                  utility.get_setting('language'),
                                  post=post_data))
            if 'id="page-LOGIN"' in content:
                utility.notification(utility.get_string(30303))
                return False
            match = re.compile('"locale":"(.+?)"',
                               re.DOTALL | re.IGNORECASE).findall(content)
            if match and not utility.get_setting('language'):
                utility.log('Setting language: ' + match[0])
                utility.set_setting('language', match[0])
            match = re.compile('"country":"(.+?)"',
                               re.DOTALL | re.IGNORECASE).findall(content)
            if match:
                utility.log('Setting country code: ' + match[0])
                utility.set_setting('country_code', match[0])
            connect.save_session()
            utility.progress_window(login_progress, 75,
                                    utility.get_string(30203))
        if not (utility.get_setting('selected_profile') or
                (utility.get_setting('single_profile') == 'true')):
            profiles.choose()
        elif not (utility.get_setting('single_profile') == 'true') and (
                utility.get_setting('show_profiles') == 'true'):
            profiles.choose()
        elif not ((utility.get_setting('single_profile') == 'true') and
                  (utility.get_setting('show_profiles') == 'true')):
            profiles.load()
        else:
            profiles.get_my_list_change_authorisation()
        if not utility.get_setting('is_kid') == 'true':
            content = utility.decode(
                connect.load_site(utility.main_url + '/browse'))
            match = re.compile('"version":{"app":"(.+?)"').findall(content)
            netflix_application, netflix_version = match[0].split('-')
            utility.set_setting('netflix_application', netflix_application)
            utility.set_setting('netflix_version', netflix_version)
        if login_progress:
            if not utility.progress_window(login_progress, 100,
                                           utility.get_string(30204)):
                return False
            xbmc.sleep(500)
            login_progress.close()
        return True
    else:
        utility.notification(utility.get_string(30300))
        if login_progress:
            login_progress.close()
        return False
Ejemplo n.º 39
0
def force_choose():
    utility.set_setting('single_profile', 'false')
    utility.notification(utility.get_string(30304))
    choose()
Ejemplo n.º 40
0
def force_choose():
    utility.set_setting("single_profile", "false")
    utility.notification(utility.get_string(30304))
    choose()
Ejemplo n.º 41
0
def force_choose():
    utility.set_setting('single_profile', 'false')
    utility.notification(utility.get_string(30304))
    choose()