Пример #1
0
def PLAY(payload, params):
    anime_url, episode = payload.rsplit("/", 1)
    sources = _BROWSER.get_episode_sources(anime_url, episode)

    serverChoice = filter(lambda x:
        control.getSetting(x[0]) == 'true', SERVER_CHOICES.iteritems())
    serverChoice = map(lambda x: x[1], serverChoice)
    sources = filter(lambda x: x[0] in serverChoice, sources)

    autoplay = True if 'true' in control.getSetting('autoplay') else False

    s = SourcesList(sources, autoplay, sortResultsByRes, {
        'title': control.lang(30100),
        'processing': control.lang(30101),
        'choose': control.lang(30102),
        'notfound': control.lang(30103),
    })

    if isDirectoryStyle():
        if s._read_sources():
            items = sorted(s._sources.iteritems(), key=lambda x: x[0])
            items = [(title[5:], url) for title, url in items]
            items = map(lambda x: utils.allocate_item(x[0], 'playlink&url=/'+x[1],'', False, ''), items)
            return control.draw_items(items)
    else:
        res = control.play_source(s.get_video_link())
        bookmark_episode_playing(sources[0])
        return res
Пример #2
0
def PLAY(payload, params):
    anime_url, episode = payload.rsplit("/", 1)
    sources = _BROWSER.get_episode_sources(anime_url, episode)

    serverChoice = filter(lambda x: control.getSetting(x[0]) == 'true',
                          SERVER_CHOICES.iteritems())
    serverChoice = map(lambda x: x[1], serverChoice)
    sources = filter(lambda x: x[0] in serverChoice, sources)

    autoplay = True if 'true' in control.getSetting('autoplay') else False

    s = SourcesList(
        sources, autoplay, sortResultsByRes, {
            'title': control.lang(30100),
            'processing': control.lang(30101),
            'choose': control.lang(30102),
            'notfound': control.lang(30103),
        })

    if isDirectoryStyle():
        if s._read_sources():
            items = sorted(s._sources.iteritems(), key=lambda x: x[0])
            items = [(title[5:], url) for title, url in items]
            items = map(
                lambda x: utils.allocate_item(x[0], 'playlink&url=/' + x[1],
                                              '', False, ''), items)
            return control.draw_items(items)
    else:
        res = control.play_source(s.get_video_link())
        bookmark_episode_playing(sources[0])
        return res
Пример #3
0
def GOGO_ANIMES_PAGE(payload, params):
    desc_order = False if "Ascending" in control.getSetting(
        'reverseorder') else True
    content_type = get_animes_contentType()
    view_type = control.getSetting('viewtype.episode')
    episodes = GogoAnimeBrowser().get_anime_episodes(payload, desc_order)
    return control.draw_items(episodes, content_type, view_type)
Пример #4
0
def SEARCH_HISTORY(payload, params):
    history = control.getSetting("9anime.history")
    history_array = history.split(HISTORY_DELIM)
    if history != "" and "Yes" in control.getSetting('searchhistory') :
        return control.draw_items(_BROWSER.search_history(history_array))
    else :
        return SEARCH(payload,params)
Пример #5
0
def SEARCH_HISTORY(payload, params):
    history = control.getSetting("9anime.history")
    history_array = history.split(HISTORY_DELIM)
    if history != "" and "Yes" in control.getSetting('searchhistory'):
        return control.draw_items(_BROWSER.search_history(history_array))
    else:
        return SEARCH(payload, params)
Пример #6
0
def SEARCH_HISTORY(payload, params):
    history = database.getSearchHistory('show')
    if "Yes" in control.getSetting('searchhistory'):
        return control.draw_items(
            _BROWSER.search_history(history),
            contentType=control.getSetting("contenttype.menu"))
    else:
        return SEARCH(payload, params)
def _add_last_watched():
    if not control.getSetting(LASTWATCHED_URL_KEY):
        return

    MENU_ITEMS.insert(
        0, ("%s[I]%s[/I]" %
            (control.lang(30000), control.getSetting(LASTWATCHED_NAME_KEY)),
            control.getSetting(LASTWATCHED_URL_KEY),
            control.getSetting(LASTWATCHED_IMAGE_KEY)))
Пример #8
0
def SEARCH(payload, params):
    query = control.keyboard(control.lang(30007))
    if query:
        if "Yes" in control.getSetting('searchhistory') :
            history = control.getSetting("9anime.history")
            if history != "" :
                query = query+HISTORY_DELIM
            history=query+history
            while history.count(HISTORY_DELIM) > 6 :
                history=history.rsplit(HISTORY_DELIM, 1)[0]
            control.setSetting("9anime.history",history)
        return control.draw_items(_BROWSER.search_site(query))
    return False
