コード例 #1
0
 def test_Methodheap_MythXML_001_01(self):
     """Test MythXML.getHosts()."""
     m_instance = MythXML()
     hosts = m_instance.getHosts()
     #print(hosts)
     bename = self.testenv['BACKENDNAME']
     self.assertTrue(bename in hosts)
コード例 #2
0
 def test_Methodheap_MythXML_002_01(self):
     """Test MythXML.getHosts() with logging."""
     with add_log_flags():
         m_instance = MythXML()
         hosts = m_instance.getHosts()
         bename = self.testenv['BACKENDNAME']
         self.assertTrue(bename in hosts)
コード例 #3
0
 def test_Methodheap_MythXML_002_02(self):
     """Test MythXML.getKeys() with logging."""
     a = False
     with add_log_flags():
         m_instance = MythXML()
         keys_list = m_instance.getKeys()
         self.assertTrue(u'MenuTheme' in keys_list)
         a = (len(tailandgrep('/tmp/my_logfile', 3, r'/Myth/GetKeys')) > 0)
     self.assertTrue(a)
コード例 #4
0
 def test_Methodheap_MythXML_002_03(self):
     """Test MythXML.getSetting() with logging."""
     a = False
     with add_log_flags():
         m_instance = MythXML()
         port = m_instance.getSetting('BackendServerPort', default='1111')
         self.assertTrue(int(port), 6543)
         a = (len(tailandgrep('/tmp/my_logfile', 3, r'BackendServerPort')) >
              0)
     self.assertTrue(a)
コード例 #5
0
 def test_Methodheap_MythXML_001_06(self):
     """Test MythXML.getChannelIcon()
     """
     m_instance = MythXML()
     icon = m_instance.getChannelIcon(self.testenv['RECCHANID'])
     with open('/tmp/icon', 'wb') as f:
         f.write(icon)
     os.system('file /tmp/icon > /tmp/my_logfile')
     a = (len(tailandgrep('/tmp/my_logfile', 2, 'JPEG|PNG')) > 0)
     self.assertTrue(a)
コード例 #6
0
 def test_Methodheap_MythXML_002_08(self):
     """Test MythXML.getExpiring() with logging."""
     a = False
     with add_log_flags():
         m_instance = MythXML()
         rec_list = m_instance.getExpiring()
         rec = next(rec_list)
         self.assertTrue(len(rec.title) > 0)
         a = (len(tailandgrep('/tmp/my_logfile', 3, r'GetExpiringList')) >
              0)
     self.assertTrue(a)
コード例 #7
0
 def test_Methodheap_MythXML_001_09(self):
     """Test MythXML.getPreviewImage()."""
     m_instance = MythXML()
     rec_chanid = self.testenv['DOWNCHANID']
     rec_starttime = self.testenv['DOWNSTARTTIME']
     preview = m_instance.getPreviewImage(str(rec_chanid), rec_starttime)
     with open('/tmp/preview', 'wb') as f:
         f.write(preview)
     os.system('file /tmp/preview > /tmp/my_logfile')
     a = (len(tailandgrep('/tmp/my_logfile', 2, 'JPEG|PNG')) > 0)
     self.assertTrue(a)
コード例 #8
0
 def test_Methodheap_MythXML_001_04(self):
     """Test MythXML.getProgramGuide()
     """
     now_0 = pdtime.now()
     now_4 = now_0 + pddelta(hours=4)
     m_instance = MythXML()
     guide_list = m_instance.getProgramGuide(now_0.isoformat(),
                                             now_4.isoformat(),
                                             self.testenv['RECCHANID'],
                                             numchan=None)
     prog = next(guide_list)
     self.assertTrue(len(prog.title) > 0)
コード例 #9
0
 def test_Methodheap_MythXML_002_06(self):
     """Test MythXML.getChannelIcon() with logging."""
     a = False
     b = False
     with add_log_flags():
         m_instance = MythXML()
         icon = m_instance.getChannelIcon(self.testenv['RECCHANID'])
         with open('/tmp/icon', 'wb') as f:
             f.write(icon)
         os.system('file /tmp/icon >> /tmp/my_logfile')
         a = (len(tailandgrep('/tmp/my_logfile', 2, 'JPEG|PNG')) > 0)
         self.assertTrue(a)
         b = (len(tailandgrep('/tmp/my_logfile', 3, r'GetChannelIcon')) > 0)
     self.assertTrue(b)
