Пример #1
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
Пример #2
0
def genres(video_type):
    post_data = ''
    match = []
    xbmcplugin.addSortMethod(plugin_handle, xbmcplugin.SORT_METHOD_LABEL)
    if not xbmcvfs.exists(utility.session_file()):
        login.login()
    if video_type == 'tv':
        post_data = '{"paths":[["genres",83,"subgenres",{"from":0,"to":20},"summary"],["genres",83,"subgenres",' \
                    '"summary"]],"authURL":"%s"}' % utility.get_setting('authorization_url')
    elif video_type == 'movie':
        post_data = '{"paths":[["genreList",{"from":0,"to":24},["id","menuName"]],["genreList"]],"authURL":"%s"}' \
                    % utility.get_setting('authorization_url')
    else:
        pass
    content = utility.decode(connect.load_site(utility.evaluator(), post=post_data))
    matches = json.loads(content)['value']['genres']
    for item in matches:
        try:
            match.append((unicode(matches[item]['id']), matches[item]['menuName']))
        except Exception:
            try:
                match.append((unicode(matches[item]['summary']['id']), matches[item]['summary']['menuName']))
            except Exception:
                pass
    for genre_id, title in match:
        if video_type == 'tv':
            add.directory(title, utility.main_url + '/browse/genre/' + genre_id + '?bc=83', 'list_videos', '',
                          video_type)
        elif not genre_id == '83' and video_type == 'movie':
            add.directory(title, utility.main_url + '/browse/genre/' + genre_id, 'list_videos', '', video_type)
    xbmcplugin.endOfDirectory(plugin_handle)
Пример #3
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)
Пример #4
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
Пример #5
0
def genres(video_type):
    post_data = ''
    match = []
    xbmcplugin.addSortMethod(plugin_handle, xbmcplugin.SORT_METHOD_LABEL)
    if not xbmcvfs.exists(utility.session_file()):
        login.login()
    if video_type == 'tv':
        post_data = utility.series_genre % utility.get_setting(
            'authorization_url')
    elif video_type == 'movie':
        post_data = utility.movie_genre % utility.get_setting(
            'authorization_url')
    else:
        pass
    content = utility.decode(
        connect.load_site(utility.evaluator(), post=post_data))
    matches = json.loads(content)['value']['genres']
    for item in matches:
        try:
            match.append(
                (unicode(matches[item]['id']), matches[item]['menuName']))
        except Exception:
            try:
                match.append((unicode(matches[item]['summary']['id']),
                              matches[item]['summary']['menuName']))
            except Exception:
                pass
    for genre_id, title in match:
        if video_type == 'tv':
            add.directory(title, 'genre?' + genre_id, 'list_videos', '',
                          video_type)
        elif not genre_id == '83' and video_type == 'movie':
            add.directory(title, 'genre?' + genre_id, 'list_videos', '',
                          video_type)
    xbmcplugin.endOfDirectory(plugin_handle)
Пример #6
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)
Пример #7
0
def genres(video_type):
    post_data = ''
    match = []
    xbmcplugin.addSortMethod(plugin_handle, xbmcplugin.SORT_METHOD_LABEL)
    if not xbmcvfs.exists(utility.session_file()):
        login.login()
    if video_type == 'tv':
        post_data = utility.series_genre % utility.get_setting('authorization_url')
    elif video_type == 'movie':
        post_data = utility.movie_genre % utility.get_setting('authorization_url')
    else:
        pass
    content = utility.decode(connect.load_site(utility.evaluator(), post=post_data))
    matches = json.loads(content)['value']['genres']
    for item in matches:
        try:
            match.append((unicode(matches[item]['id']), matches[item]['menuName']))
        except Exception:
            try:
                match.append((unicode(matches[item]['summary']['id']), matches[item]['summary']['menuName']))
            except Exception:
                pass
    for genre_id, title in match:
        if video_type == 'tv':
            add.directory(title, 'genre?' + genre_id, 'list_videos', '', video_type)
        elif not genre_id == '83' and video_type == 'movie':
            add.directory(title, 'genre?' + genre_id, 'list_videos', '', video_type)
    xbmcplugin.endOfDirectory(plugin_handle)
