Ejemplo n.º 1
0
def cookies():
    if xbmcvfs.exists(generic_utility.cookies_file()):
        xbmcvfs.delete(generic_utility.cookies_file())
        generic_utility.notification(generic_utility.get_string(30301))

    if xbmcvfs.exists(generic_utility.headers_file()):
        xbmcvfs.delete(generic_utility.headers_file())
        generic_utility.notification(generic_utility.get_string(30302))
Ejemplo n.º 2
0
def cookies():
    if xbmcvfs.exists(generic_utility.cookies_file()):
        xbmcvfs.delete(generic_utility.cookies_file())
        generic_utility.notification(generic_utility.get_string(30301))

    if xbmcvfs.exists(generic_utility.headers_file()):
        xbmcvfs.delete(generic_utility.headers_file())
        generic_utility.notification(generic_utility.get_string(30302))
Ejemplo n.º 3
0
def viewing_activity_matches(video_type):
    if not xbmcvfs.exists(generic_utility.cookies_file()):
        login.login()
    content = viewing_activity_info()
    matches = json.loads(content)['viewedItems']

    metadata = []
    #    utility.log('activity: '+unicode(matches))
    for match in matches:
        #        utility.log(match)

        if 'seriesTitle' in match:
            metadata_type = 'tv'
            series_title = match['seriesTitle']
        else:
            metadata_type = 'movie'
            series_title = None

        if video_type == metadata_type:
            metadata.append({
                'id': unicode(match['movieID']),
                'title': get_viewing_activity_title(match),
                'series_title': series_title
            })

    return metadata
Ejemplo n.º 4
0
def videos_matches(video_type, page, url):
    post_data = ''
    if not xbmcvfs.exists(generic_utility.cookies_file()):
        login.login()

    items_per_page = int(generic_utility.get_setting('items_per_page'))
    off_from = page * items_per_page
    off_to = off_from + items_per_page - 2

    if 'genre' in url:
        post_data = generic_utility.genre % (
            url.split('?')[1], off_from, off_to,
            generic_utility.get_setting('authorization_url'))
    elif 'list?' in url:
        data = url.split('?')[1]
        if ('mylist' in data):
            list_id = data.split('&')[0]
        else:
            list_id = data
        post_data = generic_utility.list_paths % (
            list_id, off_from, off_to,
            generic_utility.get_setting('authorization_url'))

    target_url = generic_utility.evaluator()
    response = connect.load_netflix_site(target_url, post=post_data)
    #    utility.log('response: '+response)
    video_ids = extract_other_video_ids(response, video_type)
    return video_ids
Ejemplo n.º 5
0
def save_cookies(session):
    cookies =  pickle.dumps(requests.utils.dict_from_cookiejar(session.cookies))

    if test == False:
        file_name = generic_utility.cookies_file()
    else:
        file_name = 'cookies'

    file_utility.write(file_name, cookies)
Ejemplo n.º 6
0
def save_cookies(session):
    cookies =  pickle.dumps(session.cookies)

    if test == False:
        file_name = generic_utility.cookies_file()
    else:
        file_name = 'cookies'

    file_utility.write(file_name, cookies)
Ejemplo n.º 7
0
def save_cookies(session):
    cookies = pickle.dumps(requests.utils.dict_from_cookiejar(session.cookies))

    if test == False:
        file_name = generic_utility.cookies_file()
    else:
        file_name = 'cookies'

    file_utility.write(file_name, cookies)
Ejemplo n.º 8
0
def save_cookies(session):
    cookies = pickle.dumps(session.cookies)

    if test == False:
        file_name = generic_utility.cookies_file()
    else:
        file_name = 'cookies'

    file_utility.write(file_name, cookies)
Ejemplo n.º 9
0
def read_cookies():
    if test == False:
        file_name = generic_utility.cookies_file()
    else:
        file_name = 'cookies'
    content = file_utility.read(file_name)
    if len(content) > 0:
        return requests.utils.cookiejar_from_dict(pickle.loads(content))
    else:
        generic_utility.log('warning, read empty cookies-file')
        return None
