当前位置: 首页>>代码示例>>Python>>正文


Python media_helper.MediaParser类代码示例

本文整理汇总了Python中helpers.media_helper.MediaParser的典型用法代码示例。如果您正苦于以下问题:Python MediaParser类的具体用法?Python MediaParser怎么用?Python MediaParser使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了MediaParser类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_youtube_parse

    def test_youtube_parse(self):
        yt_long = MediaParser.partial_media_dict_from_url("http://www.youtube.com/watch?v=I-IrVbsl_K8")
        self.assertEqual(yt_long["media_type_enum"], MediaType.YOUTUBE)
        self.assertEqual(yt_long["foreign_key"], "I-IrVbsl_K8")

        yt_short = MediaParser.partial_media_dict_from_url("http://youtu.be/I-IrVbsl_K8")
        self.assertEqual(yt_short["media_type_enum"], MediaType.YOUTUBE)
        self.assertEqual(yt_short["foreign_key"], "I-IrVbsl_K8")
开发者ID:samuelcouch,项目名称:the-blue-alliance,代码行数:8,代码来源:test_media_url_parse.py

示例2: test_imgur_parse

    def test_imgur_parse(self):
        imgur_img = MediaParser.partial_media_dict_from_url("http://imgur.com/zYqWbBh")
        self.assertEqual(imgur_img['media_type_enum'], MediaType.IMGUR)
        self.assertEqual(imgur_img['foreign_key'], "zYqWbBh")

        imgur_img = MediaParser.partial_media_dict_from_url("http://i.imgur.com/zYqWbBh.png")
        self.assertEqual(imgur_img['media_type_enum'], MediaType.IMGUR)
        self.assertEqual(imgur_img['foreign_key'], "zYqWbBh")

        self.assertEqual(MediaParser.partial_media_dict_from_url("http://imgur.com/r/aww"), None)
        self.assertEqual(MediaParser.partial_media_dict_from_url("http://imgur.com/a/album"), None)
开发者ID:MC42,项目名称:the-blue-alliance,代码行数:11,代码来源:test_media_url_parse.py

示例3: test_youtube_parse

    def test_youtube_parse(self):
        yt_long = MediaParser.partial_media_dict_from_url("http://www.youtube.com/watch?v=I-IrVbsl_K8")
        self.assertEqual(yt_long['media_type_enum'], MediaType.YOUTUBE_VIDEO)
        self.assertEqual(yt_long['foreign_key'], "I-IrVbsl_K8")

        yt_short = MediaParser.partial_media_dict_from_url("http://youtu.be/I-IrVbsl_K8")
        self.assertEqual(yt_short['media_type_enum'], MediaType.YOUTUBE_VIDEO)
        self.assertEqual(yt_short['foreign_key'], "I-IrVbsl_K8")

        yt_from_playlist = MediaParser.partial_media_dict_from_url("https://www.youtube.com/watch?v=VP992UKFbko&index=1&list=PLZT9pIgNOV6ZE0EgstWeoRWGWT3uoaszm")
        self.assertEqual(yt_from_playlist['media_type_enum'], MediaType.YOUTUBE_VIDEO)
        self.assertEqual(yt_from_playlist['foreign_key'], 'VP992UKFbko')
开发者ID:MC42,项目名称:the-blue-alliance,代码行数:12,代码来源:test_media_url_parse.py

示例4: test_youtube_profile_parse

    def test_youtube_profile_parse(self):
        result = MediaParser.partial_media_dict_from_url("https://www.youtube.com/user/Uberbots1124")
        self.assertEqual(result['media_type_enum'], MediaType.YOUTUBE_CHANNEL)
        self.assertEqual(result['is_social'], True)
        self.assertEqual(result['foreign_key'], 'uberbots1124')
        self.assertEqual(result['site_name'], MediaType.type_names[MediaType.YOUTUBE_CHANNEL])
        self.assertEqual(result['profile_url'], 'https://www.youtube.com/user/uberbots1124')

        short_result = MediaParser.partial_media_dict_from_url("https://www.youtube.com/Uberbots1124")
        self.assertEqual(short_result['media_type_enum'], MediaType.YOUTUBE_CHANNEL)
        self.assertEqual(short_result['is_social'], True)
        self.assertEqual(short_result['foreign_key'], 'uberbots1124')
        self.assertEqual(short_result['site_name'], MediaType.type_names[MediaType.YOUTUBE_CHANNEL])
        self.assertEqual(short_result['profile_url'], 'https://www.youtube.com/user/uberbots1124')
开发者ID:scottrpp,项目名称:the-blue-alliance,代码行数:14,代码来源:test_media_url_parse.py