コード例 #10
0
 def test_Methodheap_MythXML_001_05(self):
     """Test MythXML.getProgramDetails().
     """
     now_0 = pdtime.now()
     now_4 = now_0 + pddelta(hours=4)
     m_instance = MythXML()
     guide_list = m_instance.getProgramGuide(now_0.isoformat(),
                                             now_4.isoformat(),
                                             self.testenv['RECCHANID'],
                                             numchan=None)
     prog = next(guide_list)
     self.assertTrue(len(prog.title) > 0)
     p_details = m_instance.getProgramDetails(prog.chanid, prog.starttime)
     #print(repr(p_details))
     self.assertTrue(len(p_details.title) > 0)
コード例 #11
0
 def test_Methodheap_MythXML_002_04(self):
     """Test MythXML.getProgramGuide()  with logging."""
     a = False
     with add_log_flags():
         now_0 = pdtime.now()
         now_4 = now_0 + pddelta(hours=4)
         m_instance = MythXML()
         guide_list = m_instance.getProgramGuide(now_0.isoformat(),
                                                 now_4.isoformat(),
                                                 self.testenv['RECCHANID'],
                                                 numchan=None)
         prog = next(guide_list)
         self.assertTrue(len(prog.title) > 0)
         a = (len(tailandgrep('/tmp/my_logfile', 20, r'GetProgramGuide')) >
              0)
     self.assertTrue(a)
コード例 #12
0
    def test_Methodheap_MythXML_002_010(self):
        """Test MythXML.getRecorded() during standard time and
           daylight saving time.
        """
        preview_cet_is_pic = False
        preview_cest_is_pic = False
        with add_log_flags():
            m_instance = MythXML()
            progs = m_instance.getRecorded()
            try:
                found_cet = False
                found_cest = False
                while True:
                    p = next(progs)
                    if not found_cet:
                        if (p.starttime > self.t1_cet
                                and p.starttime < self.t2_cet):
                            pcet = p
                            found_cet = True
                    if not found_cest:
                        if (p.starttime > self.t1_cest
                                and p.starttime < self.t2_cest):
                            pcest = p
                            found_cest = True
                    if (found_cet and found_cest):
                        break
            except StopIteration:
                raise

            preview_cet = m_instance.getPreviewImage(str(pcet.chanid),
                                                     pcet.recstartts)
            with open('/tmp/preview_cet', 'wb') as f:
                f.write(preview_cet)
            out_cet = System.system('file /tmp/preview_cet')
            preview_cet_is_pic = (len(
                tailandgrep('/tmp/my_logfile', 2, 'JPEG|PNG')) > 0)

            preview_cest = m_instance.getPreviewImage(str(pcest.chanid),
                                                      pcest.recstartts)
            with open('/tmp/preview_cest', 'wb') as f:
                f.write(preview_cest)
            out_cest = System.system('file /tmp/preview_cest')
            preview_cest_is_pic = (len(
                tailandgrep('/tmp/my_logfile', 2, 'JPEG|PNG')) > 0)

        self.assertTrue(preview_cet_is_pic)
        self.assertTrue(preview_cest_is_pic)
コード例 #13
0
    def test_Methodheap_MythXML_001_010(self):
        """Test MythXML.getRecorded() during standard time and
           daylight saving time.
        """
        preview_cet_is_pic = False
        preview_cest_is_pic = False

        m_instance = MythXML()
        progs = m_instance.getRecorded()
        try:
            found_cet = False
            found_cest = False
            while True:
                p = next(progs)
                if not found_cet:
                    if (p.starttime > self.t1_cet
                            and p.starttime < self.t2_cet):
                        pcet = p
                        found_cet = True
                if not found_cest:
                    if (p.starttime > self.t1_cest
                            and p.starttime < self.t2_cest):
                        pcest = p
                        found_cest = True
                if (found_cet and found_cest):
                    break
        except StopIteration:
            raise

        preview_cet = m_instance.getPreviewImage(str(pcet.chanid),
                                                 pcet.recstartts)
        with open('/tmp/preview_cet', 'wb') as f:
            f.write(preview_cet)
        s_cet = System(path='file')
        out_cet = s_cet('/tmp/preview_cet')
        preview_cet_is_pic = ((b'PNG' in out_cet) or (b'JPEG' in out_cet))

        preview_cest = m_instance.getPreviewImage(str(pcest.chanid),
                                                  pcest.recstartts)
        with open('/tmp/preview_cest', 'wb') as f:
            f.write(preview_cest)
        s_cest = System(path='file')
        out_cest = s_cest('/tmp/preview_cest')
        preview_cest_is_pic = ((b'PNG' in out_cest) or (b'JPEG' in out_cest))

        self.assertTrue(preview_cet_is_pic)
        self.assertTrue(preview_cest_is_pic)
