def update_players(self):
     players_url = self.addon.getSettingString('players_url')
     players_url = xbmcgui.Dialog().input('Enter URL to download players', defaultt=players_url)
     if not xbmcgui.Dialog().yesno('Download Players', 'Download players from URL?\n[B]{0}[/B]'.format(players_url)):
         return
     self.addon.setSettingString('players_url', players_url)
     downloader = Downloader(
         extract_to='special://profile/addon_data/plugin.video.skin.info.provider/players',
         download_url=players_url)
     downloader.get_extracted_zip()
예제 #2
0
 def get_downloaded_list(self, export_list=None, sorting=False):
     if not export_list:
         return
     date = datetime.datetime.now() - datetime.timedelta(days=2)
     download_url = 'https://files.tmdb.org/p/exports/{}_ids_{}.json.gz'.format(export_list, date.strftime("%m_%d_%Y"))
     raw_list = [loads(i) for i in Downloader(download_url=download_url).get_gzip_text().splitlines()]
     return sorted(raw_list, key=lambda k: k.get('name', '')) if sorting else raw_list
예제 #3
0
 def get_contextmenu(self):
     gtvid = self.item['gtvid']
     title = self.item['title']
     menu = []
     # 詳細情報
     menu.append((Common.STR(30906), 'Action(Info)'))
     # スマートリストに追加
     try:
         if self.item['genre'][0]:
             genre = self.item['genre'][0].split('/')
         else:
             genre = ['', '']
     except Exception:
         genre = ['', '']
     args = {
         'mode': 'beginEditSmartList',
         'name': title,
         'ch': self.item['ch'],
         'g0': genre[0],
         'g1': genre[1]
     }
     menu.append((Common.STR(30903),
                  'RunPlugin(%s?%s)' % (sys.argv[0], urlencode(args))))
     # お気に入りに追加
     if self.item['favorite'] == '0':
         # add
         args = {
             'mode': 'switchFavorites',
             'name': title,
             'url': urlencode({
                 'gtvid': gtvid,
                 'rank': 1
             })
         }
         menu.append((Common.STR(30925),
                      'RunPlugin(%s?%s)' % (sys.argv[0], urlencode(args))))
     else:
         # delete
         args = {
             'mode': 'switchFavorites',
             'name': title,
             'url': urlencode({
                 'gtvid': gtvid,
                 'rank': 0
             })
         }
         menu.append((Common.STR(30926),
                      'RunPlugin(%s?%s)' % (sys.argv[0], urlencode(args))))
     # サウンロードに追加
     menu += Downloader().contextmenu(self.item,
                                      Request().content_url(gtvid))
     # トップに戻る
     menu.append((Common.STR(30936),
                  'Container.Update(%s,replace)' % (sys.argv[0])))
     return menu