Пример #9
0
def SEARCH(payload, params):
    query = control.keyboard(control.lang(30007))
    if query:
        if "Yes" in control.getSetting('searchhistory'):
            history = control.getSetting("9anime.history")
            if history != "":
                query = query + HISTORY_DELIM
            history = query + history
            while history.count(HISTORY_DELIM) > 6:
                history = history.rsplit(HISTORY_DELIM, 1)[0]
            control.setSetting("9anime.history", history)
        return control.draw_items(_BROWSER.search_site(query))
    return False
def SEARCH(payload, params):
    query = control.keyboard(control.lang(30008))
    if not query:
        return False

    # TODO: Better logic here, maybe move functionatly into router?
    if "Yes" in control.getSetting('searchhistory'):
        history = control.getSetting(HISTORY_KEY)
        if history != "":
            query = query + HISTORY_DELIM
        history = query + history
        while history.count(HISTORY_DELIM) > 6:
            history = history.rsplit(HISTORY_DELIM, 1)[0]
        control.setSetting(HISTORY_KEY, history)

    return control.draw_items(_BROWSER.search_site(query))
Пример #11
0
 def __init__(self):
     self.ClientID = control.getSetting('rd.client_id')
     if self.ClientID == '':
         self.ClientID = 'X245A4XAIBGVM'
     self.OauthUrl = 'https://api.real-debrid.com/oauth/v2/'
     self.DeviceCodeUrl = "device/code?%s"
     self.DeviceCredUrl = "device/credentials?%s"
     self.TokenUrl = "token"
     self.token = control.getSetting('rd.auth')
     self.refresh = control.getSetting('rd.refresh')
     self.DeviceCode = ''
     self.ClientSecret = control.getSetting('rd.secret')
     self.OauthTimeout = 0
     self.OauthTimeStep = 0
     self.BaseUrl = "https://api.real-debrid.com/rest/1.0/"
     self.cache_check_results = {}
Пример #12
0
 def __init__(self):
     self.client_id = "855400527"
     ##        self.client_secret = ""
     self.headers = {
         'Authorization':
         'Bearer {}'.format(control.getSetting('premiumize.token'))
     }
Пример #13
0
def PLAY(payload, params):
    anilist_id, episode, filter_lang = payload.rsplit("/")
    sources = _BROWSER.get_sources(anilist_id, episode, filter_lang, 'show')
    _mock_args = {"anilist_id": anilist_id}

    if control.getSetting('general.playstyle.episode') == '1' or params.get('source_select'):

        from resources.lib.windows.source_select import SourceSelect

        link = SourceSelect(*('source_select.xml', control.ADDON_PATH),
                            actionArgs=_mock_args, sources=sources).doModal()
    else:
        from resources.lib.windows.resolver import Resolver

        resolver = Resolver(*('resolver.xml', control.ADDON_PATH),
                            actionArgs=_mock_args)

        link = resolver.doModal(sources, {}, False)

    player.play_source(link,
                        anilist_id,
                        watchlist_update,
                        _BROWSER.get_episodeList,
                        int(episode),
                        filter_lang)
Пример #14
0
def LIST_MENU(payload, params):
    return control.draw_items(
        [
            utils.allocate_item(name, url, True, image)
            for name, url, image in MENU_ITEMS
        ],
        contentType=control.getSetting("contenttype.menu"),
    )
Пример #15
0
def bookmark_episode_playing(link):
    if not _BROWSER.is_logged_in():
        return None

    if "Yes" in control.getSetting('9anime.eptrack'):
        return _BROWSER.episode_playing(link)
    else:
        return None
Пример #16
0
def bookmark_episode_playing(link):
    if not _BROWSER.is_logged_in():
        return None

    if "Yes" in control.getSetting('9anime.eptrack'):
        return _BROWSER.episode_playing(link)
    else:
        return None
Пример #17
0
def sortResultsByRes(fetched_urls):
    prefereResSetting = utils.parse_resolution_of_source(control.getSetting('prefres'))

    filtered_urls = filter(lambda x: utils.parse_resolution_of_source(x[0]) <=
                           prefereResSetting, fetched_urls)

    return sorted(filtered_urls, key=lambda x:
                  utils.parse_resolution_of_source(x[0]),
                  reverse=True)
 def get_anime_episodes(self, anime_id, page=1):
     data = {
         "m": 'release',
         "id": anime_id,
         "sort": 'episode_asc' if 'Ascending' in control.getSetting('reverseorder') else 'episode_desc',
         "page": page,
     }
     url = self._BASE_URL
     return self._process_episode_view(url, data, "animes_page/%s/%%d" % anime_id, page)