Пример #8
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
Пример #9
0
def add(video_id):
    post_data = utility.my_list % utility.get_setting('authorization_url')
    content = utility.decode(
        connect.load_site(utility.evaluator(), post=post_data))
    match = json.loads(content)['value']['videos']
    headers = {
        'Access-Control-Request-Headers': 'content-type, accept',
        'Access-Control-Request-Method': 'POST',
        'Origin': 'http://www.netflix.com'
    }
    content = utility.decode(
        connect.load_site(utility.evaluator() + '&method=call',
                          options=True,
                          headers=headers))
    print content
    cookies = {
        'lhpuuidh-browse-' + utility.get_setting('selected_profile'):
        urllib.quote_plus(
            utility.get_setting('language').split('-')[1] + ':' +
            utility.get_setting('language').upper() + ':' +
            utility.get_setting('root_list')),
        'SecureNetflixId':
        'v%3D2%26mac%3DAQEAEQABABRkPnYy2LvtMo02JH3beZhI4vKJAM2mLeM.%26dt%3D1449696369549'
    }
    post_data = utility.add_list % (
        utility.get_setting('root_list'), utility.get_setting('my_list'),
        video_id, utility.get_setting('track_id'), unicode(
            len(match)), utility.get_setting('authorization_url'))
    headers = {
        'Referer': 'http://www.netflix.com/browse',
        'Origin': 'http://www.netflix.com'
    }
    print post_data
    content = utility.decode(
        connect.load_site(utility.evaluator() + '&method=call',
                          cookies=cookies,
                          headers=headers,
                          post=post_data))
    print content
Пример #10
0
def add(video_id):
    post_data = utility.my_list % utility.get_setting('authorization_url')
    content = utility.decode(connect.load_site(utility.evaluator(), post=post_data))
    match = json.loads(content)['value']['videos']
    headers = {'Access-Control-Request-Headers': 'content-type, accept','Access-Control-Request-Method': 'POST',
               'Origin': 'http://www.netflix.com'}
    content = utility.decode(connect.load_site(utility.evaluator()+'&method=call', options=True, headers=headers))
    print content
    cookies = {'lhpuuidh-browse-' + utility.get_setting('selected_profile'): urllib.quote_plus(utility.get_setting('language').split('-')[1] + ':' + utility.get_setting('language').upper() + ':' + utility.get_setting('root_list')), 'SecureNetflixId': 'v%3D2%26mac%3DAQEAEQABABRkPnYy2LvtMo02JH3beZhI4vKJAM2mLeM.%26dt%3D1449696369549'}
    post_data = utility.add_list % (utility.get_setting('root_list'),
                                    utility.get_setting('my_list'),
                                    video_id,
                                    utility.get_setting('track_id'),
                                    unicode(len(match)),
                                    utility.get_setting('authorization_url'))
    headers = {'Referer': 'http://www.netflix.com/browse',
               'Origin': 'http://www.netflix.com'}
    print post_data
    content = utility.decode(connect.load_site(utility.evaluator()+'&method=call',
                                               cookies=cookies,
                                               headers=headers,
                                               post=post_data))
    print content
Пример #11
0
def video_info(video_id):
    content = ''
    cache_file = xbmc.translatePath(utility.cache_dir() + video_id + '.cache')
    if xbmcvfs.exists(cache_file):
        file_handler = xbmcvfs.File(cache_file, 'rb')
        content = file_handler.read()
        file_handler.close()
    if not content:
        post_data = utility.video_info % (video_id, video_id, video_id, video_id,
                                         utility.get_setting('authorization_url'))
        content = connect.load_site(utility.evaluator(), post=post_data)
        file_handler = xbmcvfs.File(cache_file, 'wb')
        file_handler.write(content)
        file_handler.close()
    return utility.decode(content)
Пример #12
0
def video_info(video_id):
    content = ''
    cache_file = xbmc.translatePath(utility.cache_dir() + video_id + '.cache')
    if xbmcvfs.exists(cache_file):
        file_handler = xbmcvfs.File(cache_file, 'rb')
        content = file_handler.read()
        file_handler.close()
    if not content:
        postdata = '{"paths":[["videos",{media_id},["bookmarkPosition","details","episodeCount","maturity","queue",' \
                   '"releaseYear","requestId","runtime","seasonCount","summary","title","userRating","watched"]],' \
                   '["videos",{media_id},"boxarts",["_342x192","_665x375"],"jpg"]],"authURL":"{authorization_url}"}' \
            .replace('{media_id}', video_id).replace('{authorization_url}', utility.get_setting('authorization_url'))
        content = connect.load_site(utility.evaluator(), post=postdata)
        file_handler = xbmcvfs.File(cache_file, 'wb')
        file_handler.write(content)
        file_handler.close()
    return utility.decode(content)
Пример #13
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))
Пример #14
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