예제 #4
0
 def top(self):
     # 放送中の番組
     self.add_directory_item(Common.STR(30916), self.query, 16, context='top', iconimage=Common.RETRO_TV)
     # 検索:日付
     self.add_directory_item(Common.STR(30933), '', 'selectDate', context='top', iconimage=Common.CALENDAR)
     # 検索:チャンネル
     self.add_directory_item(Common.STR(30934), '', 'selectChannel', context='top', iconimage=Common.RADIO_TOWER)
     # 検索:ジャンル
     self.add_directory_item(Common.STR(30935), '', 'selectGenre', context='top', iconimage=Common.CATEGORIZE)
     # お気に入り
     self.add_directory_item(Common.STR(30923), '%s&rank=all' % self.query, 'search', context='top', iconimage=Common.FAVORITE_FOLDER)
     # ダウンロード
     Downloader().top(Common.DOWNLOADS_FOLDER)
     # スマートリスト
     for i in SmartList().getList():
         title = i['title']
         query = i['query']
         self.add_directory_item(title, query, 'search', context='smartlist', iconimage=Common.BROWSE_FOLDER)
     # end of directory
     xbmcplugin.endOfDirectory(int(sys.argv[1]))
    def run(self):
        """ Execution of the plugin """
        # save last activity timestamp
        self.settings.reset_user_activity()
        # process operation
        self.info("Plugin invoked with parameters {}", self.args)
        mode = self.get_arg('mode', None)
        if mode is None:
            self.show_main_menu()
        elif mode == 'search':
            extendedsearch = self.get_arg('extendedsearch', 'False') == 'True'
            self.show_searches(extendedsearch)
        elif mode == 'newsearch':
            self.new_search(self.get_arg('extendedsearch', 'False') == 'True')
        elif mode == 'research':
            search = self.get_arg('search', '')
            extendedsearch = self.get_arg('extendedsearch', 'False') == 'True'
            self.database.search(search, FilmUI(self), extendedsearch)
            RecentSearches(self, extendedsearch).load().add(search).save()
        elif mode == 'delsearch':
            search = self.get_arg('search', '')
            extendedsearch = self.get_arg('extendedsearch', 'False') == 'True'
            RecentSearches(
                self, extendedsearch).load().delete(search).save().populate()
            self.run_builtin('Container.Refresh')
        elif mode == 'livestreams':
            self.database.get_live_streams(
                FilmUI(self, [xbmcplugin.SORT_METHOD_LABEL]))
        elif mode == 'recent':
            channel = self.get_arg('channel', 0)
            self.database.get_recents(channel, FilmUI(self))
        elif mode == 'recentchannels':
            self.database.get_recent_channels(ChannelUI(self,
                                                        nextdir='recent'))
        elif mode == 'channels':
            self.database.get_channels(ChannelUI(self, nextdir='shows'))
        elif mode == 'action-dbinfo':
            self.show_db_info()
        elif mode == 'action-dbupdate':
            self.settings.trigger_update()
            self.notifier.show_notification(30963, 30964, time=10000)
        elif mode == 'initial':
            channel = self.get_arg('channel', 0)
            self.database.get_initials(channel, InitialUI(self))
        elif mode == 'shows':
            channel = self.get_arg('channel', 0)
            initial = self.get_arg('initial', None)
            self.database.get_shows(channel, initial, ShowUI(self))
        elif mode == 'films':
            show = self.get_arg('show', 0)
            self.database.get_films(show, FilmUI(self))
        elif mode == 'downloadmv':
            filmid = self.get_arg('id', 0)
            quality = self.get_arg('quality', 1)
            Downloader(self).download_movie(filmid, quality)
        elif mode == 'downloadep':
            filmid = self.get_arg('id', 0)
            quality = self.get_arg('quality', 1)
            Downloader(self).download_episode(filmid, quality)
        elif mode == 'playwithsrt':
            filmid = self.get_arg('id', 0)
            Downloader(self).play_movie_with_subs(filmid)

        # cleanup saved searches
        if mode is None or mode != 'newsearch':
            self.set_setting('lastsearch1', '')
            self.set_setting('lastsearch2', '')