コード例 #14
0
    def __init__(
        self,
        apikey,
        mythtv=True,
        interactive=False,
        select_first=False,
        debug=False,
        custom_ui=None,
        language=None,
        search_all_languages=False,
    ):
        """apikey (str/unicode):
            Specify the target site API key. Applications need their own key in some cases

        mythtv (True/False):
            When True, the returned meta data is being returned has the key and values massaged to match MythTV
            When False, the returned meta data  is being returned matches what target site returned

        interactive (True/False): (This option is not supported by all target site apis)
            When True, uses built-in console UI is used to select the correct show.
            When False, the first search result is used.

        select_first (True/False): (This option is not supported currently implemented in any grabbers)
            Automatically selects the first series search result (rather
            than showing the user a list of more than one series).
            Is overridden by interactive = False, or specifying a custom_ui

        debug (True/False):
             shows verbose debugging information

        custom_ui (xx_ui.BaseUI subclass): (This option is not supported currently implemented in any grabbers)
            A callable subclass of interactive class (overrides interactive option)

        language (2 character language abbreviation): (This option is not supported by all target site apis)
            The language of the returned data. Is also the language search
            uses. Default is "en" (English). For full list, run..

        search_all_languages (True/False): (This option is not supported by all target site apis)
            By default, a Netvision grabber will only search in the language specified using
            the language option. When this is True, it will search for the
            show in any language

        """
        self.config = {}
        self.mythxml = MythXML()

        if apikey is not None:
            self.config['apikey'] = apikey
        else:
            pass  # BBC does not require an apikey

        self.config['debug_enabled'] = debug  # show debugging messages
        self.common = common
        self.common.debug = debug  # Set the common function debug level

        self.log_name = u'BBCiPlayer_Grabber'
        self.common.logger = self.common.initLogger(path=sys.stderr,
                                                    log_name=self.log_name)
        self.logger = self.common.logger  # Setups the logger (self.log.debug() etc)

        self.config['custom_ui'] = custom_ui

        self.config['interactive'] = interactive

        self.config['select_first'] = select_first

        self.config['search_all_languages'] = search_all_languages

        self.error_messages = {
            'BBCUrlError':
            u"! Error: The URL (%s) cause the exception error (%s)\n",
            'BBCHttpError':
            u"! Error: An HTTP communications error with the BBC was raised (%s)\n",
            'BBCRssError':
            u"! Error: Invalid RSS meta data\nwas received from the BBC error (%s). Skipping item.\n",
            'BBCVideoNotFound':
            u"! Error: Video search with the BBC did not return any results (%s)\n",
            'BBCConfigFileError':
            u"! Error: bbc_config.xml file missing\nit should be located in and named as (%s).\n",
            'BBCUrlDownloadError':
            u"! Error: Downloading a RSS feed or Web page (%s).\n",
        }

        # Channel details and search results
        self.channel = {
            'channel_title': u'BBC iPlayer',
            'channel_link': u'http://www.bbc.co.uk',
            'channel_description':
            u"BBC iPlayer is our service that lets you catch up with radio and television programmes from the past week.",
            'channel_numresults': 0,
            'channel_returned': 1,
            u'channel_startindex': 0
        }

        # XPath parsers used to detect a video type of item
        self.countryCodeParsers = [
            etree.XPath('.//a[@class="episode-title title-link cta-video"]',
                        namespaces=self.common.namespaces),
            etree.XPath('.//div[@class="feature video"]',
                        namespaces=self.common.namespaces),
            etree.XPath('.//atm:category[@term="TV"]',
                        namespaces=self.common.namespaces),
        ]

        # Season and Episode detection regex patterns
        self.s_e_Patterns = [
            # "Series 7 - Episode 4" or "Series 7 - Episode 4" or "Series 7: On Holiday: Episode 10"
            re.compile(
                u'''^.+?Series\\ (?P<seasno>[0-9]+).*.+?Episode\\ (?P<epno>[0-9]+).*$''',
                re.UNICODE),
            # Series 5 - 1
            re.compile(
                u'''^.+?Series\\ (?P<seasno>[0-9]+)\\ \\-\\ (?P<epno>[0-9]+).*$''',
                re.UNICODE),
            # Series 1 - Warriors of Kudlak - Part 2
            re.compile(
                u'''^.+?Series\\ (?P<seasno>[0-9]+).*.+?Part\\ (?P<epno>[0-9]+).*$''',
                re.UNICODE),
            # Series 3: Programme 3
            re.compile(
                u'''^.+?Series\\ (?P<seasno>[0-9]+)\\:\\ Programme\\ (?P<epno>[0-9]+).*$''',
                re.UNICODE),
            # Series 3:
            re.compile(u'''^.+?Series\\ (?P<seasno>[0-9]+).*$''', re.UNICODE),
            # Episode 1
            re.compile(u'''^.+?Episode\\ (?P<seasno>[0-9]+).*$''', re.UNICODE),
        ]

        self.channel_icon = u'%SHAREDIR%/mythnetvision/icons/bbciplayer.jpg'

        self.config[u'image_extentions'] = ["png", "jpg", "bmp"
                                            ]  # Acceptable image extentions
