示例#1
0
 def test_long_form(self):
     self.assertEqual(
         parse_youtube_video_id(
             'http://www.youtube.com/watch?v=dbh4re56u4&feature=feedu'),
         'dbh4re56u4')
     self.assertEqual(
         parse_youtube_video_id(
             'https://www.youtube.com/watch?v=br56urn6u'), 'br56urn6u')
示例#2
0
def forwards(apps, schema_editor):
    OtherVideo = apps.get_model("arkisto", "OtherVideo")
    for video in OtherVideo.objects.all():
        video_id = parse_youtube_video_id(video.youtube_url)
        if video_id:
            video.youtube_url = 'https://www.youtube.com/v/{}'.format(video_id)
            video.save()
示例#3
0
def forwards(apps, schema_editor):
    OtherVideo = apps.get_model("arkisto", "OtherVideo")
    for video in OtherVideo.objects.all():
        video_id = parse_youtube_video_id(video.youtube_url)
        if video_id:
            video.youtube_url = 'https://www.youtube.com/v/{}'.format(video_id)
            video.save()
def forwards(apps, schema_editor):
    Entry = apps.get_model("kompomaatti", "Entry")
    for entry in Entry.objects.all():
        video_id = parse_youtube_video_id(entry.youtube_url)
        if video_id:
            entry.youtube_url = 'https://www.youtube.com/v/{}'.format(video_id)
            entry.save()
示例#5
0
    def clean_youtube_url(self):
        # Make sure field has content
        if not self.cleaned_data['youtube_url']:
            return self.cleaned_data['youtube_url']

        # Parse video id
        video_id = parse_youtube_video_id(self.cleaned_data['youtube_url'])

        # Warn if something is wrong
        if not video_id:
            raise ValidationError('Osoitteesta ei löytynyt videotunnusta.')

        # Return a new video url
        return 'https://www.youtube.com/v/{}'.format(video_id)
示例#6
0
    def clean_youtube_url(self):
        # Make sure field has content
        if not self.cleaned_data['youtube_url']:
            return self.cleaned_data['youtube_url']

        # Parse video id
        video_id = parse_youtube_video_id(self.cleaned_data['youtube_url'])

        # Warn if something is wrong
        if not video_id:
            raise ValidationError('Osoitteesta ei löytynyt videotunnusta.')

        # Return a new video url
        return 'https://www.youtube.com/v/{}'.format(video_id)
示例#7
0
 def test_long_form(self):
     self.assertEqual(parse_youtube_video_id('http://www.youtube.com/watch?v=dbh4re56u4&feature=feedu'),
                      'dbh4re56u4')
     self.assertEqual(parse_youtube_video_id('https://www.youtube.com/watch?v=br56urn6u'),
                      'br56urn6u')
示例#8
0
 def test_youtu_be(self):
     self.assertEqual(parse_youtube_video_id('http://youtu.be/w34tvwoier8'), 'w34tvwoier8')
示例#9
0
 def test_short_embed_form(self):
     self.assertEqual(parse_youtube_video_id('http://www.youtube.com/v/egv5yber5yre5?version=3&hl=en_US'),
                      'egv5yber5yre5')
示例#10
0
 def test_embed_form(self):
     self.assertEqual(parse_youtube_video_id('http://www.youtube.com/embed/w4v6be547'), 'w4v6be547')
示例#11
0
 def test_youtu_be(self):
     self.assertEqual(parse_youtube_video_id('http://youtu.be/w34tvwoier8'),
                      'w34tvwoier8')
示例#12
0
 def test_short_embed_form(self):
     self.assertEqual(
         parse_youtube_video_id(
             'http://www.youtube.com/v/egv5yber5yre5?version=3&hl=en_US'
         ), 'egv5yber5yre5')
示例#13
0
 def test_embed_form(self):
     self.assertEqual(
         parse_youtube_video_id('http://www.youtube.com/embed/w4v6be547'),
         'w4v6be547')