示例5: createTeamMediaSuggestion

    def createTeamMediaSuggestion(cls, author_account_key, media_url, team_key, year_str):
        """Create a Team Media Suggestion. Returns status (success, exists, bad_url)"""

        media_dict = MediaParser.partial_media_dict_from_url(media_url)
        if media_dict is not None:
            existing_media = Media.get_by_id(Media.render_key_name(media_dict['media_type_enum'], media_dict['foreign_key']))
            if existing_media is None or team_key not in [reference.id() for reference in existing_media.references]:
                foreign_type = Media.SLUG_NAMES[media_dict['media_type_enum']]
                suggestion_id = Suggestion.render_key_name(year_str, 'team', team_key, foreign_type, media_dict['foreign_key'])
                suggestion = Suggestion.get_by_id(suggestion_id)
                if not suggestion or suggestion.review_state != Suggestion.REVIEW_PENDING:
                    media_dict['year'] = int(year_str)
                    media_dict['reference_type'] = 'team'
                    media_dict['reference_key'] = team_key

                    suggestion = Suggestion(
                        id=suggestion_id,
                        author=author_account_key,
                        target_model="media",
                        )
                    suggestion.contents = media_dict
                    suggestion.put()
                    return 'success'
                else:
                    return 'suggestion_exists'
            else:
                return 'media_exists'
        else:
            return 'bad_url'
开发者ID:csteward24,项目名称:the-blue-alliance,代码行数:29,代码来源:suggestion_creator.py

示例6: test_snapchat_profile_parse

 def test_snapchat_profile_parse(self):
     result = MediaParser.partial_media_dict_from_url("https://www.snapchat.com/add/evolution2626")
     self.assertEqual(result['media_type_enum'], MediaType.SNAPCHAT_PROFILE)
     self.assertEqual(result['is_social'], True)
     self.assertEqual(result['foreign_key'], 'evolution2626')
     self.assertEqual(result['site_name'], MediaType.type_names[MediaType.SNAPCHAT_PROFILE])
     self.assertEqual(result['profile_url'], 'https://www.snapchat.com/add/evolution2626')
开发者ID:technonerdz,项目名称:the-blue-alliance,代码行数:7,代码来源:test_media_url_parse.py

示例7: test_twitter_profile_parse

 def test_twitter_profile_parse(self):
     result = MediaParser.partial_media_dict_from_url("https://twitter.com/team1124")
     self.assertEqual(result['media_type_enum'], MediaType.TWITTER_PROFILE)
     self.assertEqual(result['is_social'], True)
     self.assertEqual(result['foreign_key'], 'team1124')
     self.assertEqual(result['site_name'], MediaType.type_names[MediaType.TWITTER_PROFILE])
     self.assertEqual(result['profile_url'], 'https://twitter.com/team1124')
开发者ID:MC42,项目名称:the-blue-alliance,代码行数:7,代码来源:test_media_url_parse.py

示例8: test_github_profile_parse

 def test_github_profile_parse(self):
     result = MediaParser.partial_media_dict_from_url("https://github.com/frc1124")
     self.assertEqual(result['media_type_enum'], MediaType.GITHUB_PROFILE)
     self.assertEqual(result['is_social'], True)
     self.assertEqual(result['foreign_key'], 'frc1124')
     self.assertEqual(result['site_name'], MediaType.type_names[MediaType.GITHUB_PROFILE])
     self.assertEqual(result['profile_url'], 'https://github.com/frc1124')
开发者ID:MC42,项目名称:the-blue-alliance,代码行数:7,代码来源:test_media_url_parse.py

示例9: createEventMediaSuggestion

    def createEventMediaSuggestion(cls, author_account_key, media_url, event_key, private_details_json=None):
        """Create an Event Media Suggestion. Returns status (success, suggestion_exists, media_exists, bad_url)"""

        media_dict = MediaParser.partial_media_dict_from_url(media_url)
        if media_dict is not None:
            if media_dict['media_type_enum'] != MediaType.YOUTUBE_VIDEO:
                return 'bad_url', None

            existing_media = Media.get_by_id(Media.render_key_name(media_dict['media_type_enum'], media_dict['foreign_key']))
            if existing_media is None or event_key not in [reference.id() for reference in existing_media.references]:
                foreign_type = Media.SLUG_NAMES[media_dict['media_type_enum']]
                suggestion_id = Suggestion.render_media_key_name(event_key[:4], 'event', event_key, foreign_type, media_dict['foreign_key'])
                suggestion = Suggestion.get_by_id(suggestion_id)
                if not suggestion or suggestion.review_state != Suggestion.REVIEW_PENDING:
                    media_dict['year'] = event_key[:4]
                    media_dict['reference_type'] = 'event'
                    media_dict['reference_key'] = event_key
                    target_model = 'event_media'
                    if private_details_json is not None:
                        media_dict['private_details_json'] = private_details_json

                    suggestion = Suggestion(
                        id=suggestion_id,
                        author=author_account_key,
                        target_model=target_model,
                        )
                    suggestion.contents = media_dict
                    suggestion.put()
                    return 'success', suggestion
                else:
                    return 'suggestion_exists', None
            else:
                return 'media_exists', None
        else:
            return 'bad_url', None
