Exemplo n.º 1
0
def main(video_type):
    add.directory(generic_utility.get_string(30105), '',
                  'list_viewing_activity', '', video_type)

    if video_type == 'show':
        add.directory(generic_utility.get_string(30107), 'genre?83',
                      'list_videos', '', video_type)
        add.directory(generic_utility.get_string(30108), '', 'list_genres', '',
                      video_type)

    elif video_type == 'movie':
        add.directory(generic_utility.get_string(30108), '', 'list_genres', '',
                      video_type)
    elif video_type == 'dynamic':
        add_dynamic_lists()

    if video_type != 'dynamic' and generic_utility.get_setting(
            'is_kid') == 'false':
        try:
            root_list = lolomos.get_root_list()
        except AttributeError:
            if connect.do_login():
                root_list = lolomos.get_root_list()
            else:
                raise Exception("Cannot login")
        mylist = lolomos.get_mylist(root_list)
        add.directory(child('displayName', mylist[1]), 'list?&mylist',
                      'list_videos', '', video_type)

    add.directory(generic_utility.get_string(30109), '', 'search', '',
                  video_type)
    xbmcplugin.endOfDirectory(plugin_handle, cacheToDisc=False)
Exemplo n.º 2
0
def index():
    add.directory(generic_utility.get_string(30100),
                  '',
                  'main',
                  '',
                  'movie',
                  login_context=True)
    add.directory(generic_utility.get_string(30101),
                  '',
                  'main',
                  '',
                  'show',
                  login_context=True)

    add.directory(generic_utility.get_string(30102),
                  '',
                  'main',
                  '',
                  'dynamic',
                  login_context=True)

    if not generic_utility.get_setting('single_profile') == 'true':
        add.item(generic_utility.get_string(30103) + ' - [COLOR FF8E0000]' +
                 generic_utility.get_setting('profile_name') + '[/COLOR]',
                 'choose_profile',
                 login_context=True)
    xbmcplugin.endOfDirectory(plugin_handle)
Exemplo n.º 3
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:
            generic_utility.notification(generic_utility.get_string(30305))
    else:
        generic_utility.notification(generic_utility.get_string(30305))
        pass
Exemplo n.º 4
0
def main(video_type):
    add.directory(generic_utility.get_string(30105), '',
                  'list_viewing_activity', '', video_type)

    if video_type == 'show':
        add.directory(generic_utility.get_string(30107), 'genre?83',
                      'list_videos', '', video_type)
        add.directory(generic_utility.get_string(30108), '', 'list_genres', '',
                      video_type)

    elif video_type == 'movie':
        add.directory(generic_utility.get_string(30108), '', 'list_genres', '',
                      video_type)
    elif video_type == 'dynamic':
        add_dynamic_lists()

    if video_type != 'dynamic':
        root_list = lolomos.get_root_list()
        mylist = lolomos.get_mylist(root_list)
        add.directory(child('displayName', mylist[1]), 'list?&mylist',
                      'list_videos', '', video_type)

    add.directory(generic_utility.get_string(30109), '', 'search', '',
                  video_type)
    xbmcplugin.endOfDirectory(plugin_handle, cacheToDisc=False)
Exemplo n.º 5
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))
Exemplo n.º 6
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))
Exemplo n.º 7
0
def index():
    add.directory(generic_utility.get_string(30100), '', 'main', '', 'movie', login_context=True)
    add.directory(generic_utility.get_string(30101), '', 'main', '', 'tv', login_context=True)
    add.directory(generic_utility.get_string(30102), '', 'wi_home', '', 'both', login_context=True)
    if not generic_utility.get_setting('single_profile') == 'true':
        add.item(
            generic_utility.get_string(30103) + ' - [COLOR FF8E0000]' + generic_utility.get_setting('profile_name') + '[/COLOR]',
            'choose_profile', login_context=True)
    xbmcplugin.endOfDirectory(plugin_handle)
Exemplo n.º 8
0
def addon():
    dialog = xbmcgui.Dialog()
    if dialog.yesno(generic_utility.addon_name + ':', generic_utility.get_string(30307)):
        try:
            xbmcvfs.rmdir(generic_utility.data_dir(), force=True)
            generic_utility.log('Addon userdata folder deleted.')
            generic_utility.notification(generic_utility.get_string(30308))
        except Exception:
            pass
Exemplo n.º 9
0
def addon():
    dialog = xbmcgui.Dialog()
    if dialog.yesno(generic_utility.addon_name + ':',
                    generic_utility.get_string(30307)):
        try:
            xbmcvfs.rmdir(generic_utility.data_dir(), force=True)
            generic_utility.log('Addon userdata folder deleted.')
            generic_utility.notification(generic_utility.get_string(30308))
        except Exception:
            pass
Exemplo n.º 10
0
def main(video_type):
    add.directory(generic_utility.get_string(30105), '', 'list_viewing_activity', '', video_type)

    add_dynamic_lists(video_type)
    if video_type == 'tv':
        add.directory(generic_utility.get_string(30107), 'genre?83', 'list_videos', '', video_type)
        add.directory(generic_utility.get_string(30108), '', 'list_genres', '', video_type)
    else:
        add.directory(generic_utility.get_string(30108), '', 'list_genres', '', video_type)
    add.directory(generic_utility.get_string(30109), '', 'search', '', video_type)
    xbmcplugin.endOfDirectory(plugin_handle)
Exemplo n.º 11
0
def main(video_type):
    add.directory(generic_utility.get_string(30105), '', 'list_viewing_activity', '', video_type)

    add_dynamic_lists(video_type)
    if video_type == 'tv':
        add.directory(generic_utility.get_string(30107), 'genre?83', 'list_videos', '', video_type)
        add.directory(generic_utility.get_string(30108), '', 'list_genres', '', video_type)
    else:
        add.directory(generic_utility.get_string(30108), '', 'list_genres', '', video_type)
    add.directory(generic_utility.get_string(30109), '', 'search', '', video_type)
    xbmcplugin.endOfDirectory(plugin_handle)
Exemplo n.º 12
0
def read_lists(falkor_cache):

    mylist_id = extract_mylist_id(falkor_cache)

    lists = falkor_cache['lists']
    lists = filter_size(lists)
    rets = []
    videos=[]

    list_contains_mylist = False
    for list_key in lists:
        list = lists[list_key]
        list = filter_size(list)
        if 'displayName' in list:
            if list_key == mylist_id:
                list_contains_mylist = True
            display_name = unicode(list['displayName']['value'])
            ret = {'id': list_key, 'name': display_name}
            rets.append(ret)

    if not list_contains_mylist:
        ret = {'id': mylist_id, 'name': generic_utility.get_string(30104)}
        rets.append(ret)

    return rets
Exemplo n.º 13
0
def show_loading_progress(run_as_widget):
    loading_progress = None
    if not run_as_widget:
        loading_progress = xbmcgui.DialogProgress()
        loading_progress.create('Netflix', generic_utility.get_string(30205) + '...')
        generic_utility.progress_window(loading_progress, 0, '...')
    return loading_progress