예제 #6
0
    def run(self):
        """ Execution of the plugin """
        start = time.time()
        # save last activity timestamp
        self.settings.user_activity()
        # process operation
        self.logger.info("Plugin invoked with parameters {}", self.args)
        self.logger.debug("start View id {}", self.getCurrentViewId())
        self.logger.debug("start Skin {}", self.getSkinName())
        #
        mode = self.get_arg('mode', None)
        if mode is None:
            self.show_main_menu()
            self.setViewId(self.resolveViewId('MAIN'))
        elif mode == 'search':
            self.show_searches()
            self.setViewId(self.resolveViewId('MAIN'))
        elif mode == 'newsearch':
            self.new_search()
        elif mode == 'research':
            search = self.get_arg('search', '')
            ui = FilmlistUi.FilmlistUi(self)
            ui.generate(self.database.getQuickSearch(search))
            RecentSearches(self).load().add(search).save()
            #
        elif mode == 'delsearch':
            search = self.get_arg('search', '')
            RecentSearches(self).load().delete(search).save().populate()
            self.run_builtin('Container.Refresh')
            self.setViewId(self.resolveViewId('MAIN'))
            #
        elif mode == 'extendedSearchScreen':
            ExtendedSearch(self, self.database,
                           self.get_arg('extendedSearchAction', None),
                           self.get_arg('searchId', None)).show()
            #
        elif mode == 'livestreams':
            ui = LivestreamUi.LivestreamUi(self)
            ui.generate(self.database.getLivestreams())
            #
        elif mode == 'recent':
            channel = self.get_arg('channel', "")
            channel == "" if channel == "0" else channel
            ui = FilmlistUi.FilmlistUi(self)
            ui.generate(self.database.getRecentFilms(channel))
            # self.database.get_recents(channel, FilmUI(self))
            #
        elif mode == 'recentchannels':
            #
            self.add_folder_item(30906, {'mode': 'recent'},
                                 icon=os.path.join(self.path, 'resources',
                                                   'icons', 'broadcast-m.png'))
            ui = ChannelUi.ChannelUi(self, 'recent')
            ui.generate(self.database.getChannelsRecent())
        elif mode == 'channels':
            #
            self.add_folder_item(30906, {'mode': 'initial'},
                                 icon=os.path.join(self.path, 'resources',
                                                   'icons', 'broadcast-m.png'))
            #
            ui = ChannelUi.ChannelUi(self, 'shows')
            ui.generate(self.database.getChannels())
        elif mode == 'action-dbinfo':
            self.run_builtin("ActivateWindow(busydialognocancel)")
            self.show_db_info()
            self.run_builtin("Dialog.Close(busydialognocancel)")
        elif mode == 'action-dbupdate':
            self.settings.set_update_triggered('true')
            self.notifier.show_notification(30963, 30964)
        elif mode == 'initial':
            ui = LetterUi.LetterUi(self)
            ui.generate(self.database.getStartLettersOfShows())
        elif mode == 'shows':
            channel = self.get_arg('channel', "")
            channel == "" if channel == "0" else channel
            initial = self.get_arg('initial', "")
            initial == "" if initial == "0" else initial
            # self.database.get_shows(channel, initial, ShowUI(self))
            ui = ShowUi.ShowUi(self)
            if initial == "":
                ui.generate(self.database.getShowsByChannnel(channel))
            else:
                ui.generate(self.database.getShowsByLetter(initial))
        elif mode == 'films':
            show = self.get_arg('show', "")
            show == "" if show == "0" else show
            channel = self.get_arg('channel', "")
            channel == "" if channel == "0" else channel
            # self.database.get_films(show, FilmUI(self))
            ui = FilmlistUi.FilmlistUi(self, pLongTitle=False)
            ui.generate(self.database.getFilms(channel, show))
            #
        elif mode == 'downloadmv':
            filmid = self.get_arg('id', "")
            quality = self.get_arg('quality', 1)
            Downloader(self).download_movie(filmid, quality)
        elif mode == 'downloadep':
            filmid = self.get_arg('id', "")
            quality = self.get_arg('quality', 1)
            Downloader(self).download_episode(filmid, quality)
        elif mode == 'playwithsrt':
            filmid = self.get_arg('id', "")
            Downloader(self).play_movie_with_subs(filmid)

        # cleanup saved searches
        if self.get_setting('lastsearch1') != '' and (mode is None
                                                      or mode != 'newsearch'):
            self.set_setting('lastsearch1', '')
        #
        self.logger.info('request processed: {} sec', time.time() - start)
        #
        self.logger.debug(" View id {}", self.getCurrentViewId())
        self.logger.debug(" Skin {}", self.getSkinName())
예제 #7
0
 def __init__(self, query='bc=all&genre=all&bc=all'):
     self.query = query
     self.args, _ = self.update_query(self.query)
     self.downloader = Downloader()