コード例 #15
0
ファイル: bliptv_api.py プロジェクト: rcrdnalor/mythtv
    def __init__(
        self,
        apikey,
        mythtv=True,
        interactive=False,
        select_first=False,
        debug=False,
        custom_ui=None,
        language=None,
        search_all_languages=False,
    ):
        """apikey (str/unicode):
            Specify the target site API key. Applications need their own key in some cases

        mythtv (True/False):
            When True, the returned meta data is being returned has the key and values massaged to match MythTV
            When False, the returned meta data  is being returned matches what target site returned

        interactive (True/False): (This option is not supported by all target site apis)
            When True, uses built-in console UI is used to select the correct show.
            When False, the first search result is used.

        select_first (True/False): (This option is not supported currently implemented in any grabbers)
            Automatically selects the first series search result (rather
            than showing the user a list of more than one series).
            Is overridden by interactive = False, or specifying a custom_ui

        debug (True/False):
             shows verbose debugging information

        custom_ui (xx_ui.BaseUI subclass): (This option is not supported currently implemented in any grabbers)
            A callable subclass of interactive class (overrides interactive option)

        language (2 character language abbreviation): (This option is not supported by all target site apis)
            The language of the returned data. Is also the language search
            uses. Default is "en" (English). For full list, run..

        search_all_languages (True/False): (This option is not supported by all target site apis)
            By default, a Netvision grabber will only search in the language specified using
            the language option. When this is True, it will search for the
            show in any language

        """
        self.config = {}
        self.mythxml = MythXML()

        if apikey is not None:
            self.config['apikey'] = apikey
        else:
            pass  # blip.tv does not require an apikey

        self.config['debug_enabled'] = debug  # show debugging messages

        self.log_name = "Bliptv"
        self.log = self._initLogger(
        )  # Setups the logger (self.log.debug() etc)

        self.config['custom_ui'] = custom_ui

        self.config['interactive'] = interactive  # prompt for correct series?

        self.config['select_first'] = select_first

        self.config['search_all_languages'] = search_all_languages

        # Defaulting to ENGISH but the blip.tv apis do not support specifying a language
        self.config['language'] = "en"

        self.error_messages = {
            'BliptvUrlError':
            "! Error: The URL (%s) cause the exception error (%s)\n",
            'BliptvHttpError':
            "! Error: An HTTP communicating error with blip.tv was raised (%s)\n",
            'BliptvRssError':
            "! Error: Invalid RSS meta data\nwas received from blip.tv error (%s). Skipping item.\n",
            'BliptvVideoNotFound':
            "! Error: Video search with blip.tv did not return any results (%s)\n",
        }

        # This is an example that must be customized for each target site
        self.key_translation = [{
            'channel_title': 'channel_title',
            'channel_link': 'channel_link',
            'channel_description': 'channel_description',
            'channel_numresults': 'channel_numresults',
            'channel_returned': 'channel_returned',
            'channel_startindex': 'channel_startindex'
        }, {
            'title': 'item_title',
            'blip_safeusername': '******',
            'updated': 'item_pubdate',
            'blip_puredescription': 'item_description',
            'link': 'item_link',
            'blip_picture': 'item_thumbnail',
            'video': 'item_url',
            'blip_runtime': 'item_duration',
            'blip_rating': 'item_rating',
            'width': 'item_width',
            'height': 'item_height',
            'language': 'item_lang'
        }]

        # The following url_ configs are based of the
        # http://blip.tv/about/api/
        self.config['base_url'] = "http://www.blip.tv%s"
        self.config['thumb_url'] = "http://a.images.blip.tv%s"

        self.config['urls'] = {}

        # v2 api calls - An example that must be customized for each target site
        self.config['urls'][
            'video.search'] = "http://www.blip.tv/?search=%s;&page=%s;&pagelen=%s;&language_code=%s;&skin=rss"
        self.config['urls'][
            'categories'] = "http://www.blip.tv/?section=categories&cmd=view&skin=api"

        self.config['image_extentions'] = ["png", "jpg", "bmp"
                                           ]  # Acceptable image extentions

        # Functions that parse video data from RSS data
        self.config['item_parser'] = {}
        self.config['item_parser']['main'] = self.getVideosForURL

        # Tree view url and the function that parses that urls meta data
        self.config['urls']['tree.view'] = {
            'P_R_R_F': {
                '__all__': ['http://www.blip.tv/%s/?skin=rss', 'main'],
            },
            'categories': {
                '__all__': ['http://www.blip.tv/rss/', 'main'],
            },
        }

        # Tree view categories are disabled until their results can be made more meaningful
        #self.tree_order = ['P_R_R_F', 'categories', ]
        self.tree_order = ['P_R_R_F']

        self.tree_org = {
            #            'P_R_R_F': [['Popular/Recent/Features/Random ...', ['popular', 'recent', 'random', 'featured',]],
            'P_R_R_F': [
                ['', [
                    'popular',
                    'recent',
                    'random',
                    'featured',
                ]],
            ],
            # categories are dynamically filled in from a list retrieved from the blip.tv site
            'categories': [
                ['Categories', ''],
            ],
        }

        self.tree_customize = {
            'P_R_R_F': {
                '__default__': {},
                #'cat name': {},
            },
            'categories': {
                '__default__': {
                    'categories_id': '',
                    'sort': '',
                },
                #'cat name': {},
            },
        }

        self.feed_names = {
            'P_R_R_F': {
                'popular': 'Most Comments',
                'recent': 'Most Recent',
                'random': 'Random selection',
            },
            'categories': {
                'featured': 'Featured Videos',
                'popular': 'Most Comments',
                'recent': 'Most Recent',
                'random': 'Random selection',
            },
        }

        self.feed_icons = {
            'P_R_R_F': {
                'popular': 'directories/topics/most_comments',
                'recent': 'directories/topics/most_recent',
                'random': 'directories/topics/random',
            },
            'categories': {
                'featured': 'directories/topics/featured',
                'popular': 'directories/topics/most_comments',
                'recent': 'directories/topics/most_recent',
                'random': 'directories/topics/random',
            },
        }

        # Initialize the tree view flag so that the item parsing code can be used for multiple purposes
        self.categories = False
        self.treeview = False
        self.channel_icon = '%SHAREDIR%/mythnetvision/icons/bliptv.png'