Exemplo n.º 14
0
def load_videos_to_directory(loading_progress,
                             run_as_widget,
                             metadatas,
                             video_type,
                             page=None,
                             url=None,
                             viewing_activity=False):
    video_metadatas = multiprocessor.load_data(metadatas, video_type,
                                               run_as_widget, loading_progress,
                                               url, viewing_activity)
    removable = url != None and 'my-list' in url

    sorted_video_metadata = sorted(video_metadatas,
                                   key=lambda t: t['title'],
                                   reverse=viewing_activity)
    for video_metadata in sorted_video_metadata:
        if (video_metadata != None):
            video_add(video_metadata, removable, viewing_activity)


#    generic_utility.log(url)

    items_per_page = int(generic_utility.get_setting('items_per_page'))
    if ((url == None or 'list_viewing_activity' not in url)
            and len(video_metadatas) == items_per_page):
        add.add_next_item('Next', page + 1, url, video_type, 'list_videos', '')
    if len(video_metadatas) == 0:
        generic_utility.notification(generic_utility.get_string(30306))
    add_sort_methods()
Exemplo n.º 15
0
def choose():
    profiles = []
    content = connect.load_netflix_site(generic_utility.profile_url)
    #    generic_utility.log('choose: '+content)
    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(generic_utility.get_string(30103),
                           [profile['name'] for profile in profiles])
        if nr >= 0:
            selected_profile = profiles[nr]
        else:
            selected_profile = profiles[0]

        switch_profile(selected_profile['token'])

        generic_utility.set_setting('selected_profile',
                                    selected_profile['token'])
        generic_utility.set_setting(
            'is_kid', 'true' if selected_profile['is_kid'] else 'false')
        generic_utility.set_setting('profile_name', selected_profile['name'])
    else:
        generic_utility.log('Choose profile: no profiles were found!',
                            loglevel=xbmc.LOGERROR)
Exemplo n.º 16
0
def show_loading_progress(run_as_widget):
    loading_progress = None
    if not run_as_widget:
        loading_progress = xbmcgui.DialogProgress()
        loading_progress.create('Netflix', generic_utility.get_string(30205) + '...')
        generic_utility.progress_window(loading_progress, 0, '...')
    return loading_progress
Exemplo n.º 17
0
def directory(name, url, mode, thumb, type='', context_enable=True, login_context = False):
    entries = []
    name = generic_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(
            (generic_utility.get_string(30150), 'RunPlugin(plugin://%s/?mode=add_my_list_to_library)' % generic_utility.addon_id))
    list_item.setProperty('fanart_image', generic_utility.addon_fanart())
    if context_enable:
        if login_context == True:
            entries.append(('Relogin',
                            'RunPlugin(plugin://%s/?mode=relogin)' % (
                                generic_utility.addon_id)))

        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
Exemplo n.º 18
0
def directory(name,
              url,
              mode,
              thumb,
              type='',
              context_enable=True,
              login_context=False):
    entries = []
    name = generic_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((generic_utility.get_string(30150),
                        'RunPlugin(plugin://%s/?mode=add_my_list_to_library)' %
                        generic_utility.addon_id))
    list_item.setProperty('fanart_image', generic_utility.addon_fanart())
    if context_enable:
        if login_context == True:
            entries.append(('Relogin', 'RunPlugin(plugin://%s/?mode=relogin)' %
                            (generic_utility.addon_id)))

        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