예제 #8
0
class Browse:
    def __init__(self, query='bc=all&genre=all&bc=all'):
        self.query = query
        self.args, _ = self.update_query(self.query)
        self.downloader = Downloader()

    def update_query(self, query, values=None):
        args = parse_qs(query, keep_blank_values=True)
        for key in args.keys():
            args[key] = args[key][0]
        args.update(values or {})
        return args, urlencode(args)

    def show_top(self):
        # 検索:日付
        self.__add_directory_item(name=Const.STR(30933),
                                  query='',
                                  action='setdate',
                                  iconimage=Const.CALENDAR)
        # 検索:チャンネル
        self.__add_directory_item(name=Const.STR(30934),
                                  query='',
                                  action='setchannel',
                                  iconimage=Const.RADIO_TOWER)
        # 検索:ジャンル
        self.__add_directory_item(name=Const.STR(30935),
                                  query='',
                                  action='setgenre',
                                  iconimage=Const.CATEGORIZE)
        # ダウンロード
        self.downloader.top(Const.DOWNLOADS)
        # end of directory
        xbmcplugin.endOfDirectory(int(sys.argv[1]))

    def show_date(self):
        # すべての日付
        name = Const.STR(30820)
        # 月,火,水,木,金,土,日
        w = Const.STR(30920).split(',')
        # 次のアクション
        if self.args.get('bc') is None:
            action = 'setchannel'
        elif self.args.get('genre') is None:
            action = 'setgenre'
        else:
            action = 'search'
        _, query = self.update_query(self.query, {'date': ''})
        self.__add_directory_item(name,
                                  query,
                                  action,
                                  iconimage=Const.CALENDAR)
        # 直近30日分のメニューを追加
        for i in range(30):
            d = datetime.date.today() - datetime.timedelta(i)
            wd = d.weekday()
            # 8月31日(土)
            # date1 = d.strftime(Const.STR(30919)) % w[wd]
            date1 = strftime(d, Const.STR(30919)) % w[wd]
            # 2019-08-31
            date2 = d.strftime('%Y-%m-%d')
            if isholiday(date2) or wd == 6:
                name = '[COLOR red]%s[/COLOR]' % date1
            elif wd == 5:
                name = '[COLOR blue]%s[/COLOR]' % date1
            else:
                name = date1
            _, query = self.update_query(self.query, {'date': date2})
            self.__add_directory_item(name,
                                      query,
                                      action,
                                      iconimage=Const.CALENDAR)
        # end of directory
        xbmcplugin.endOfDirectory(int(sys.argv[1]))

    def show_channel(self):
        bc_list = [
            ('', Const.STR(30810)),
            ('ntv', Const.STR(30811)),
            ('ex', Const.STR(30812)),
            ('tbs', Const.STR(30813)),
            ('tx', Const.STR(30814)),
            ('cx', Const.STR(30815)),
            ('nhk', Const.STR(30816)),
        ]
        for id, name in bc_list:
            # 次のアクション
            if self.args.get('genre') is None:
                action = 'setgenre'
            elif self.args.get('date') is None:
                action = 'setdate'
            else:
                action = 'search'
            _, query = self.update_query(self.query, {'bc': id})
            self.__add_directory_item(name,
                                      query,
                                      action,
                                      iconimage=Const.RADIO_TOWER)
        # end of directory
        xbmcplugin.endOfDirectory(int(sys.argv[1]))

    def show_genre(self):
        genre_list = [
            ('', Const.STR(30800)),
            ('drama', Const.STR(30801)),
            ('variety', Const.STR(30802)),
            ('documentary', Const.STR(30803)),
            ('anime', Const.STR(30804)),
            ('sport', Const.STR(30805)),
            ('other', Const.STR(30806)),
        ]
        for id, name in genre_list:
            # 次のアクション
            if self.args.get('bc') is None:
                action = 'setchannel'
            elif self.args.get('date') is None:
                action = 'setdate'
            else:
                action = 'search'
            _, query = self.update_query(self.query, {'genre': id})
            self.__add_directory_item(name,
                                      query,
                                      action,
                                      iconimage=Const.CATEGORIZE)
        # end of directory
        xbmcplugin.endOfDirectory(int(sys.argv[1]))

    def search(self):
        # トークンを取得
        url = 'https://tver.jp/api/access_token.php'
        buf = urlread(url)
        jso = json.loads(buf)
        token = jso.get('token', '')
        # 番組検索
        url = 'https://api.tver.jp/v4/search?catchup=1&%s&token=%s' % (
            self.query, token)
        buf = urlread(url)
        datalist = json.loads(buf).get('data', [])
        datadict = {}
        for data in sorted(datalist,
                           key=lambda item: self.__date(item),
                           reverse=True):
            '''
            {
                "bool": {
                    "cast": 1
                },
                "catchup_id": "f0058710",
                "date": "7月14日(火)放送分",
                "expire": "10月21日(水) 00:53 終了予定",
                "ext": {
                    "adconfigid": null,
                    "allow_scene_share": true,
                    "catch": "",
                    "episode_number": "598",
                    "is_caption": false,
                    "live_lb_type": null,
                    "multiple_catchup": false,
                    "share_secret": "c950d127003629617cc5fffbcbde3c95",
                    "site_catch": "",
                    "stream_id": null,
                    "yospace_id": null
                },
                "href": "/feature/f0058710",
                "images": [
                    {
                        "image": "https://api-cdn.tver.jp/s3/@202010/image/@20201007/638c1baf-3a27-47f2-92f0-54038255ab77.jpg",
                        "large": "https://api-cdn.tver.jp/s3/@202010/large/@20201007/2444cd40-0558-4d18-923a-3496745ebbf0.jpg",
                        "right": "(C) ytv",
                        "small": "https://api-cdn.tver.jp/s3/@202010/small/@20201007/07009320-8d91-4308-85c4-7277758f03b3.jpg",
                        "type": "e_cut"
                    }
                ],
                "media": "読売テレビ",
                "mylist_id": "f0009802",
                "player": "videocloud",
                "pos": "/search",
                "publisher_id": "5330942432001",
                "reference_id": "Niketsu_598_200715",
                "service": "ts_ytv",
                "subtitle": "ジュニア衝撃ぬるいカップ麺&芸人名言",
                "title": "にけつッ!!",
                "type": "catchup",
                "url": "http://www.ytv.co.jp/niketsu/"
            }
            '''
            # 表示
            self.__add_item(data)
        # end of directory
        xbmcplugin.endOfDirectory(int(sys.argv[1]))

    def play(self, url):
        url = self.__extract_url(url)
        # xbmc.executebuiltin('PlayMedia(%s)' % url)
        xbmcplugin.setResolvedUrl(int(sys.argv[1]),
                                  succeeded=True,
                                  listitem=xbmcgui.ListItem(path=url))

    def download(self, url, contentid):
        url = self.__extract_url(url)
        self.downloader.download(url, contentid)

    def __extract_url(self, url):
        # 番組詳細を取得
        #
        # https://tver.jp/episode/77607556
        #
        buf = urlread(url)
        args = {}
        keys = ('player_id', 'player_key', 'catchup_id', 'publisher_id',
                'reference_id', 'title', 'sub_title', 'service',
                'service_name', 'sceneshare_enabled', 'share_start')
        '''
        function showPlayer(){
            if( canPlayMovie() ){
                addPlayer(
                    '4394098882001',
                    'TtyB0eZ4Y',
                    'f0058835',
                    '4394098882001',
                    '104da7b3-2df3-491a-bab2-5f08793e608a',
                    'ぶらり途中下車の旅',
                    ' 小田急線',
                    'ntv',
                    '日テレ無料',
                    true,
                    0
                );
            }else{
                addSpPlayer(
                    'f0058835',
                    'ぶらり途中下車の旅',
                    ' 小田急線',
                    'ntv',
                    '日テレ無料',
                    'https%3A%2F%2Ftver.jp%2Fepisode%2F77607556',
                    '',
                    '104da7b3-2df3-491a-bab2-5f08793e608a',
                    0,
                    ''
                );
            }
        }
        '''
        vals = map(
            lambda x: x.strip(" '\t"),
            re.search(r'addPlayer\((.*?)\);',
                      re.sub(r'\n', ' ', buf.decode())).group(1).split(','))
        for key, val in zip(keys, vals):
            args[key] = val
        # ポリシーキーを取得
        #
        # https://players.brightcove.net/4394098882001/TtyB0eZ4Y_default/index.min.js?_=1602300285436
        #
        url = 'https://players.brightcove.net/%s/%s_default/index.min.js' % (
            args['player_id'], args['player_key'])
        buf = urlread(url)
        #
        # options:{accountId:"4394098882001",policyKey:"BCpkADawqM1l5pA4XtMLusHj72LGzFewqKZzldpmNYTUQdoKnFL_GHhN3dg5FRnNQ5V7SOUKBl-tYFMt8CpSzuSzFAPhIHtVwmMz6F52VnMfu2UjDmeYfvvUqk0CWon46Yh-CZwIVp5vfXrZ"}
        #
        pk = re.search(r'options:\{accountId:"(.*?)",policyKey:"(.*?)"\}',
                       buf.decode()).group(2)
        # HLSマスターのURLを取得
        if args['service'] != 'tx' and args[
                'service'] != 'russia2018' and args['service'] != "gorin":
            ref_id = 'ref:' + args['reference_id']
        else:
            ref_id = args['reference_id']
        #
        # https://edge.api.brightcove.com/playback/v1/accounts/5102072603001/videos/ref%3Asunday_variety_episode_code_6950
        #
        url = 'https://edge.api.brightcove.com/playback/v1/accounts/%s/videos/%s' % (
            args['publisher_id'], ref_id)
        buf = urlread(url, ('Accept', 'application/json;pk=%s' % pk))
        jso = json.loads(buf)
        src = jso.get('sources')[3].get('src')
        #
        # https://manifest.prod.boltdns.net/manifest/v1/hls/v4/aes128/4394098882001/15157782-1259-4ba1-b9e6-ee7298b261f6/10s/master.m3u8?fastly_token=NWZhNjY1MTVfNGIyZjQzZDc0ZTg0YmY3NTg0OTE1YThjOGQzZjk2NDk5NTcyMzU4N2ViYzFiZDY2NDBjN2QwZWMxNTIwYjZmNw%3D%3D
        #
        return src

    def __date(self, item):
        # データの時刻情報
        itemdate = item.get('date', '')
        # 現在時刻
        now = datetime.datetime.now()
        year0 = now.strftime('%Y')
        date0 = now.strftime('%m-%d')
        # 日時を抽出
        date = '0000-00-00'
        m = re.match(r'(20[0-9]{2})年', itemdate)
        if m:
            date = '%s-00-00' % (m.group(1))
        m = re.match(r'([0-9]{1,2})月([0-9]{1,2})日', itemdate)
        if m:
            date1 = '%02d-%02d' % (int(m.group(1)), int(m.group(2)))
            date = '%04d-%s' % (int(year0) -
                                1 if date1 > date0 else int(year0), date1)
        m = re.match(r'([0-9]{1,2})/([0-9]{1,2})', itemdate)
        if m:
            date1 = '%02d-%02d' % (int(m.group(1)), int(m.group(2)))
            date = '%04d-%s' % (int(year0) if date1 < date0 else int(year0) -
                                1, date1)
        # 抽出結果
        return date

    def __labeldate(self, date):
        # listitem.date用に変換
        m = re.search('^([0-9]{4})-([0-9]{2})-([0-9]{2})', date)
        if m:
            date = '%s.%s.%s' % (m.group(3), m.group(2), m.group(1))
        return date

    def __contentid(self, item):
        publisher_id = item.get('publisher_id', 'unknown')
        reference_id = item.get('reference_id', 'unknown')
        hash = hashlib.md5(json.dumps(item).encode()).hexdigest()
        contentid = '%s.%s.%s' % (publisher_id, reference_id, hash)
        return contentid

    def __thumbnail(self, item):
        # ファイルパス
        imagefile = os.path.join(Const.CACHE_PATH,
                                 '%s.png' % self.__contentid(item))
        if os.path.isfile(imagefile) and os.path.getsize(imagefile) < 1000:
            # delete imagefile
            os.remove(imagefile)
            # delete from database
            conn = sqlite.connect(Const.CACHE_DB)
            c = conn.cursor()
            # c.execute("SELECT cachedurl FROM texture WHERE url = '%s';" % imagefile)
            c.execute("DELETE FROM texture WHERE url = '%s';" % imagefile)
            conn.commit()
            conn.close()
        if os.path.isfile(imagefile):
            pass
        else:
            buffer = urlread(item['images'][0]['small'])
            image = Image.open(io.BytesIO(buffer))  # 320x180
            image = image.resize((216, 122))
            background = Image.new('RGB', (216, 216), (0, 0, 0))
            background.paste(image, (0, 47))
            background.save(imagefile, 'PNG')
        return imagefile

    def __add_item(self, item):
        # 番組情報を付加
        s = item['_summary'] = {
            'title': item.get('title', 'n/a'),
            'url': 'https://tver.jp%s' % item['href'],
            'date': self.__date(item),
            'description': item.get('subtitle', ''),
            'source': item.get('media', 'n/a'),
            'category': '',
            'duration': '',
            'thumbnail': item['images'][0]['small'],
            'thumbfile': self.__thumbnail(item),
            'contentid': self.__contentid(item),
        }
        # listitem
        labels = {
            'title': s['title'],
            'plot': '%s\n%s' % (s['date'], s['description']),
            'plotoutline': s['description'],
            'studio': s['source'],
            'date': self.__labeldate(s['date']),
        }
        listitem = xbmcgui.ListItem(item['title'])
        listitem.setArt({
            'icon': s['thumbnail'],
            'thumb': s['thumbnail'],
            'poster': s['thumbnail']
        })
        listitem.setInfo(type='video', infoLabels=labels)
        listitem.setProperty('IsPlayable', 'true')
        # context menu
        contextmenu = []
        contextmenu += [(Const.STR(30938), 'Action(Info)')]  # 詳細情報
        contextmenu += self.downloader.contextmenu(item)  # ダウンロード追加/削除
        contextmenu += [
            (Const.STR(30936), 'Container.Update(%s,replace)' % sys.argv[0])
        ]  # トップに戻る
        contextmenu += [
            (Const.STR(30937), 'RunPlugin(%s?action=settings)' % sys.argv[0])
        ]  # アドオン設定
        listitem.addContextMenuItems(contextmenu, replaceItems=True)
        # add directory item
        url = '%s?action=%s&url=%s' % (sys.argv[0], 'play', quote_plus(
            s['url']))
        xbmcplugin.addDirectoryItem(int(sys.argv[1]), url, listitem, False)

    def __add_directory_item(self, name, query, action, iconimage=''):
        # listitem
        listitem = xbmcgui.ListItem(name)
        listitem.setArt({'icon': iconimage})
        # context menu
        contextmenu = []
        if query:
            contextmenu += [(Const.STR(30936),
                             'Container.Update(%s,replace)' % sys.argv[0])
                            ]  # トップに戻る
        contextmenu += [
            (Const.STR(30937), 'RunPlugin(%s?action=settings)' % sys.argv[0])
        ]  # アドオン設定
        listitem.addContextMenuItems(contextmenu, replaceItems=True)
        # add directory item
        url = '%s?action=%s&query=%s' % (sys.argv[0], action,
                                         quote_plus(query))
        xbmcplugin.addDirectoryItem(int(sys.argv[1]), url, listitem, True)
