예제 #1
0
    def delete(self):

        if (self.playlist.name == CONST.DEFAULT_AUDIO_PLAYLIST
                or self.playlist.name == CONST.DEFAULT_VIDEO_PLAYLIST):

            os.remove(
                Utils.createPath(os.path.basename(self.link_to_play),
                                 self.playlist.user))

            if self.link_to_play != self.link_to_load:
                os.remove(
                    Utils.createPath(os.path.basename(self.link_to_load),
                                     self.playlist.user))

        super(Media, self).delete()
예제 #2
0
    def delete(self):

        if (self.playlist.name == CONST.DEFAULT_AUDIO_PLAYLIST 
            or self.playlist.name == CONST.DEFAULT_VIDEO_PLAYLIST):

            os.remove(Utils.createPath(
                os.path.basename(self.link_to_play), 
                self.playlist.user))

            if self.link_to_play != self.link_to_load:
                os.remove(Utils.createPath(
                    os.path.basename(self.link_to_load), 
                    self.playlist.user))
        
        super(Media, self).delete()
예제 #3
0
def audio(request, playlistName, media, mediatype):
    
    response = HttpResponse(mimetype=mediatype)
    response['Content-Disposition'] = 'attachment; filename=%s' % smart_str(media)
    response['Accept-Ranges'] = 'bytes'
    path = Utils.createPath(os.path.basename(media), request.user)
    response['X-Sendfile'] = smart_str(path)

    return response
예제 #4
0
def audio(request, playlistName, media, mediatype):

    response = HttpResponse(mimetype=mediatype)
    response['Content-Disposition'] = 'attachment; filename=%s' % smart_str(
        media)
    response['Accept-Ranges'] = 'bytes'
    path = Utils.createPath(os.path.basename(media), request.user)
    response['X-Sendfile'] = smart_str(path)

    return response
예제 #5
0
    def download(self, call=None):

        myfilename = Utils.uniquify(self.path + CONST.DEFAULT_MEDIA_NAME +
                                    '.' + CONST.VIDEO_TO_PLAY_EXTENSION)

        myfilename = Utils.createPath(myfilename, self.user)
        print "Path for downloading: " + myfilename

        ydl = youtube_dl.YoutubeDL({
            'outtmpl': myfilename,
            'format': CONST.VIDEO_TO_PLAY_EXTENSION
        })
        # Add all the available extractors
        ydl.add_default_info_extractors()

        ydl.extract_info(self.link, download=True, callback=call)

        return Utils.createLink(os.path.basename(myfilename), self.user)
예제 #6
0
    def download(self, call=None):

        myfilename = Utils.uniquify(
            self.path + 
            CONST.DEFAULT_MEDIA_NAME + 
            '.' + CONST.VIDEO_TO_PLAY_EXTENSION)

        myfilename = Utils.createPath(myfilename, self.user)
        print "Path for downloading: " + myfilename

        ydl = youtube_dl.YoutubeDL({
            'outtmpl': myfilename,
            'format': CONST.VIDEO_TO_PLAY_EXTENSION})
        # Add all the available extractors
        ydl.add_default_info_extractors()

        ydl.extract_info(self.link, download=True, callback=call)

        return Utils.createLink(os.path.basename(myfilename), self.user)
예제 #7
0
def convert(path, current_user, extension=None):
    "Convert video file to audio"
    print 'converting...'

    current_task.update_state(state='PROGRESS')
    is_audio = True

    if extension == None:

        filename_to_play = Converter(current_user).convert(path, 
            CONST.AUDIO_TO_PLAY_EXTENSION)
        print filename_to_play + " converted"
        filename_to_load = Converter(current_user).convert(path, 
            CONST.AUDIO_TO_LOAD_EXTENSION)
        print filename_to_load + " converted"
        
        os.remove(Utils.createPath(
                    os.path.basename(path), 
                    current_user))
        
    elif extension == CONST.VIDEO_TO_LOAD_EXTENSION:

        is_audio = False
        filename_to_play = path
        filename_to_load = Converter(current_user).convert(path, extension)
        print filename_to_load + " converted"

    playlist_field = create_default_playlist(current_user, is_audio)

    if filename_to_play != None:
        medianame = os.path.basename(Utils.getName(filename_to_play))

        Media.objects.create_media(playlist=playlist_field, 
            name = medianame, 
            link_to_play=filename_to_play, 
            link_to_load=filename_to_load)
        
    return filename_to_play
예제 #8
0
def convert(path, current_user, extension=None):
    "Convert video file to audio"
    print 'converting...'

    current_task.update_state(state='PROGRESS')
    is_audio = True

    if extension == None:

        filename_to_play = Converter(current_user).convert(
            path, CONST.AUDIO_TO_PLAY_EXTENSION)
        print filename_to_play + " converted"
        filename_to_load = Converter(current_user).convert(
            path, CONST.AUDIO_TO_LOAD_EXTENSION)
        print filename_to_load + " converted"

        os.remove(Utils.createPath(os.path.basename(path), current_user))

    elif extension == CONST.VIDEO_TO_LOAD_EXTENSION:

        is_audio = False
        filename_to_play = path
        filename_to_load = Converter(current_user).convert(path, extension)
        print filename_to_load + " converted"

    playlist_field = create_default_playlist(current_user, is_audio)

    if filename_to_play != None:
        medianame = os.path.basename(Utils.getName(filename_to_play))

        Media.objects.create_media(playlist=playlist_field,
                                   name=medianame,
                                   link_to_play=filename_to_play,
                                   link_to_load=filename_to_load)

    return filename_to_play
예제 #9
0
 def __init__(self, link, user):
     self.link = link
     self.user = user
     self.path = Utils.createPath('', user)
예제 #10
0
 def __init__(self, link, user):
     self.link = link
     self.user = user
     self.path = Utils.createPath('', user)