Пример #19
0
def sortResultsByRes(fetched_urls):
    prefereResSetting = utils.parse_resolution_of_source(control.getSetting('prefres'))

    filtered_urls = filter(lambda x: utils.parse_resolution_of_source(x[0]) <=
                           prefereResSetting, fetched_urls)

    return sorted(filtered_urls, key=lambda x:
                  utils.parse_resolution_of_source(x[0]),
                  reverse=True)
Пример #20
0
def ANIMES_PAGE(payload, params):
    anime_url, flavor_or_season = payload.rsplit("/", 1)
    desc_order = False if "Ascending" in control.getSetting('reverseorder') else True
    content_type = get_animes_contentType()
    view_type = control.getSetting('viewtype.episode')
    if anime_url.find("/") == -1:
        # Seasons
        is_dubbed = True if "dub" == flavor_or_season else False
        seasons = _BROWSER.get_anime_seasons(anime_url, is_dubbed, desc_order)
        content_type = get_animes_contentType(seasons)
        return control.draw_items(seasons, content_type, view_type)

    season = flavor_or_season
    anime_url, flavor = anime_url.rsplit("/", 1)
    is_dubbed = True if "dub" == flavor else False

    episodes = _BROWSER.get_anime_episodes(anime_url, is_dubbed, season, desc_order)
    return control.draw_items(episodes, content_type, view_type)
Пример #21
0
def SEARCH(payload, params):
    query = control.keyboard(control.lang(30009))
    if not query:
        return False

    # TODO: Better logic here, maybe move functionatly into router?
    if "Yes" in control.getSetting('searchhistory'):
        database.addSearchHistory(query, 'show')
        history = database.getSearchHistory('show')

    return control.draw_items(_ANILIST_BROWSER.get_search(query))
Пример #22
0
def GOGO_PLAY(payload, params):
    sources = GogoAnimeBrowser().get_episode_sources(payload)
    autoplay = True if 'true' in control.getSetting('autoplay') else False

    s = SourcesList(
        sorted(sources.items()), autoplay, sortResultsByRes, {
            'title': control.lang(30100),
            'processing': control.lang(30101),
            'choose': control.lang(30102),
            'notfound': control.lang(30103),
        })

    control.play_source(s.get_video_link())
Пример #23
0
def TOOLS_MENU(payload, params):
    TOOLS_ITEMS = [
        (control.lang(30020), "settings", ''),
        (control.lang(30021), "clear_cache", ''),
        (control.lang(30022), "clear_torrent_cache", ''),
        (control.lang(30023), "clear_history", ''),
        (control.lang(30026), "rebuild_database", ''),
        (control.lang(30024), "wipe_addon_data", ''),
        ]

    return control.draw_items(
        [utils.allocate_item(name, url, True, image) for name, url, image in TOOLS_ITEMS],
        contentType=control.getSetting("contenttype.menu"),
    )        
Пример #24
0
def _add_last_watched():
    anilist_id = control.getSetting("addon.last_watched")
    if not anilist_id:
        return

    try:
        last_watched = ast.literal_eval(
            database.get_show(anilist_id)['kodi_meta'])
    except:
        return

    MENU_ITEMS.insert(
        0, ("%s[I]%s[/I]" % (control.lang(30000), last_watched['name']),
            "animes/%s/" % anilist_id, last_watched['poster']))
Пример #25
0
def PLAY(payload, params):
    anime_url, kitsu_id = payload.rsplit("/", 1)
    anime_url, episode = anime_url.rsplit("/", 1)
    anime_url, season = anime_url.rsplit("/", 1)
    anime_url, flavor = anime_url.rsplit("/", 1)
    is_dubbed = True if "dub" == flavor else False
    name, image = _BROWSER.get_anime_metadata(anime_url, is_dubbed)
    sources = _BROWSER.get_episode_sources(anime_url, is_dubbed, season, episode)
    autoplay = True if 'true' in control.getSetting('autoplay') else False

    s = SourcesList(sorted(sources.items()), autoplay, sortResultsByRes, {
        'title': control.lang(30100),
        'processing': control.lang(30101),
        'choose': control.lang(30102),
        'notfound': control.lang(30103),
    })

    __set_last_watched(anime_url, is_dubbed, name, image)
    control.play_source(s.get_video_link(),
                        watchlist_update(episode, kitsu_id),
                        on_stopped,
                        on_percent if 'true' in control.getSetting('watchlist.percentbool') else None
                        )
