Exemplo n.º 1
0
    def playback_checker(self):
        for i in range(0, 300):
            if self.isPlaying():
                break
            xbmc.sleep(100)

        while self.isPlaying():
            try:
                if (self.getTime() / self.getTotalTime()) >= .8:
                    Watched().mark(self.anime_id, self.episode_id)
            except:
                pass
            xbmc.sleep(1000)
Exemplo n.º 2
0
    def add_directory(self, items, mode=True):
        if items is None or len(items) == 0:
            return

        sysaddon = sys.argv[0]
        addon_poster = addon_banner = control.addonInfo('icon')
        addon_fanart = control.addonInfo('fanart')

        mode = 'episodes'
        for i in items:
            try:
                tvshowtitle = i['tvshowtitle']
                anime_id = i['anime_id']
                episode_id = i['episode_id'] if 'episode_id' in i else 0
                if episode_id is 0: continue

                duration = i['duration'] if 'duration' in i else 0
                if duration is 0 or duration is None:
                    duration = 24 * 60
                else:
                    duration = duration * 60

                url = '%s?action=play' % sysaddon
                try:
                    url += '&anime_id=%s&episode_id=%s' % (anime_id,
                                                           episode_id)
                except:
                    pass

                episodetitle = i['title']
                plot = i['plot']
                if plot is u'' or plot is None:
                    plot = "No overview of episode available at this time."

                season = 1
                episode = i['episode']
                if i['poster'] is not None:
                    poster = self.posterurl % i['poster']
                else:
                    poster = addon_poster
                if i['fanart'] is not None:
                    fanart = self.fanarturl % i['fanart']
                else:
                    fanart = addon_fanart
                premiered = i['premiered']

                genre = [g['name'] for g in i['genre']]
                genre = ' / '.join(genre)

                iswatched = Watched().watched(anime_id, episode_id)
                if iswatched:
                    overlay = 7
                    playcount = 1
                else:
                    overlay = 6
                    playcount = 0

                if episodetitle is not None:
                    label = "%s - %sx%s - %s" % (tvshowtitle, int(season),
                                                 int(episode), episodetitle)
                else:
                    label = "%s - %sx%s" % (tvshowtitle, int(season),
                                            int(episode))

                item = control.item(label=label)

                try:
                    item.setArt({'poster': poster, 'fanart': fanart})
                    item.setInfo(type='Video',
                                 infoLabels={
                                     'Plot': plot,
                                     'Year': premiered,
                                     'premiered': premiered,
                                     'overlay': overlay,
                                     'playcount': playcount,
                                     'episode': episode,
                                     'duration': duration,
                                     'genre': genre,
                                 })
                except:
                    pass

                item.setProperty('Fanart_Image', fanart)
                # item.setProperty('Video', 'true')
                # item.setProperty('IsPlayable', 'true')

                item.setProperty('startoffset', '0')
                item.setProperty('resumetime', '0')
                item.setProperty('totaltime', '1')

                item.addStreamInfo(
                    'video', {
                        'codec': 'h264',
                        'width': 1280,
                        'height': 720,
                        'aspect': round(128 / 720)
                    })
                item.addStreamInfo('audio', {
                    'codec': 'aac',
                    'language': 'en',
                    'channels': 2
                })

                cm = []
                cm.append(
                    ('Browse anime',
                     'Container.Update(%s?action=get_episodes&anime_id=%s)' %
                     (sysaddon, anime_id)))

                if iswatched:
                    cm.append((
                        'Unmark as Watched',
                        'RunPlugin(%s?action=watched&anime_id=%s&episode_id=%s&unmark=True)'
                        % (sysaddon, anime_id, episode_id)))
                else:
                    cm.append((
                        'Mark as Watched',
                        'RunPlugin(%s?action=watched&anime_id=%s&episode_id=%s)'
                        % (sysaddon, anime_id, episode_id)))
                item.addContextMenuItems(cm)

                control.addItem(handle=int(sys.argv[1]),
                                url=url,
                                listitem=item,
                                isFolder=False)
            except:
                pass
        control.directory(int(sys.argv[1]), cacheToDisc=True)
        control.content(int(sys.argv[1]), mode)
        views.setView('episodes', {'skin.confluence': 504})