예제 #9
0
    def run(self):
        # save last activity timestamp
        self.settings.ResetUserActivity()
        # process operation
        mode = self.get_arg('mode', None)
        if mode is None:
            self.show_main_menu()
        elif mode == 'search':
            extendedsearch = self.get_arg('extendedsearch', 'False') == 'True'
            self.show_searches(extendedsearch)
        elif mode == 'newsearch':
            self.new_search(self.get_arg('extendedsearch', 'False') == 'True')
        elif mode == 'research':
            search = self.get_arg('search', '')
            extendedsearch = self.get_arg('extendedsearch', 'False') == 'True'
            self.database.Search(search, FilmUI(self), extendedsearch)
            RecentSearches(self, extendedsearch).load().add(search).save()
        elif mode == 'delsearch':
            search = self.get_arg('search', '')
            extendedsearch = self.get_arg('extendedsearch', 'False') == 'True'
            RecentSearches(
                self, extendedsearch).load().delete(search).save().populate()
            self.runBuiltin('Container.Refresh')
        elif mode == 'livestreams':
            self.database.GetLiveStreams(
                FilmUI(self, [xbmcplugin.SORT_METHOD_LABEL]))
        elif mode == 'recent':
            channel = self.get_arg('channel', 0)
            self.database.GetRecents(channel, FilmUI(self))
        elif mode == 'recentchannels':
            self.database.GetRecentChannels(ChannelUI(self, nextdir='recent'))
        elif mode == 'channels':
            self.database.GetChannels(ChannelUI(self, nextdir='shows'))
        elif mode == 'action-dbinfo':
            self.show_db_info()
        elif mode == 'action-dbupdate':
            self.settings.TriggerUpdate()
            self.notifier.ShowNotification(30963, 30964, time=10000)
        elif mode == 'initial':
            channel = self.get_arg('channel', 0)
            self.database.GetInitials(channel, InitialUI(self))
        elif mode == 'shows':
            channel = self.get_arg('channel', 0)
            initial = self.get_arg('initial', None)
            self.database.GetShows(channel, initial, ShowUI(self))
        elif mode == 'films':
            show = self.get_arg('show', 0)
            self.database.GetFilms(show, FilmUI(self))
        elif mode == 'downloadmv':
            filmid = self.get_arg('id', 0)
            quality = self.get_arg('quality', 1)
            Downloader(self).download_movie(filmid, quality)
        elif mode == 'downloadep':
            filmid = self.get_arg('id', 0)
            quality = self.get_arg('quality', 1)
            Downloader(self).download_episode(filmid, quality)
        elif mode == 'playwithsrt':
            filmid = self.get_arg('id', 0)
            only_sru = self.get_arg('only_set_resolved_url', 'False') == 'True'
            Downloader(self).play_movie_with_subs(filmid, only_sru)

        # cleanup saved searches
        if mode is None or mode != 'search':
            self.addon.setSetting('lastsearch1', '')
        if mode is None or mode != 'searchall':
            self.addon.setSetting('lastsearch2', '')