コード例 #16
0
 def test_Methodheap_MythXML_001_03(self):
     """Test MythXML.getSetting()."""
     m_instance = MythXML()
     port = m_instance.getSetting('BackendServerPort', default='1111')
     self.assertTrue(int(port), 6543)
コード例 #17
0
 def test_Methodheap_MythXML_001_02(self):
     """Test MythXML.getKeys()."""
     m_instance = MythXML()
     keys_list = m_instance.getKeys()
     self.assertTrue(u'MenuTheme' in keys_list)
コード例 #18
0
    def __init__(self,
                apikey,
                mythtv = True,
                interactive = False,
                select_first = False,
                debug = False,
                custom_ui = None,
                language = None,
                search_all_languages = False,
                ):
        """apikey (str/unicode):
            Specify the target site API key. Applications need their own key in some cases

        mythtv (True/False):
            When True, the returned meta data is being returned has the key and values massaged to match MythTV
            When False, the returned meta data  is being returned matches what target site returned

        interactive (True/False): (This option is not supported by all target site apis)
            When True, uses built-in console UI is used to select the correct show.
            When False, the first search result is used.

        select_first (True/False): (This option is not supported currently implemented in any grabbers)
            Automatically selects the first series search result (rather
            than showing the user a list of more than one series).
            Is overridden by interactive = False, or specifying a custom_ui

        debug (True/False):
             shows verbose debugging information

        custom_ui (xx_ui.BaseUI subclass): (This option is not supported currently implemented in any grabbers)
            A callable subclass of interactive class (overrides interactive option)

        language (2 character language abbreviation): (This option is not supported by all target site apis)
            The language of the returned data. Is also the language search
            uses. Default is "en" (English). For full list, run..

        search_all_languages (True/False): (This option is not supported by all target site apis)
            By default, a Netvision grabber will only search in the language specified using
            the language option. When this is True, it will search for the
            show in any language

        """
        self.config = {}
        self.mythxml = MythXML()

        if apikey is not None:
            self.config['apikey'] = apikey
        else:
            pass    # YouTube does not require an apikey

        self.config['debug_enabled'] = debug # show debugging messages

        self.log_name = "youtube"
        self.log = self._initLogger() # Setups the logger (self.log.debug() etc)

        self.config['custom_ui'] = custom_ui

        self.config['interactive'] = interactive # prompt for correct series?

        self.config['select_first'] = select_first

        self.config['search_all_languages'] = search_all_languages

        self.error_messages = {'YouTubeUrlError': u"! Error: The URL (%s) cause the exception error (%s)\n", 'YouTubeHttpError': u"! Error: An HTTP communications error with YouTube was raised (%s)\n", 'YouTubeRssError': u"! Error: Invalid RSS meta data\nwas received from YouTube error (%s). Skipping item.\n", 'YouTubeVideoNotFound': u"! Error: Video search with YouTube did not return any results (%s)\n", 'YouTubeVideoDetailError': u"! Error: Invalid Video meta data detail\nwas received from YouTube error (%s). Skipping item.\n", }

        # This is an example that must be customized for each target site
        self.key_translation = [{'channel_title': 'channel_title', 'channel_link': 'channel_link', 'channel_description': 'channel_description', 'channel_numresults': 'channel_numresults', 'channel_returned': 'channel_returned', 'channel_startindex': 'channel_startindex'}, {'title': 'item_title', 'author': 'item_author', 'published_parsed': 'item_pubdate', 'media_description': 'item_description', 'video': 'item_link', 'thumbnail': 'item_thumbnail', 'link': 'item_url', 'duration': 'item_duration', 'rating': 'item_rating', 'item_width': 'item_width', 'item_height': 'item_height', 'language': 'item_lang'}]

        # Defaulting to no language specified. The YouTube apis does support specifying a language
        if language:
            self.config['language'] = language
        else:
            self.config['language'] = u''

        self.config[u'urls'] = {}

        # v2 api calls - An example that must be customized for each target site
        self.config[u'urls'][u'video.search'] = 'http://gdata.youtube.com/feeds/api/videos?vq=%s&max-results=%s&start-index=%s&orderby=relevance&Ir=%s'


        # Functions that parse video data from RSS data
        self.config['item_parser'] = {}
        self.config['item_parser']['main'] = self.getVideosForURL

        # Tree view url and the function that parses that urls meta data
        self.config[u'urls'][u'tree.view'] = {
            'standard_feeds': {
                '__all__': ['http://gdata.youtube.com/feeds/api/standardfeeds/%s?v=2', 'main'],
                },
            'category': {
                '__all__': ['http://gdata.youtube.com/feeds/api/videos?category=%s&v=2', 'main'],
                },
            'local_feeds': {
                '__all__': ['http://gdata.youtube.com/feeds/api/standardfeeds/%s?v=2', 'main'],
                },
            'location_feeds': {
                '__all__': ['http://gdata.youtube.com/feeds/api/videos?v=2&q=%s', 'main'],
                },
            }
        self.config[u'urls'][u'categories_list'] = 'http://gdata.youtube.com/schemas/2007/categories.cat'

        self.config[u'image_extentions'] = ["png", "jpg", "bmp"] # Acceptable image extentions

        self.tree_order = ['standard_feeds', 'location_feeds', 'local_feeds', 'category']
        self.tree_org = {
            'category': [
                ['', ['Film']],
                ['', ['Sports']],
                ['Information', ['News', 'Tech', 'Education', 'Howto', ]],
                ['Entertainment', ['Comedy', 'Music', 'Games', 'Entertainment', ]],
                ['Other', ['Autos', 'Animals', 'Travel', 'People', 'Nonprofit']] ],
            'standard_feeds':
                [['Feeds', ['top_rated', 'top_favourites', 'most_viewed', 'most_popular', 'most_recent', 'most_discussed', 'most_responded', 'recently_featured', '']], ],
            'local_feeds':
                [['Feeds', ['top_rated', 'top_favourites', 'most_viewed', 'most_popular', 'most_recent', 'most_discussed', 'most_responded', 'recently_featured', '']], ],
            'location_feeds':
                [['', ['location']], ]
            }

        self.tree_customize = {
            'category': {
                '__default__': {'order': 'rating', 'max-results': '20', 'start-index': '1', 'Ir': self.config['language']},
                #'cat name': {'order: '', 'max-results': , 'start-index': , 'restriction: '', 'time': '', 'Ir': ''},
                'Film': {'max-results': '40', 'time': 'this_month',},
                'Music': {'max-results': '40', 'time': 'this_month',},
                'Sports': {'max-results': '40', 'time': 'this_month',},
            },
            'standard_feeds': {
                '__default__': {'order': 'rating', 'max-results': '20', 'start-index': '1', 'Ir': self.config['language'], 'time': 'this_month'},
                #'feed name": {'order: '', 'max-results': , 'start-index': , 'restriction: '', 'time': '', 'Ir': ''}
            },
            'local_feeds': {
                '__default__': {'order': 'rating', 'max-results': '20', 'start-index': '1', 'Ir': self.config['language'], 'location': '', 'location-radius':'500km'},
                #'feed name": {'order: '', 'max-results': , 'start-index': , 'restriction: '', 'time': '', 'Ir': ''}
            },
            'location_feeds': {
                '__default__': {'order': 'rating', 'max-results': '20', 'start-index': '1', 'Ir': self.config['language'], },
                #'feed name": {'order: '', 'max-results': , 'start-index': , 'restriction: '', 'time': '', 'Ir': ''}
            },
            }

        self.feed_names = {
            'standard_feeds': {'top_rated': 'Highest Rated', 'top_favourites': 'Most Subscribed', 'most_viewed': 'Most Viewed', 'most_popular': 'Most Popular', 'most_recent': 'Most Recent', 'most_discussed': 'Most Comments', 'most_responded': 'Most Responses', 'recently_featured': 'Featured'}
            }

        self.feed_icons = {
            'standard_feeds': {'top_rated': 'directories/topics/rated', 'top_favourites': 'directories/topics/most_subscribed', 'most_viewed': 'directories/topics/most_viewed', 'most_popular': None, 'most_recent': 'directories/topics/most_recent', 'most_discussed': 'directories/topics/most_comments', 'most_responded': None, 'recently_featured': 'directories/topics/featured'
                },
            'local_feeds': {'top_rated': 'directories/topics/rated', 'top_favourites': 'directories/topics/most_subscribed', 'most_viewed': 'directories/topics/most_viewed', 'most_popular': None, 'most_recent': 'directories/topics/most_recent', 'most_discussed': 'directories/topics/most_comments', 'most_responded': None, 'recently_featured': 'directories/topics/featured'
                },
            'category': {
                'Film': 'directories/topics/movies',
                'Comedy': 'directories/film_genres/comedy',
                'Sports': 'directories/topics/sports',
                'News': 'directories/topics/news', 'Tech': 'directories/topics/technology', 'Education': 'directories/topics/education', 'Howto': 'directories/topics/howto',
                'Music': 'directories/topics/music', 'Games': 'directories/topics/games', 'Entertainment': 'directories/topics/entertainment',
                'Autos': 'directories/topics/automotive', 'Animals': 'directories/topics/animals', 'Travel': 'directories/topics/travel', 'People': 'directories/topics/people', 'Nonprofit': 'directories/topics/nonprofit',
                },
            }

        self.treeview = False
        self.channel_icon = u'%SHAREDIR%/mythnetvision/icons/youtube.png'