开发者ID:MC42,项目名称:the-blue-alliance,代码行数:35,代码来源:suggestion_creator.py

示例10: test_fb_profile_parse

 def test_fb_profile_parse(self):
     result = MediaParser.partial_media_dict_from_url("http://facebook.com/theuberbots")
     self.assertEqual(result['media_type_enum'], MediaType.FACEBOOK_PROFILE)
     self.assertEqual(result['is_social'], True)
     self.assertEqual(result['foreign_key'], 'theuberbots')
     self.assertEqual(result['site_name'], MediaType.type_names[MediaType.FACEBOOK_PROFILE])
     self.assertEqual(result['profile_url'], 'https://www.facebook.com/theuberbots')
开发者ID:MC42,项目名称:the-blue-alliance,代码行数:7,代码来源:test_media_url_parse.py

示例11: test_twitch_profile_parse

 def test_twitch_profile_parse(self):
     result = MediaParser.partial_media_dict_from_url("https://www.twitch.tv/evolution2626")
     self.assertEqual(result['media_type_enum'], MediaType.TWITCH_CHANNEL)
     self.assertEqual(result['is_social'], True)
     self.assertEqual(result['foreign_key'], 'evolution2626')
     self.assertEqual(result['site_name'], MediaType.type_names[MediaType.TWITCH_CHANNEL])
     self.assertEqual(result['profile_url'], 'https://www.twitch.tv/evolution2626')
开发者ID:technonerdz,项目名称:the-blue-alliance,代码行数:7,代码来源:test_media_url_parse.py

示例12: test_instagram_profile_parse

 def test_instagram_profile_parse(self):
     result = MediaParser.partial_media_dict_from_url("https://www.instagram.com/4hteamneutrino")
     self.assertEqual(result['media_type_enum'], MediaType.INSTAGRAM_PROFILE)
     self.assertEqual(result['is_social'], True)
     self.assertEqual(result['foreign_key'], '4hteamneutrino')
     self.assertEqual(result['site_name'], MediaType.type_names[MediaType.INSTAGRAM_PROFILE])
     self.assertEqual(result['profile_url'], 'https://www.instagram.com/4hteamneutrino')
开发者ID:MC42,项目名称:the-blue-alliance,代码行数:7,代码来源:test_media_url_parse.py

示例13: test_periscope_profile_parse

 def test_periscope_profile_parse(self):
     result = MediaParser.partial_media_dict_from_url("https://www.periscope.tv/evolution2626")
     self.assertEqual(result['media_type_enum'], MediaType.PERISCOPE_PROFILE)
     self.assertEqual(result['is_social'], True)
     self.assertEqual(result['foreign_key'], 'evolution2626')
     self.assertEqual(result['site_name'], MediaType.type_names[MediaType.PERISCOPE_PROFILE])
     self.assertEqual(result['profile_url'], 'https://www.periscope.tv/evolution2626')
开发者ID:MC42,项目名称:the-blue-alliance,代码行数:7,代码来源:test_media_url_parse.py

示例14: test_cdphotothread_parse

 def test_cdphotothread_parse(self):
     cd = MediaParser.partial_media_dict_from_url("https://www.chiefdelphi.com/media/photos/41999")
     self.assertEqual(cd['media_type_enum'], MediaType.CD_PHOTO_THREAD)
     self.assertEqual(cd['foreign_key'], "41999")
     self.assertTrue(cd['details_json'])
     details = json.loads(cd['details_json'])
     self.assertEqual(details['image_partial'], "a88/a880fa0d65c6b49ddb93323bc7d2e901_l.jpg")
开发者ID:MC42,项目名称:the-blue-alliance,代码行数:7,代码来源:test_media_url_parse.py

示例15: test_instagram_image

 def test_instagram_image(self):
     result = MediaParser.partial_media_dict_from_url("https://www.instagram.com/p/BUnZiriBYre/")
     self.assertEqual(result['media_type_enum'], MediaType.INSTAGRAM_IMAGE)
     self.assertEqual(result['foreign_key'], "BUnZiriBYre")
     details = json.loads(result['details_json'])
     self.assertEqual(details['title'], "FRC 195 @ 2017 Battlecry @ WPI")
     self.assertEqual(details['author_name'], '1stroboticsrocks')
     self.assertIsNotNone(details.get('thumbnail_url', None))
开发者ID:MC42,项目名称:the-blue-alliance,代码行数:8,代码来源:test_media_url_parse.py


注:本文中的helpers.media_helper.MediaParser类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。