Ejemplo n.º 10
0
def read_cookies():
    if test == False:
        file_name = generic_utility.cookies_file()
    else:
        file_name = 'cookies'
    content = file_utility.read(file_name)
    if len(content) > 0:
        return requests.utils.cookiejar_from_dict(pickle.loads(content))
    else:
        generic_utility.log('warning, read empty cookies-file')
        return None
Ejemplo n.º 11
0
def read_cookies():
    if not test:
        file_name = generic_utility.cookies_file()
    else:
        file_name = 'cookies'
    content = file_utility.read(file_name)
    if len(content) > 0:
        loaded = pickle.loads(content)
        if type(loaded) == requests.cookies.RequestsCookieJar:
            return loaded
        else:
            return None
    else:
        generic_utility.log('warning, read empty cookies-file')
        return None
Ejemplo n.º 12
0
def read_cookies():
    if not test:
        file_name = generic_utility.cookies_file()
    else:
        file_name = 'cookies'
    content = file_utility.read(file_name)
    if len(content) > 0:
        loaded = pickle.loads(content)
        if type(loaded) == requests.cookies.RequestsCookieJar:
            return loaded
        else:
            return None
    else:
        generic_utility.log('warning, read empty cookies-file')
        return None
Ejemplo n.º 13
0
def genre_data(video_type):
    match = []
    if not xbmcvfs.exists(generic_utility.cookies_file()):
        login.login()

    content = genre_info(video_type)

    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
    return match
Ejemplo n.º 14
0
def genre_data(video_type):
    match = []
    if not xbmcvfs.exists(generic_utility.cookies_file()):
        login.login()

    content = genre_info(video_type)

    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
    return match
Ejemplo n.º 15
0
def viewing_activity_matches(video_type):
    if not xbmcvfs.exists(generic_utility.cookies_file()):
        login.login()
    content = viewing_activity_info()
    matches = json.loads(content)['viewedItems']

    metadata = []
#    utility.log('activity: '+unicode(matches))
    for match in matches:
#        utility.log(match)

        if 'seriesTitle' in match:
            metadata_type = 'tv'
            series_title = match['seriesTitle']
        else:
            metadata_type = 'movie'
            series_title = None

        if video_type == metadata_type:
            metadata.append({'id':unicode(match['movieID']), 'title':get_viewing_activity_title(match), 'series_title':series_title})

    return metadata
Ejemplo n.º 16
0
def videos_matches(video_type, page, url):
    post_data = ''
    if not xbmcvfs.exists(generic_utility.cookies_file()):
        login.login()

    items_per_page = int(generic_utility.get_setting('items_per_page'))
    off_from = page * items_per_page
    off_to = off_from + items_per_page - 2

    if 'genre' in url:
        post_data = generic_utility.genre % (url.split('?')[1], off_from, off_to, generic_utility.get_setting('authorization_url'))
    elif 'list?' in url:
        data = url.split('?')[1]
        if('mylist' in data):
            list_id = data.split('&')[0]
        else:
            list_id = data
        post_data = generic_utility.list_paths % (list_id, off_from, off_to, generic_utility.get_setting('authorization_url'))

    target_url = generic_utility.evaluator()
    response = connect.load_netflix_site(target_url, post=post_data)
#    utility.log('response: '+response)
    video_ids = extract_other_video_ids(response, video_type)
    return video_ids
Ejemplo n.º 17
0
def search_matches(search_string, video_type):
    if not xbmcvfs.exists(generic_utility.cookies_file()):
        login.login()
    content = search_results(search_string)
    return extract_other_video_ids(content, video_type)
Ejemplo n.º 18
0
def search_matches(search_string, video_type):
    if not xbmcvfs.exists(generic_utility.cookies_file()):
        login.login()
    content = search_results(search_string)
    return extract_other_video_ids(content, video_type)