Exemplo n.º 19
0
def season(name, url, thumb, series_name, series_id):
    entries = []
    cover_file, fanart_file = generic_utility.cover_fanart(series_id)
    u = sys.argv[0]
    u += '?url=' + urllib.quote_plus(unicode(url))
    u += '&mode=list_episodes'
    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', generic_utility.addon_fanart())
    entries.append((
        generic_utility.get_string(30150),
        'RunPlugin(plugin://%s/?mode=add_series_to_library&url=%s&name=%s&series_id=%s)'
        % (generic_utility.addon_id, urllib.quote_plus(unicode(url)),
           urllib.quote_plus(generic_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
Exemplo n.º 20
0
def cache():
    try:
        xbmcvfs.rmdir(generic_utility.cache_dir(), force=True)
        generic_utility.log('Cache folder deleted.')
        generic_utility.notification(generic_utility.get_string(30309))
    except Exception:
        pass
Exemplo n.º 21
0
def cache():
    try:
        xbmcvfs.rmdir(generic_utility.cache_dir(), force=True)
        generic_utility.log('Cache folder deleted.')
        generic_utility.notification(generic_utility.get_string(30309))
    except Exception:
        pass
Exemplo n.º 22
0
def add_videos_to_directory(loading_progress, run_as_widget, video_metadatas, video_type, page = None, url=None, viewing_activity = False):

    removable = url != None and 'mylist' in url

    if not viewing_activity:
        sorted_video_metadata = sorted(video_metadatas, key=lambda t: t['title'], reverse = viewing_activity)
    else:
        sorted_video_metadata = video_metadatas

    allowed_types = calc_allowed_types(video_type, viewing_activity)

    filtered_video_metadata = []
    for video_metadata in sorted_video_metadata:
        if video_metadata['type'] in allowed_types:
            filtered_video_metadata.append(video_metadata)

    add.videos(filtered_video_metadata, removable, viewing_activity=viewing_activity)

    items_per_page = int(generic_utility.get_setting('items_per_page'))
    if (not url or 'list_viewing_activity' not in url) and len(video_metadatas) == items_per_page:
        add.add_next_item('zzz[Next]zzz', page + 1, url, video_type, 'list_videos', '')

    if len(video_metadatas) == 0:
        generic_utility.notification(generic_utility.get_string(30306))
    if not viewing_activity:
        add_sort_methods()
Exemplo n.º 23
0
 def read_browser(self):
     self.browser = generic_utility.get_setting('browser')
     if self.browser not in(BROWSER_CHROME, BROWSER_CHROME_LAUNCHER, BROWSER_EDGE, BROWSER_INTERNET_EXPLORER, BROWSER_SAFARI, BROWSER_CHROMIUM, BROWSER_ANDROID):
         generic_utility.notification(generic_utility.get_string(50001))
         xbmc.sleep(2000)
         self.valid_browser = False
         generic_utility.open_setting()
     self.valid_browser = True
Exemplo n.º 24
0
def add_context_menu_movie(entries, removable, title, type, video_id, year):
    entries.append((
        generic_utility.get_string(30153), 'RunPlugin(plugin://%s/?mode=play_trailer&url=%s&type=%s)' % (
            generic_utility.addon_id, urllib.quote_plus(generic_utility.encode(title)), type)))
    entries.append((generic_utility.get_string(30156),
                    'Container.Update(plugin://%s/?mode=list_videos&url=%s&type=movie)' % (
                        generic_utility.addon_id, urllib.quote_plus(
                                generic_utility.main_url + 'WiMovie/' + video_id))))
    entries.append(
            (generic_utility.get_string(30157), 'Container.Update(plugin://%s/?mode=list_videos&url=%s&type=tv)' % (
                generic_utility.addon_id, urllib.quote_plus(generic_utility.main_url + 'WiMovie/' + video_id))))
    if removable:
        entries.append((generic_utility.get_string(30154), 'RunPlugin(plugin://%s/?mode=remove_from_queue&url=%s)' % (
            generic_utility.addon_id, urllib.quote_plus(video_id))))
    else:
        entries.append((generic_utility.get_string(30155), 'RunPlugin(plugin://%s/?mode=add_to_queue&url=%s)' % (
            generic_utility.addon_id, urllib.quote_plus(video_id))))
    title_utf8 = title.strip() + ' (' + str(year) + ')'
    title = urllib.quote_plus(title_utf8.encode('utf-8'))
    movie_dir = library.get_movie_dir(title_utf8)[0]
    if xbmcvfs.exists(movie_dir + os.sep) == False:
        entries.append((generic_utility.get_string(30150),
                        'RunPlugin(plugin://%s/?mode=add_movie_to_library&url=%s&name=%s)' % (
                            generic_utility.addon_id, urllib.quote_plus(video_id),
                            title)))
    else:
        entries.append((generic_utility.get_string(301501),
                        'RunPlugin(plugin://%s/?mode=remove_movie_from_library&url=&name=%s)' % (
                            generic_utility.addon_id, title)))
Exemplo n.º 25
0
    def __init__(self):
        global addon_path
        self.read_browser()

        self.strActionInfo = xbmcgui.ControlLabel(180, 60, 1200, 400, '', 'font14', '0xFFBBBBFF')
        self.addControl(self.strActionInfo)
        self.strActionInfo.setLabel(generic_utility.get_string(50005))

        addon_path = xbmcaddon.Addon().getAddonInfo("path")
Exemplo n.º 26
0
 def read_browser(self):
     self.browser = generic_utility.get_setting('browser')
     if self.browser not in (BROWSER_CHROME, BROWSER_CHROME_LAUNCHER,
                             BROWSER_EDGE, BROWSER_INTERNET_EXPLORER,
                             BROWSER_SAFARI):
         generic_utility.notification(generic_utility.get_string(50001))
         xbmc.sleep(2000)
         self.valid_browser = False
         generic_utility.open_setting()
     self.valid_browser = True
Exemplo n.º 27
0
    def __init__(self):
        global addon_path
        self.read_browser()

        self.strActionInfo = xbmcgui.ControlLabel(180, 60, 1200, 400, '',
                                                  'font14', '0xFFBBBBFF')
        self.addControl(self.strActionInfo)
        self.strActionInfo.setLabel(generic_utility.get_string(50005))

        addon_path = xbmcaddon.Addon().getAddonInfo("path")
Exemplo n.º 28
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:
        generic_utility.notification(generic_utility.get_string(30305))
        content = None
    return content
Exemplo n.º 29
0
def main(video_type):
    add.directory(generic_utility.get_string(30105), '', 'list_viewing_activity', '', video_type)

    if video_type == 'show':
        add.directory(generic_utility.get_string(30107), 'genre?83', 'list_videos', '', video_type)
        add.directory(generic_utility.get_string(30108), '', 'list_genres', '', video_type)

    elif video_type == 'movie':
        add.directory(generic_utility.get_string(30108), '', 'list_genres', '', video_type)
    elif video_type == 'dynamic':
        add_dynamic_lists()

    if video_type != 'dynamic':
        root_list = lolomos.get_root_list()
        mylist = lolomos.get_mylist(root_list)
        add.directory(child('displayName', mylist[1]), 'list?&mylist', 'list_videos', '', video_type)

    add.directory(generic_utility.get_string(30109), '', 'search', '', video_type)
    xbmcplugin.endOfDirectory(plugin_handle, cacheToDisc=False)
Exemplo n.º 30
0
def login():
    if not test:
        login_progress = xbmcgui.DialogProgress()
        login_progress.create('Netflix', generic_utility.get_string(30200) + '...')
        generic_utility.progress_window(login_progress, 25, generic_utility.get_string(30201))
    content = connect.load_netflix_site(generic_utility.main_url + 'Login', new_session=True, login_process=True)
    if not 'Sorry, Netflix ' in content:

        match = re.compile('locale: "(.+?)"', re.DOTALL|re.UNICODE).findall(content)
        locale = None
        if(len(match)) == 0:
            match = re.compile('"pageName":"login","locale":"(.+?)"', re.DOTALL|re.UNICODE).findall(content)
            if(len(match)) == 0:
                generic_utility.error('Cannot find locale on page. content: '+content)
                login_url = 'Login'
            else:
                locale = match[0]
                login_url = 'Login?locale=' + locale
        else:
            locale = match[0]
            login_url = 'Login?locale=' + locale
        generic_utility.set_setting('language', locale)

        post_data = {'authURL': generic_utility.get_setting('authorization_url'), 'email': generic_utility.get_setting('username'),
                     'password': generic_utility.get_setting('password'), 'RememberMe': 'on'}
        if not test:
            generic_utility.progress_window(login_progress, 50, generic_utility.get_string(30202))

        content = connect.load_netflix_site(
            generic_utility.main_url + login_url,
            post=post_data, login_process=True)

        if 'id="page-LOGIN"' in content:
            if not test:
                generic_utility.notification(generic_utility.get_string(30303))
            return False

        parse_data_set_cookies(content)

        if not test:
            generic_utility.progress_window(login_progress, 75, generic_utility.get_string(30203))

        profile_selection()

        if login_progress:
            if not test:
                if not generic_utility.progress_window(login_progress, 100, generic_utility.get_string(30204)):
                    return False
                xbmc.sleep(500)
                login_progress.close()
        return True
    else:
        if not test:
            generic_utility.notification(generic_utility.get_string(30300))
            if login_progress:
                login_progress.close()
        return False
Exemplo n.º 31
0
def season(item):
    entries = []
    u = sys.argv[0]
    u += '?url=' + urllib.quote_plus(unicode(item.get("season")))
    u += '&mode=list_episodes'
    u += '&series_id=' + urllib.quote_plus(item.get("series_id"))
    
    if generic_utility.get_setting('use_tmdb') == 'true':
        extended_info = get.extended_artwork(item.get("tvshowtitle"),item.get("tvshowyear"),"show",item.get("series_id"))
    else:
        extended_info = {}
    
    list_item = xbmcgui.ListItem(item.get("name"))
    artwork = {
        'icon': 'DefaultTVShows.png', 
        'thumb': extended_info.get("poster", item.get("seriesthumb","")), 
        'landscape': extended_info.get("landscape",item.get("seriesthumb","")), 
        'poster': extended_info.get("poster",""), 
        'clearlogo': extended_info.get("clearlogo",""), 
        'clearart': extended_info.get("clearart",""), 
        'fanart': extended_info.get("fanart",""), 
        'characterart': extended_info.get("characterart",""), 
        'discart': extended_info.get("discart",""), 
        'banner': extended_info.get("banner","")
    }
    list_item.setArt(artwork)
    
    list_item.setInfo(type='video',infoLabels={
        'title': item.get("name",""),
        'year': item.get("year"), 
        'playcount': item.get("playcount"), 
        'tvshowtitle':item.get("tvshowtitle"),
        'castandrole': eval(extended_info.get("castandrole","[]")), 
        'trailer': extended_info.get("trailer",""),
        'genre': extended_info.get("genre",""), 
        'studio': extended_info.get("studio",""), 
        'plot': extended_info.get("plot",item.get("description","")),
        'plotoutline': item.get("description",""),
        'director': extended_info.get("director",""),
        'writer': extended_info.get("writer",""),
        'rating': float(extended_info.get("rating","0")),
        })
    list_item.setProperty("totalepisodes", str(item.get("total_episodes","")))
    list_item.setProperty("watchedepisodes", str(item.get("watched_episodes","")))
    list_item.setProperty("unwatchedepisodes", str(item.get("unwatched_episodes","")))
    entries.append((generic_utility.get_string(30150),
                    'RunPlugin(plugin://%s/?mode=add_series_to_library&url=%s&name=%s&series_id=%s)' % (
                        generic_utility.addon_id, urllib.quote_plus(unicode(item.get("season"))),
                        urllib.quote_plus(generic_utility.encode(item.get("tvshowtitle").strip())),
                        item.get("series_id"))))
    list_item.addContextMenuItems(entries)
    directory_item = xbmcplugin.addDirectoryItem(handle=plugin_handle, url=u, listitem=list_item, isFolder=True)
    return directory_item
Exemplo n.º 32
0
def trailer(video_type, title):
    import search

    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:
        generic_utility.notification(generic_utility.get_string(30305))
        content = None
    return content
Exemplo n.º 33
0
def add_context_menu_show(entries, removable, thumb_url, title, video_id):
    if generic_utility.get_setting('browse_tv_shows') == 'true':
        entries.append((generic_utility.get_string(30151),
                        'Container.Update(plugin://%s/?mode=play_video_main&url=%s&thumb=%s)' % (
                            generic_utility.addon_id, urllib.quote_plus(video_id), urllib.quote_plus(thumb_url))))
    else:
        entries.append((generic_utility.get_string(30152),
                        'Container.Update(plugin://%s/?mode=list_seasons&url=%s&thumb=%s)' % (
                            generic_utility.addon_id, urllib.quote_plus(video_id), urllib.quote_plus(thumb_url))))
    if removable:
        entries.append((generic_utility.get_string(30154), 'RunPlugin(plugin://%s/?mode=remove_from_queue&url=%s)' % (
            generic_utility.addon_id, urllib.quote_plus(video_id))))
    else:
        entries.append((generic_utility.get_string(30155), 'RunPlugin(plugin://%s/?mode=add_to_queue&url=%s)' % (
            generic_utility.addon_id, urllib.quote_plus(video_id))))
    series_dir = library.get_series_dir(title.strip())
    #        generic_utility.log('series-dir: '+series_dir)
    if xbmcvfs.exists(series_dir + os.sep) == False:
        entries.append((generic_utility.get_string(30150),
                        'RunPlugin(plugin://%s/?mode=add_series_to_library&url=&name=%s&series_id=%s)' % (
                            generic_utility.addon_id, urllib.quote_plus(generic_utility.encode(title.strip())),
                            urllib.quote_plus(video_id))))
    else:
        entries.append((generic_utility.get_string(301501),
                        'RunPlugin(plugin://%s/?mode=remove_series_from_library&url=&name=%s)' % (
                            generic_utility.addon_id, urllib.quote_plus(generic_utility.encode(title.strip())))))
Exemplo n.º 34
0
def add_context_menu_show(entries, removable, thumb_url, title, video_id):
    if generic_utility.get_setting('browse_tv_shows') == 'true':
        entries.append((generic_utility.get_string(30151),
                        'RunPlugin(plugin://%s/?mode=play_video_main&url=%s&thumb=%s)' % (
                            generic_utility.addon_id, urllib.quote_plus(video_id), urllib.quote_plus(thumb_url))))

    else:
        entries.append((generic_utility.get_string(30152),
                        'Container.Update(plugin://%s/?mode=list_seasons&url=%s&thumb=%s)' % (
                            generic_utility.addon_id, urllib.quote_plus(video_id), urllib.quote_plus(thumb_url))))
    if removable:
        entries.append((generic_utility.get_string(30154), 'RunPlugin(plugin://%s/?mode=remove_from_queue&url=%s)' % (
            generic_utility.addon_id, urllib.quote_plus(video_id))))
    else:
        entries.append((generic_utility.get_string(30155), 'RunPlugin(plugin://%s/?mode=add_to_queue&url=%s)' % (
            generic_utility.addon_id, urllib.quote_plus(video_id))))
    series_dir = library.get_series_dir(title.strip())
    #        generic_utility.log('series-dir: '+series_dir)
    if xbmcvfs.exists(series_dir + os.sep) == False:
        entries.append((generic_utility.get_string(30150),
                        'RunPlugin(plugin://%s/?mode=add_series_to_library&url=&name=%s&series_id=%s)' % (
                            generic_utility.addon_id, urllib.quote_plus(generic_utility.encode(title.strip())),
                            urllib.quote_plus(video_id))))
    else:
        entries.append((generic_utility.get_string(301501),
                        'RunPlugin(plugin://%s/?mode=remove_series_from_library&url=&name=%s)' % (
                            generic_utility.addon_id, urllib.quote_plus(generic_utility.encode(title.strip())))))
Exemplo n.º 35
0
def add_context_menu_movie(entries, removable, title, type, video_id, year):
    entries.append((
        generic_utility.get_string(30156),
        'Container.Update(plugin://%s/?mode=list_videos&url=%s&type=movie)' %
        (generic_utility.addon_id,
         urllib.quote_plus(generic_utility.main_url + 'WiMovie/' + video_id))))
    entries.append((
        generic_utility.get_string(30157),
        'Container.Update(plugin://%s/?mode=list_videos&url=%s&type=tv)' %
        (generic_utility.addon_id,
         urllib.quote_plus(generic_utility.main_url + 'WiMovie/' + video_id))))
    if removable:
        entries.append(
            (generic_utility.get_string(30154),
             'RunPlugin(plugin://%s/?mode=remove_from_queue&url=%s)' %
             (generic_utility.addon_id, urllib.quote_plus(video_id))))
    else:
        entries.append(
            (generic_utility.get_string(30155),
             'RunPlugin(plugin://%s/?mode=add_to_queue&url=%s)' %
             (generic_utility.addon_id, urllib.quote_plus(video_id))))
    title_utf8 = title.strip() + ' (' + str(year) + ')'
    title = urllib.quote_plus(title_utf8.encode('utf-8'))
    movie_dir = library.get_movie_dir(title_utf8)[0]
    if xbmcvfs.exists(movie_dir + os.sep) == False:
        entries.append(
            (generic_utility.get_string(30150),
             'RunPlugin(plugin://%s/?mode=add_movie_to_library&url=%s&name=%s)'
             % (generic_utility.addon_id, urllib.quote_plus(video_id), title)))
    else:
        entries.append((generic_utility.get_string(
            301501
        ), 'RunPlugin(plugin://%s/?mode=remove_movie_from_library&url=&name=%s)'
                        % (generic_utility.addon_id, title)))
Exemplo n.º 36
0
def login():
    login_progress = xbmcgui.DialogProgress()
    login_progress.create('Netflix', generic_utility.get_string(30200) + '...')
    generic_utility.progress_window(login_progress, 25,
                                    generic_utility.get_string(30201))
    content = connect.load_netflix_site(generic_utility.main_url + 'Login',
                                        new_session=True)
    if not 'Sorry, Netflix ' in content:
        match = re.compile('name="authURL" value="(.+?)"',
                           re.DOTALL | re.UNICODE).findall(content)
        #        utility.log('Setting authorization url: ' + match[0])
        generic_utility.set_setting('authorization_url', match[0])
        match = re.compile('locale: "(.+?)"',
                           re.DOTALL | re.UNICODE).findall(content)
        generic_utility.set_setting('language', match[0])
        post_data = {
            'authURL': generic_utility.get_setting('authorization_url'),
            'email': generic_utility.get_setting('username'),
            'password': generic_utility.get_setting('password'),
            'RememberMe': 'on'
        }
        generic_utility.progress_window(login_progress, 50,
                                        generic_utility.get_string(30202))
        content = connect.load_netflix_site(
            generic_utility.main_url + 'Login?locale=' +
            generic_utility.get_setting('language'),
            post=post_data)
        #        utility.log(content)

        if 'id="page-LOGIN"' in content:
            generic_utility.notification(generic_utility.get_string(30303))
            return False
        match = re.compile('"apiUrl":"(.+?)",', re.UNICODE).findall(content)
        generic_utility.set_setting('api_url', match[0])

        connect.set_chrome_netflix_cookies()

        generic_utility.progress_window(login_progress, 75,
                                        generic_utility.get_string(30203))

        profile_selection()

        if login_progress:
            if not generic_utility.progress_window(
                    login_progress, 100, generic_utility.get_string(30204)):
                return False
            xbmc.sleep(500)
            login_progress.close()
        return True
    else:
        generic_utility.notification(generic_utility.get_string(30300))
        if login_progress:
            login_progress.close()
        return False
Exemplo n.º 37
0
def viewing_activity(video_type, run_as_widget=False):
    loading_progress = show_loading_progress(run_as_widget)
    xbmcplugin.setContent(plugin_handle, 'movies')

    metadata = get.viewing_activity_matches(video_type)
    if len(metadata) > 0:
        add_videos_to_directory(loading_progress, run_as_widget, metadata, video_type, viewing_activity=True)
    else:
        generic_utility.notification(generic_utility.get_string(30306))

    if generic_utility.get_setting('force_view') and not run_as_widget:
        xbmc.executebuiltin('Container.SetViewMode(' + generic_utility.get_setting('view_id_activity') + ')')
    xbmcplugin.endOfDirectory(plugin_handle)
Exemplo n.º 38
0
def viewing_activity(video_type, run_as_widget=False):
    loading_progress = show_loading_progress(run_as_widget)
    xbmcplugin.setContent(plugin_handle, 'movies')

    metadata = get.viewing_activity_matches(video_type)
    if len(metadata) > 0:
        add_videos_to_directory(loading_progress, run_as_widget, metadata, video_type, viewing_activity=True)
    else:
        generic_utility.notification(generic_utility.get_string(30306))

    if generic_utility.get_setting('force_view') and not run_as_widget:
        xbmc.executebuiltin('Container.SetViewMode(' + generic_utility.get_setting('view_id_activity') + ')')
    xbmcplugin.endOfDirectory(plugin_handle)
Exemplo n.º 39
0
def add_next_item(page, url, video_type, mode):
    name = generic_utility.get_string(30110)
    u = sys.argv[0]
    u += '?url=' + urllib.quote_plus(url)
    u += '&mode=' + mode
    u += '&type=' + video_type
    u += '&page=' + str(page)
    u += '&name=' + urllib.quote_plus(generic_utility.encode(name))
    liz=xbmcgui.ListItem(unicode(name), iconImage="DefaultFolder.png")
    liz.setInfo( type="Video", infoLabels={ "Title": name, "sorttitle": "zzzzzzz"})
    liz.setArt( { "thumb": generic_utility.addon_handle.getAddonInfo('icon'), "fanart":generic_utility.addon_handle.getAddonInfo('fanart') })
    liz.setProperty('IsPlayable', 'false');
    ok=xbmcplugin.addDirectoryItem(handle=plugin_handle,url=u,listitem=liz,isFolder=True)
    return ok
Exemplo n.º 40
0
def add_videos_to_directory(loading_progress,
                            run_as_widget,
                            video_metadatas,
                            video_type,
                            page=None,
                            url=None,
                            viewing_activity=False):

    removable = url != None and 'mylist' in url

    if viewing_activity and type != "movie":
        xbmcplugin.setContent(int(sys.argv[1]), "episodes")
    elif video_type == "movie":
        xbmcplugin.setContent(int(sys.argv[1]), "movies")
    elif video_type == "show":
        xbmcplugin.setContent(int(sys.argv[1]), "tvshows")
    elif video_type == "both":
        xbmcplugin.setContent(int(sys.argv[1]), "tvshows")

    if not viewing_activity:
        sorted_video_metadata = sorted(video_metadatas,
                                       key=lambda t: t['date_watched'],
                                       reverse=viewing_activity)
    else:
        sorted_video_metadata = video_metadatas

    allowed_types = calc_allowed_types(video_type, viewing_activity)

    filtered_video_metadata = []
    for video_metadata in sorted_video_metadata:
        if video_metadata['type'] in allowed_types:
            filtered_video_metadata.append(video_metadata)

    add.videos(filtered_video_metadata,
               removable,
               viewing_activity=viewing_activity)

    items_per_page = int(generic_utility.get_setting('items_per_page'))

    if len(video_metadatas) == 0:
        generic_utility.notification(generic_utility.get_string(30306))

    if not viewing_activity:
        add_sort_methods()
    else:
        xbmcplugin.addSortMethod(plugin_handle, xbmcplugin.SORT_METHOD_LABEL)

    if (not url or 'list_viewing_activity'
            not in url) and len(video_metadatas) == items_per_page:
        add.add_next_item(page + 1, url, video_type, 'list_videos')
Exemplo n.º 41
0
def search(search_string, video_type, run_as_widget=False):
    loading_progress = None
    if not run_as_widget:
        loading_progress = xbmcgui.DialogProgress()
        loading_progress.create('Netflix', generic_utility.get_string(30205) + '...')
        generic_utility.progress_window(loading_progress, 0, '...')
    xbmcplugin.setContent(plugin_handle, 'movies')

    metadatas = get.videos_in_search(search_string)
#    video_ids = get.search_matches(search_string, video_type)
    add_videos_to_directory(loading_progress, run_as_widget, metadatas, video_type, 0, '')

    if generic_utility.get_setting('force_view') and not run_as_widget:
        xbmc.executebuiltin('Container.SetViewMode(' + generic_utility.get_setting('view_id_videos') + ')')
    xbmcplugin.endOfDirectory(plugin_handle)
Exemplo n.º 42
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:
            generic_utility.notification(generic_utility.get_string(30305))
    else:
        generic_utility.notification(generic_utility.get_string(30305))
        pass
Exemplo n.º 43
0
def search(search_string, video_type, run_as_widget=False):
    loading_progress = None
    if not run_as_widget:
        loading_progress = xbmcgui.DialogProgress()
        loading_progress.create('Netflix', generic_utility.get_string(30205) + '...')
        generic_utility.progress_window(loading_progress, 0, '...')
    xbmcplugin.setContent(plugin_handle, 'movies')

    metadatas = get.videos_in_search(search_string)
#    video_ids = get.search_matches(search_string, video_type)
    add_videos_to_directory(loading_progress, run_as_widget, metadatas, video_type, 0, '')

    if generic_utility.get_setting('force_view') and not run_as_widget:
        xbmc.executebuiltin('Container.SetViewMode(' + generic_utility.get_setting('view_id_videos') + ')')
    xbmcplugin.endOfDirectory(plugin_handle)
Exemplo n.º 44
0
def load_videos_to_directory(loading_progress, run_as_widget, metadatas, video_type, page = None, url=None, viewing_activity = False):
    video_metadatas = multiprocessor.load_data(metadatas, video_type, run_as_widget, loading_progress, url, viewing_activity)
    removable = url != None and 'my-list' in url

    sorted_video_metadata = sorted(video_metadatas, key=lambda t: t['title'], reverse = viewing_activity)
    for video_metadata in sorted_video_metadata:
        if (video_metadata != None):
            video_add(video_metadata, removable, viewing_activity)
#    generic_utility.log(url)

    items_per_page = int(generic_utility.get_setting('items_per_page'))
    if ((url == None or 'list_viewing_activity' not in url) and len(video_metadatas) == items_per_page):
        add.add_next_item('Next', page + 1, url, video_type, 'list_videos', '')
    if len(video_metadatas) == 0:
        generic_utility.notification(generic_utility.get_string(30306))
    add_sort_methods()
Exemplo n.º 45
0
def login():
    login_progress = xbmcgui.DialogProgress()
    login_progress.create('Netflix', generic_utility.get_string(30200) + '...')
    generic_utility.progress_window(login_progress, 25, generic_utility.get_string(30201))
    content = connect.load_netflix_site(generic_utility.main_url + 'Login', new_session=True)
    if not 'Sorry, Netflix ' in content:
        match = re.compile('name="authURL" value="(.+?)"', re.DOTALL| re.UNICODE).findall(content)
#        utility.log('Setting authorization url: ' + match[0])
        generic_utility.set_setting('authorization_url', match[0])
        match = re.compile('locale: "(.+?)"', re.DOTALL|re.UNICODE).findall(content)
        generic_utility.set_setting('language', match[0])
        post_data = {'authURL': generic_utility.get_setting('authorization_url'), 'email': generic_utility.get_setting('username'),
                     'password': generic_utility.get_setting('password'), 'RememberMe': 'on'}
        generic_utility.progress_window(login_progress, 50, generic_utility.get_string(30202))
        content = connect.load_netflix_site(
            generic_utility.main_url + 'Login?locale=' + generic_utility.get_setting('language'),
            post=post_data)
#        utility.log(content)

        if 'id="page-LOGIN"' in content:
            generic_utility.notification(generic_utility.get_string(30303))
            return False
        match = re.compile('"apiUrl":"(.+?)",', re.UNICODE).findall(content)
        generic_utility.set_setting('api_url', match[0])

        connect.set_chrome_netflix_cookies()

        generic_utility.progress_window(login_progress, 75, generic_utility.get_string(30203))

        profile_selection()

        if login_progress:
            if not generic_utility.progress_window(login_progress, 100, generic_utility.get_string(30204)):
                return False
            xbmc.sleep(500)
            login_progress.close()
        return True
    else:
        generic_utility.notification(generic_utility.get_string(30300))
        if login_progress:
            login_progress.close()
        return False
Exemplo n.º 46
0
def add_videos_to_directory(loading_progress, run_as_widget, video_metadatas, video_type, page = None, url=None, viewing_activity = False):

    removable = url != None and 'mylist' in url
    
    if viewing_activity and type!="movie":
        xbmcplugin.setContent(int(sys.argv[1]), "episodes")
    elif video_type=="movie":
        xbmcplugin.setContent(int(sys.argv[1]), "movies")
    elif video_type == "show":
        xbmcplugin.setContent(int(sys.argv[1]), "tvshows")
    elif video_type == "both":
        xbmcplugin.setContent(int(sys.argv[1]), "tvshows")
    
    if not viewing_activity:
        sorted_video_metadata = sorted(video_metadatas, key=lambda t: t['date_watched'], reverse = viewing_activity)
    else:
        sorted_video_metadata = video_metadatas

    allowed_types = calc_allowed_types(video_type, viewing_activity)

    filtered_video_metadata = []
    for video_metadata in sorted_video_metadata:
        if video_metadata['type'] in allowed_types:
            filtered_video_metadata.append(video_metadata)

    add.videos(filtered_video_metadata, removable, viewing_activity=viewing_activity)

    items_per_page = int(generic_utility.get_setting('items_per_page'))

    if len(video_metadatas) == 0:
        generic_utility.notification(generic_utility.get_string(30306))
    
    if not viewing_activity:
        add_sort_methods()
    else:
        xbmcplugin.addSortMethod(plugin_handle, xbmcplugin.SORT_METHOD_LABEL)
    
    if page is not None and (not url or 'list_viewing_activity' not in url) and len(video_metadatas) == items_per_page:
        add.add_next_item(page + 1, url, video_type, 'list_videos')
Exemplo n.º 47
0
def choose():
    profiles = []
    content = connect.load_netflix_site(generic_utility.profile_url, login_process=True)
#    generic_utility.log('choose: '+content)
    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(generic_utility.get_string(30103), [profile['name'] for profile in profiles])
        if nr >= 0:
            selected_profile = profiles[nr]
        else:
            selected_profile = profiles[0]

        switch_profile(selected_profile['token'])

        generic_utility.set_setting('selected_profile', selected_profile['token'])
        generic_utility.set_setting('is_kid', 'true' if selected_profile['is_kid'] else 'false')
        generic_utility.set_setting('profile_name', selected_profile['name'])
    else:
        generic_utility.log('Choose profile: no profiles were found!', loglevel=xbmc.LOGERROR)
Exemplo n.º 48
0
def season(name, url, thumb, series_name, series_id):
    entries = []
    cover_file, fanart_file = generic_utility.cover_fanart(series_id)
    u = sys.argv[0]
    u += '?url=' + urllib.quote_plus(unicode(url))
    u += '&mode=list_episodes'
    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', generic_utility.addon_fanart())
    entries.append((generic_utility.get_string(30150),
                    'RunPlugin(plugin://%s/?mode=add_series_to_library&url=%s&name=%s&series_id=%s)' % (
                        generic_utility.addon_id, urllib.quote_plus(unicode(url)),
                        urllib.quote_plus(generic_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
Exemplo n.º 49
0
    elif mode == 'search':
        search.netflix(video_type)
    elif mode == 'delete_cookies':
        delete.cookies()
    elif mode == 'delete_cache':
        delete.cache()
    elif mode == 'reset_addon':
        delete.addon()
    elif mode == 'play_video':
        #    utility.log('play_video: '+url)
        play.video(url, series_id);
    elif mode == 'play_video_main':
        #    utility.log('play_video_main: '+url)
        play.video(url, series_id);
    elif mode == 'relogin':
        connect.do_login()
    else:
        general.index()


try:
    handle_request()
except:
    generic_utility.log('parameters: ' + sys.argv[2])
    generic_utility.log(traceback.format_exc(), xbmc.LOGERROR)
    dialog = xbmcgui.Dialog()
    do_fresh_login = dialog.yesno(generic_utility.get_string(50002), generic_utility.get_string(50003), generic_utility.get_string(50004))
    if do_fresh_login:
        if connect.do_login()==True:
            generic_utility.notification('Login refreshed. please try again.')
Exemplo n.º 50
0
def video(video_metadata, removable = False, viewing_activity = False):
#    utility.log(str(video_metadata))

    title = video_metadata['title']
    video_id = video_metadata['video_id']
    thumb_url = video_metadata['thumb_url']
    type = video_metadata['type']
    description = video_metadata['description']
    duration = video_metadata['duration']
    year = video_metadata['year']
    mpaa = video_metadata['mpaa']
    director = video_metadata['director']
    genre = video_metadata['genre']
    rating = video_metadata['rating']
    playcount = video_metadata['playcount']

    next_mode = 'play_video_main'
    if viewing_activity == False and generic_utility.get_setting('browse_tv_shows') == 'true' and (type == 'tvshow' or type == 'episode'):
        next_mode = 'list_seasons'

    entries = []
    cover_file, fanart_file = generic_utility.cover_fanart(video_id)
    if xbmcvfs.exists(cover_file):
        thumb_url = cover_file
    u = sys.argv[0]
    u += '?url=' + urllib.quote_plus(video_id)
    u += '&mode=' + next_mode
    u += '&name=' + urllib.quote_plus(generic_utility.encode(title))
    u += '&thumb=' + urllib.quote_plus(thumb_url)
    list_item = xbmcgui.ListItem(title)
    list_item.setArt({'icon': 'DefaultTVShows.png', 'thumb': thumb_url})
    list_item.setInfo(type='video',
                      infoLabels={'title': title, 'plot': description, 'duration': unicode(duration), 'year': int(year),
                                  'mpaa': mpaa, 'director': director, 'genre': genre, 'rating': rating,
                                  'playcount': playcount})
    list_item.setProperty('IsPlayable', 'true');
    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', thumb_url)
    if type == 'tvshow':
        if generic_utility.get_setting('browse_tv_shows') == 'true':
            entries.append((generic_utility.get_string(30151),
                            'Container.Update(plugin://%s/?mode=play_video_main&url=%s&thumb=%s)' % (
                                generic_utility.addon_id, urllib.quote_plus(video_id), urllib.quote_plus(thumb_url))))
        else:
            entries.append((generic_utility.get_string(30152),
                            'Container.Update(plugin://%s/?mode=list_seasons&url=%s&thumb=%s)' % (
                                generic_utility.addon_id, urllib.quote_plus(video_id), urllib.quote_plus(thumb_url))))
    if type != 'episode':
        entries.append((
                       generic_utility.get_string(30153), 'RunPlugin(plugin://%s/?mode=play_trailer&url=%s&type=%s)' % (
                           generic_utility.addon_id, urllib.quote_plus(generic_utility.encode(title)), type)))
        if removable:
            entries.append((generic_utility.get_string(30154), 'RunPlugin(plugin://%s/?mode=remove_from_queue&url=%s)' % (
                generic_utility.addon_id, urllib.quote_plus(video_id))))
        else:
            entries.append((generic_utility.get_string(30155), 'RunPlugin(plugin://%s/?mode=add_to_queue&url=%s)' % (
                generic_utility.addon_id, urllib.quote_plus(video_id))))
        entries.append((generic_utility.get_string(30156),
                        'Container.Update(plugin://%s/?mode=list_videos&url=%s&type=movie)' % (
                            generic_utility.addon_id, urllib.quote_plus(
                                generic_utility.main_url + 'WiMovie/' + video_id))))
        entries.append((generic_utility.get_string(30157), 'Container.Update(plugin://%s/?mode=list_videos&url=%s&type=tv)' % (
            generic_utility.addon_id, urllib.quote_plus(generic_utility.main_url + 'WiMovie/' + video_id))))
#    generic_utility.log(type)
    if type in ('tvshow', 'episode'):
        series_dir = library.get_series_dir(title.strip())
#        generic_utility.log('series-dir: '+series_dir)
        if xbmcvfs.exists(series_dir+os.sep) == False:
            entries.append((generic_utility.get_string(30150),
                            'RunPlugin(plugin://%s/?mode=add_series_to_library&url=&name=%s&series_id=%s)' % (
                                generic_utility.addon_id, urllib.quote_plus(generic_utility.encode(title.strip())), urllib.quote_plus(video_id))))
        else:
            entries.append((generic_utility.get_string(301501),
                            'RunPlugin(plugin://%s/?mode=remove_series_from_library&url=&name=%s)' % (
                                generic_utility.addon_id, urllib.quote_plus(generic_utility.encode(title.strip())))))

    elif type == 'movie':
        title_utf8 = title.strip() + ' (' + str(year) + ')'
        title = urllib.quote_plus(title_utf8.encode('utf-8'))
        movie_dir = library.get_movie_dir(title_utf8)[0]
        if xbmcvfs.exists(movie_dir+os.sep) == False:
            entries.append((generic_utility.get_string(30150),
                            'RunPlugin(plugin://%s/?mode=add_movie_to_library&url=%s&name=%s)' % (
                                generic_utility.addon_id, urllib.quote_plus(video_id),
                                title)))
        else:
            entries.append((generic_utility.get_string(301501),
                            'RunPlugin(plugin://%s/?mode=remove_movie_from_library&url=&name=%s)' % (
                                generic_utility.addon_id, title)))

#    utility.log(str(entries))
    list_item.addContextMenuItems(entries)

    folder = True
    if next_mode == 'play_video_main':
        folder = False
#    utility.log(u)
    directory_item = xbmcplugin.addDirectoryItem(handle=plugin_handle, url=u, listitem=list_item, isFolder=folder)
    return directory_item
Exemplo n.º 51
0
    elif mode == 'delete_cookies':
        delete.cookies()
    elif mode == 'delete_cache':
        delete.cache()
    elif mode == 'reset_addon':
        delete.addon()
    elif mode == 'play_video':
        #    utility.log('play_video: '+url)
        play.video(url, series_id)
    elif mode == 'play_video_main':
        #    utility.log('play_video_main: '+url)
        play.video(url, series_id)
    elif mode == 'relogin':
        connect.do_login()
    else:
        general.index()


try:
    handle_request()
except:
    generic_utility.log('parameters: ' + sys.argv[2])
    generic_utility.log(traceback.format_exc(), xbmc.LOGERROR)
    dialog = xbmcgui.Dialog()
    do_fresh_login = dialog.yesno(generic_utility.get_string(50002),
                                  generic_utility.get_string(50003),
                                  generic_utility.get_string(50004))
    if do_fresh_login:
        if connect.do_login() == True:
            generic_utility.notification(generic_utility.get_string(50006))
Exemplo n.º 52
0
def video(video_metadata, removable=False, viewing_activity=False):
    #    utility.log(str(video_metadata))

    title = video_metadata['title']
    video_id = video_metadata['video_id']
    thumb_url = video_metadata['thumb_url']
    type = video_metadata['type']
    description = video_metadata['description']
    duration = video_metadata['duration']
    year = video_metadata['year']
    mpaa = video_metadata['mpaa']
    director = video_metadata['director']
    genre = video_metadata['genre']
    rating = video_metadata['rating']
    playcount = video_metadata['playcount']

    next_mode = 'play_video_main'
    if viewing_activity == False and generic_utility.get_setting(
            'browse_tv_shows') == 'true' and (type == 'tvshow'
                                              or type == 'episode'):
        next_mode = 'list_seasons'

    entries = []
    cover_file, fanart_file = generic_utility.cover_fanart(video_id)
    if xbmcvfs.exists(cover_file):
        thumb_url = cover_file
    u = sys.argv[0]
    u += '?url=' + urllib.quote_plus(video_id)
    u += '&mode=' + next_mode
    u += '&name=' + urllib.quote_plus(generic_utility.encode(title))
    u += '&thumb=' + urllib.quote_plus(thumb_url)
    list_item = xbmcgui.ListItem(title)
    list_item.setArt({'icon': 'DefaultTVShows.png', 'thumb': thumb_url})
    list_item.setInfo(type='video',
                      infoLabels={
                          'title': title,
                          'plot': description,
                          'duration': unicode(duration),
                          'year': int(year),
                          'mpaa': mpaa,
                          'director': director,
                          'genre': genre,
                          'rating': rating,
                          'playcount': playcount
                      })
    list_item.setProperty('IsPlayable', 'true')
    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', thumb_url)
    if type == 'tvshow':
        if generic_utility.get_setting('browse_tv_shows') == 'true':
            entries.append((
                generic_utility.get_string(30151),
                'Container.Update(plugin://%s/?mode=play_video_main&url=%s&thumb=%s)'
                % (generic_utility.addon_id, urllib.quote_plus(video_id),
                   urllib.quote_plus(thumb_url))))
        else:
            entries.append((
                generic_utility.get_string(30152),
                'Container.Update(plugin://%s/?mode=list_seasons&url=%s&thumb=%s)'
                % (generic_utility.addon_id, urllib.quote_plus(video_id),
                   urllib.quote_plus(thumb_url))))
    if type != 'episode':
        entries.append(
            (generic_utility.get_string(30153),
             'RunPlugin(plugin://%s/?mode=play_trailer&url=%s&type=%s)' %
             (generic_utility.addon_id,
              urllib.quote_plus(generic_utility.encode(title)), type)))
        if removable:
            entries.append(
                (generic_utility.get_string(30154),
                 'RunPlugin(plugin://%s/?mode=remove_from_queue&url=%s)' %
                 (generic_utility.addon_id, urllib.quote_plus(video_id))))
        else:
            entries.append(
                (generic_utility.get_string(30155),
                 'RunPlugin(plugin://%s/?mode=add_to_queue&url=%s)' %
                 (generic_utility.addon_id, urllib.quote_plus(video_id))))
        entries.append((
            generic_utility.get_string(30156),
            'Container.Update(plugin://%s/?mode=list_videos&url=%s&type=movie)'
            % (generic_utility.addon_id,
               urllib.quote_plus(generic_utility.main_url + 'WiMovie/' +
                                 video_id))))
        entries.append(
            (generic_utility.get_string(30157),
             'Container.Update(plugin://%s/?mode=list_videos&url=%s&type=tv)' %
             (generic_utility.addon_id,
              urllib.quote_plus(generic_utility.main_url + 'WiMovie/' +
                                video_id))))
#    generic_utility.log(type)
    if type in ('tvshow', 'episode'):
        series_dir = library.get_series_dir(title.strip())
        #        generic_utility.log('series-dir: '+series_dir)
        if xbmcvfs.exists(series_dir + os.sep) == False:
            entries.append((generic_utility.get_string(
                30150
            ), 'RunPlugin(plugin://%s/?mode=add_series_to_library&url=&name=%s&series_id=%s)'
                            % (generic_utility.addon_id,
                               urllib.quote_plus(
                                   generic_utility.encode(title.strip())),
                               urllib.quote_plus(video_id))))
        else:
            entries.append((generic_utility.get_string(
                301501
            ), 'RunPlugin(plugin://%s/?mode=remove_series_from_library&url=&name=%s)'
                            % (generic_utility.addon_id,
                               urllib.quote_plus(
                                   generic_utility.encode(title.strip())))))

    elif type == 'movie':
        title_utf8 = title.strip() + ' (' + str(year) + ')'
        title = urllib.quote_plus(title_utf8.encode('utf-8'))
        movie_dir = library.get_movie_dir(title_utf8)[0]
        if xbmcvfs.exists(movie_dir + os.sep) == False:
            entries.append((generic_utility.get_string(
                30150
            ), 'RunPlugin(plugin://%s/?mode=add_movie_to_library&url=%s&name=%s)'
                            % (generic_utility.addon_id,
                               urllib.quote_plus(video_id), title)))
        else:
            entries.append((generic_utility.get_string(
                301501
            ), 'RunPlugin(plugin://%s/?mode=remove_movie_from_library&url=&name=%s)'
                            % (generic_utility.addon_id, title)))

#    utility.log(str(entries))
    list_item.addContextMenuItems(entries)

    folder = True
    if next_mode == 'play_video_main':
        folder = False


#    utility.log(u)
    directory_item = xbmcplugin.addDirectoryItem(handle=plugin_handle,
                                                 url=u,
                                                 listitem=list_item,
                                                 isFolder=folder)
    return directory_item
Exemplo n.º 53
0
def force_choose():
    generic_utility.set_setting('single_profile', 'false')
    generic_utility.notification(generic_utility.get_string(30304))
    choose()
Exemplo n.º 54
0
def force_choose():
    generic_utility.set_setting('single_profile', 'false')
    generic_utility.notification(generic_utility.get_string(30304))
    choose()