예제 #1
0
    def test_load_remote_m3u8(self, m):

        mocked_path = 'http://example.com/playlist.m3u8'
        m.get(mocked_path, text=self.sample_m3u8)

        load_remote_m3u8(mocked_path, self.playlist, remove_existed=True)

        self.assertEqual(self.playlist.count, 2)
예제 #2
0
파일: views.py 프로젝트: joe513/m3u8
    def form_valid(self, form):
        playlist, created = Playlist.objects.get_or_create(
            user=self.request.user)
        if form.cleaned_data['url']:
            load_remote_m3u8(
                form.cleaned_data['url'],
                playlist,
                remove_existed=form.cleaned_data['remove_existed'])
        elif form.cleaned_data['file']:
            load_m3u8_from_file(
                form.cleaned_data['file'],
                playlist,
                remove_existed=form.cleaned_data['remove_existed'])

        return super(CreatePlaylist, self).form_valid(form)
예제 #3
0
    def form_valid(self, form):
        playlist = Playlist.objects.filter(user=self.request.user).first()
        if not playlist:
            playlist = Playlist.objects.create(user=self.request.user)

        form.instance.user = self.request.user

        if form.cleaned_data['url']:
            load_remote_m3u8(
                form.cleaned_data['url'],
                playlist,
                remove_existed=form.cleaned_data['remove_existed'])
        elif form.cleaned_data['file']:
            load_m3u8_from_file(
                form.cleaned_data['file'],
                playlist,
                remove_existed=form.cleaned_data['remove_existed'])

        return super(CreatePlaylist, self).form_valid(form)