Exemplo n.º 3
0
    def add_directory(self,
                      items,
                      stype=[],
                      sort=0,
                      status=0,
                      sgenre=[],
                      offset=0):
        if items is None or len(items) == 0:
            return
        print items

        sysaddon = sys.argv[0]
        addon_poster = addon_banner = control.addonInfo('icon')
        addon_fanart = control.addonInfo('fanart')

        # from resources.lib.modules import playcount
        # indicators = playcount.getTVShowIndicators(refresh=True)

        mode = 'tvshows'
        for i in items:
            # try:
            tvshowtitle = i['title']
            anime_id = i['anime_id']
            if anime_id is None: continue
            duration = i['duration']
            if duration is 0 or duration is None:
                duration = 24 * 60
            else:
                duration = duration * 60
            anime_id = i['anime_id']

            animetype = int(i['type'])

            if animetype is 2:
                episode_id = 0
                try:
                    episode_id = i['episodes'].keys()[0]
                except:
                    pass
                if episode_id is 0: continue

                url = '%s?action=play' % sysaddon
                try:
                    url += '&anime_id=%s&episode_id=%s' % (anime_id,
                                                           episode_id)
                except:
                    pass
            else:
                url = '%s?action=get_episodes' % sysaddon
                try:
                    url += '&anime_id=%s' % anime_id
                except:
                    pass

            plot = i['plot']
            if plot is u'' or plot is None:
                plot = "No overview of episode available at this time."

            episode = len(i['episodes'])
            rating = i['rating']
            if rating is None or rating is 0: rating = 0.1
            genre = i['genre']

            if len(i['fanart']) > 0:
                fanart = i['fanart'][random.randint(0, len(i['fanart']) - 1)]
                fanart = self.fanarturl % fanart
            else:
                fanart = addon_fanart
            if i['poster'] is not None:
                poster = self.posterurl % i['poster']
            else:
                poster = addon_poster

            premiered = i['premiered']

            num_watched = Watched().watched(anime_id)

            # tvdb = i['tvdb']
            # if tvdb is not 0:
            # print playcount.getTVShowOverlay(indicators, str(tvdb))
            # print "%s, %s" % (tvdb, trakt.getTraktShowID(tvdb))
            # except: pass

            if num_watched is None: num_watched = 0
            if episode is None: episode = 0
            # print "%s, %s" % (episode, num_watched)
            iswatched = True if num_watched == episode else False
            if iswatched:
                overlay = 7
                pcount = 1
            else:
                overlay = 6
                pcount = 0

            item = control.item(label=tvshowtitle)

            try:
                item.setArt({'poster': poster, 'thumb': poster})
                item.setInfo(type='Video',
                             infoLabels={
                                 'Plot': plot,
                                 'Year': premiered,
                                 'premiered': premiered,
                                 'episode': episode,
                                 'duration': duration,
                                 'genre': genre,
                                 'rating': rating,
                                 'overlay': overlay,
                                 'playcount': pcount
                             })

            except:
                pass

            if animetype is 2:
                item.addStreamInfo(
                    'video', {
                        'codec': 'h264',
                        'width': 1280,
                        'height': 720,
                        'aspect': round(128 / 720)
                    })
                item.addStreamInfo('audio', {
                    'codec': 'aac',
                    'language': 'en',
                    'channels': 2
                })
                item.setProperty('IsPlayable', 'true')

            item.setProperty('Fanart_Image', fanart)
            item.setProperty('WatchedEpisodes', str(num_watched))
            item.setProperty('UnWatchedEpisodes', str(episode - num_watched))
            cm = []
            cm.append(("Show Information", 'Action(Info)'))
            if iswatched:
                cm.append((
                    'Unmark Show as Watched',
                    'RunPlugin(%s?action=watched&anime_id=%s&episode_id=%s&unmark=True)'
                    % (sysaddon, anime_id, -999)))
            else:
                cm.append(
                    ('Mark Show as Watched',
                     'RunPlugin(%s?action=watched&anime_id=%s&episode_id=%s)' %
                     (sysaddon, anime_id, -999)))

            if Favorites().is_favorite(anime_id):
                cm.append(('Remove from Favorite Anime List',
                           'RunPlugin(%s?action=remove_favorite&anime_id=%s)' %
                           (sysaddon, anime_id)))
            else:
                cm.append(('Add to Favorite Anime List',
                           'RunPlugin(%s?action=add_favorite&anime_id=%s)' %
                           (sysaddon, anime_id)))

            item.addContextMenuItems(cm)

            control.addItem(handle=int(sys.argv[1]),
                            url=url,
                            listitem=item,
                            isFolder=False if animetype is 2 else True)
            # control.addItem(handle=int(sys.argv[1]), url=url, listitem=item, isFolder=False)
            # except:
            #     pass

        if int(offset) + self.itemsperpage < self.totalitems:
            item = control.item(label="Next Page")
            url = '%s?action=get_by_select' % sysaddon
            url += '&stype=%s&sort=%s&status=%s&genre=%s&offset=%s' % (
                stype, sort, status, sgenre, (int(offset) + self.itemsperpage))

            item.setArt({'poster': addon_poster, 'fanart': addon_fanart})
            control.addItem(handle=int(sys.argv[1]),
                            url=url,
                            listitem=item,
                            isFolder=True)

        control.directory(int(sys.argv[1]), cacheToDisc=True)
        control.content(int(sys.argv[1]), mode)
        views.setView('tvshows', {'skin.confluence': 504})