コード例 #19
0
ファイル: youtube_api.py プロジェクト: martyg77/mythtv
    def __init__(
        self,
        apikey,
        mythtv=True,
        interactive=False,
        select_first=False,
        debug=False,
        custom_ui=None,
        language=None,
        search_all_languages=False,
    ):
        """apikey (str/unicode):
            Specify the target site API key. Applications need their own key in some cases

        mythtv (True/False):
            When True, the returned meta data is being returned has the key and values massaged to match MythTV
            When False, the returned meta data  is being returned matches what target site returned

        interactive (True/False): (This option is not supported by all target site apis)
            When True, uses built-in console UI is used to select the correct show.
            When False, the first search result is used.

        select_first (True/False): (This option is not supported currently implemented in any grabbers)
            Automatically selects the first series search result (rather
            than showing the user a list of more than one series).
            Is overridden by interactive = False, or specifying a custom_ui

        debug (True/False):
             shows verbose debugging information

        custom_ui (xx_ui.BaseUI subclass): (This option is not supported currently implemented in any grabbers)
            A callable subclass of interactive class (overrides interactive option)

        language (2 character language abbreviation): (This option is not supported by all target site apis)
            The language of the returned data. Is also the language search
            uses. Default is "en" (English). For full list, run..

        search_all_languages (True/False): (This option is not supported by all target site apis)
            By default, a Netvision grabber will only search in the language specified using
            the language option. When this is True, it will search for the
            show in any language

        """
        self.config = {}
        self.common = common_api.Common()
        self.mythxml = MythXML()

        self.config['debug_enabled'] = debug  # show debugging messages

        self.log_name = "youtube"
        self.log = self._initLogger(
        )  # Setups the logger (self.log.debug() etc)

        self.config['custom_ui'] = custom_ui

        self.config['interactive'] = interactive  # prompt for correct series?

        self.config['select_first'] = select_first

        self.config['search_all_languages'] = search_all_languages

        self.error_messages = \
                {'YouTubeUrlError': u"! Error: The URL (%s) cause the exception error (%s)\n",
                'YouTubeHttpError': u"! Error: An HTTP communications error with YouTube was raised (%s)\n",
                'YouTubeRssError': u"! Error: Invalid RSS meta data\nwas received from YouTube error (%s). Skipping item.\n",
                'YouTubeVideoNotFound': u"! Error: Video search with YouTube did not return any results (%s)\n",
                'YouTubeVideoDetailError': u"! Error: Invalid Video meta data detail\nwas received from YouTube error (%s). Skipping item.\n", }

        # This is an example that must be customized for each target site
        self.key_translation = \
                [{'channel_title': 'channel_title',
                    'channel_link': 'channel_link',
                    'channel_description': 'channel_description',
                    'channel_numresults': 'channel_numresults',
                    'channel_returned': 'channel_returned',
                    'channel_startindex': 'channel_startindex'},
                 {'title': 'item_title',
                    'author': 'item_author',
                    'published_parsed': 'item_pubdate',
                    'media_description': 'item_description',
                    'video': 'item_link',
                    'thumbnail': 'item_thumbnail',
                    'link': 'item_url',
                    'duration': 'item_duration',
                    'rating': 'item_rating',
                    'item_width': 'item_width',
                    'item_height': 'item_height',
                    'language': 'item_lang'}]

        # Defaulting to no language specified. The YouTube apis does support specifying a language
        if language:
            self.config['language'] = language
        else:
            self.config['language'] = u''

        self.getUserPreferences(
            "~/.mythtv/MythNetvision/userGrabberPrefs/youtube.xml")

        # Read region code from user preferences, used by tree view
        region = self.userPrefs.find("region")
        if region is not None and region.text:
            self.config['region'] = region.text
        else:
            self.config['region'] = u'us'

        self.apikey = getData().update(getData().a)

        apikey = self.userPrefs.find("apikey")
        if apikey is not None and apikey.text:
            self.apikey = apikey.text

        self.feed_icons = {
            'Film & Animation': 'directories/topics/movies',
            'Movies': 'directories/topics/movies',
            'Trailers': 'directories/topics/movies',
            'Sports': 'directories/topics/sports',
            'News & Politics': 'directories/topics/news',
            'Science & Technology': 'directories/topics/technology',
            'Education': 'directories/topics/education',
            'Howto & Style': 'directories/topics/howto',
            'Music': 'directories/topics/music',
            'Gaming': 'directories/topics/games',
            'Entertainment': 'directories/topics/entertainment',
            'Autos & Vehicles': 'directories/topics/automotive',
            'Pets & Animals': 'directories/topics/animals',
            'Travel & Events': 'directories/topics/travel',
            'People & Blogs': 'directories/topics/people',
        }

        self.treeview = False
        self.channel_icon = u'%SHAREDIR%/mythnetvision/icons/youtube.png'
コード例 #20
0
 def test_Methodheap_MythXML_001_08(self):
     """Test MythXML.getExpiring()."""
     m_instance = MythXML()
     rec_list = m_instance.getExpiring()
     rec = next(rec_list)
     self.assertTrue(len(rec.title) > 0)