Пример #26
0
def PLAY(payload, params):
    ep_id = payload
    sources = _BROWSER.get_episode_sources(ep_id, params['session'])
    autoplay = True if 'true' in control.getSetting('autoplay') else False

    s = SourcesList(
        sorted(sources.items()), autoplay, sortResultsByRes, {
            'title': control.lang(30100),
            'processing': control.lang(30101),
            'choose': control.lang(30102),
            'notfound': control.lang(30103),
        })

    control.play_source(s.get_video_link())
Пример #27
0
    def __init__(self, xml_file, xml_location, actionArgs=None):

        try:
            super(PlayingNext, self).__init__(xml_file,
                                              xml_location,
                                              actionArgs=actionArgs)
            self.player = control.player()
            self.playing_file = self.player.getPlayingFile()
            self.duration = self.player.getTotalTime() - self.player.getTime()
            self.closed = False
            self.actioned = None
            self.default_action = control.getSetting(
                'playingnext.defaultaction')
        except:
            import traceback
            traceback.print_exc()
Пример #28
0
    def __init__(self, xml_file, xml_location, actionArgs=None):

        try:
            super(SkipIntro, self).__init__(xml_file,
                                            xml_location,
                                            actionArgs=actionArgs)
            self.player = control.player()
            self.playing_file = self.player.getPlayingFile()
            self.duration = self.player.getTotalTime() - self.player.getTime()
            self.skip = int(control.getSetting('skipintro.time'))
            self.closed = False
            self.actioned = None
            self.default_action = '0'
        except:
            import traceback
            traceback.print_exc()
Пример #29
0
    def resolve_item(self):
        if control.getSetting('general.autotrynext') == 'true':
            sources = self.sources[self.position:]
        else:
            sources = [self.sources[self.position]]

        if self.rescrape:
            selected_source = self.sources[self.position]
            selected_source['name'] = selected_source['release_title']
            database.addTorrentList(self.anilist_id, [selected_source], 2)

        resolver = Resolver(*('resolver.xml', control.ADDON_PATH),
                            actionArgs=self.actionArgs)

        self.stream_link = resolver.doModal(sources, {}, False)

        if self.stream_link is None:
            return
        else:
            self.close()
Пример #30
0
def PLAY_MOVIE(payload, params):
    anilist_id, episode = payload.rsplit("/")
    sources = _BROWSER.get_sources(anilist_id, episode, 'movie')

    _mock_args = {'anilist_id': anilist_id}

    if control.getSetting('general.playstyle.movie') == '1' or params:

        from resources.lib.windows.source_select import SourceSelect

        link = SourceSelect(*('source_select.xml', control.ADDON_PATH),
                            actionArgs=_mock_args,
                            sources=sources).doModal()
    else:
        from resources.lib.windows.resolver import Resolver

        resolver = Resolver(*('resolver.xml', control.ADDON_PATH),
                            actionArgs=_mock_args)

        link = resolver.doModal(sources, {}, False)

    player.play_source(link, anilist_id, watchlist_update, None, int(episode))
Пример #31
0
def ANIMES_PAGE(animeurl, params):
    order = control.getSetting('reverseorder')
    episodes = _BROWSER.get_anime_episodes(animeurl, isDirectoryStyle())
    if ("Ascending" in order):
        episodes = reversed(episodes)
    return control.draw_items(episodes)
Пример #32
0
def isDirectoryStyle():
    style = control.getSetting('displaystyle')
    return "Directory" == style
Пример #33
0
def ANIMES_PAGE(animeurl, params):
    order = control.getSetting('reverseorder')
    episodes = _BROWSER.get_anime_episodes(animeurl, isDirectoryStyle())
    if ( "Ascending" in order ):
        episodes = reversed(episodes)
    return control.draw_items(episodes)
Пример #34
0
def on_percent():
    return int(control.getSetting('watchlist.percent'))
Пример #35
0
 def __init__(self):
     self.agent_identifier = 'test'
     self.apikey = control.getSetting('alldebrid.apikey')
Пример #36
0
def isDirectoryStyle():
    style = control.getSetting('displaystyle')
    return "Directory" == style
Пример #37
0
def get_animes_contentType(seasons=None):
    contentType = control.getSetting("contenttype.episodes")
    if seasons and seasons[0]['is_dir']:
        contentType = control.getSetting("contenttype.seasons")

    return contentType