Exemplo n.º 4
0
    def episode_directory(self, items):
        if items is None or len(items) == 0:
            return
        sysaddon = sys.argv[0]
        addon_poster = addon_banner = control.addonInfo('icon')
        addon_fanart = control.addonInfo('fanart')

        if self.fanart is None:
            self.fanart = addon_fanart

        mode = 'episodes'
        j = 0
        for i in items:
            # try:
            j += 1
            tvshowtitle = i['title']
            if tvshowtitle is None: tvshowtitle = i['label']
            tvshowtitle = str(j) + " - " + tvshowtitle
            episode_id = i['episode_id']
            anime_id = i['anime_id']
            episode_link = i['episodelink']
            duration = i['duration']
            episode_link = i['episodelink']
            if duration is 0 or duration is None: duration = 24

            url = '%s?action=play' % sysaddon
            try:
                url += '&anime_id=%s&episode_id=%s' % (anime_id, episode_link)
            except:
                pass

            plot = i['plot']
            if plot is u'' or plot is None:
                plot = "No overview of episode available at this time."

            season = i['season']
            if season is 0 or season is None: season = 1

            episode = i['episode']
            if i['fanart'] is not None:
                fanart = self.fanarturl % i['fanart']
            else:
                fanart = addon_fanart

            if i['poster'] is not None:
                poster = self.thumbnailurl % i['poster']
            else:
                poster = addon_poster
            premiered = i['premiered']

            iswatched = Watched().watched(anime_id, episode_id)

            if iswatched:
                overlay = 7
                playcount = 1
            else:
                overlay = 6
                playcount = 0

            item = control.item(label=tvshowtitle)

            try:
                item.setArt({'poster': poster})
            except:
                pass
            try:
                item.setInfo(type='Video',
                             infoLabels={
                                 'Plot': plot,
                                 'plot': plot,
                                 'Year': premiered,
                                 'premiered': premiered,
                                 'overlay': overlay,
                                 'playcount': playcount,
                                 'episode': episode,
                                 'duration': duration,
                                 'season': season,
                                 'title': tvshowtitle,
                                 'mediatype': 'episode'
                             })
            except:
                pass

            item.setProperty('Fanart_Image', fanart)
            # item.setProperty('IsPlayable', 'true')

            item.setProperty('startoffset', '0')
            item.setProperty('resumetime', '0')
            item.setProperty('totaltime', '1')

            item.addStreamInfo(
                'video', {
                    'codec': 'h264',
                    'width': 1280,
                    'height': 720,
                    'aspect': round(128 / 720)
                })
            item.addStreamInfo('audio', {
                'codec': 'aac',
                'language': 'en',
                'channels': 2
            })

            cm = []
            if iswatched:
                cm.append((
                    'Unmark as Watched',
                    'RunPlugin(%s?action=watched&anime_id=%s&episode_id=%s&unmark=True)'
                    % (sysaddon, anime_id, episode_id)))
            else:
                cm.append(
                    ('Mark as Watched',
                     'RunPlugin(%s?action=watched&anime_id=%s&episode_id=%s)' %
                     (sysaddon, anime_id, episode_id)))
            item.addContextMenuItems(cm)
            control.addItem(handle=int(sys.argv[1]),
                            url=url,
                            listitem=item,
                            isFolder=False)
        # except:
        #     pass
        control.content(int(sys.argv[1]), mode)
        control.directory(int(sys.argv[1]), cacheToDisc=True)