Exemplo n.º 1
0
    def create_playlist(self, media_type, playlist):
        print "[create_playlist] <%s> playlist['name']: %s\n" % (
            media_type, playlist['name'])

        ncomp = len(playlist['path'])
        last_component = urllib.quote(playlist['path'][ncomp - 1],
                                      ' ()[],@!&%"\'')
        playlist['path'][ncomp - 1] = last_component

        filename = ''
        for component in playlist['path']:
            if filename == '':
                filename = component
            else:
                filename = os.path.join(filename, component)

        print "[create_playlist] full path: %s\n" % filename
        print "[create_playlist] creating m3u object..."
        m = m3u.m3u(filename, media_type)
        print "[create_playlist] saving playlist..."
        result = m.save()

        if result:
            return last_component

        return False
Exemplo n.º 2
0
    def get_playlist_tracks(self, media_type, playlist):
        print "[get_playlist_tracks]  playlist['name']: %s\n" % playlist["name"]

        filename = ""
        for component in playlist["path"]:
            filename = os.path.join(filename, component)

        print "[get_playlist_tracks]  %s\n" % filename
        print "[get_playlist_tracks] creating m3u object..."
        m = m3u.m3u(filename, media_type)
        print "[get_playlist_tracks] getting tracks..."
        tracks = m.get_tracks()

        return tracks
Exemplo n.º 3
0
    def get_playlist_tracks(self, media_type, playlist):
        print "[get_playlist_tracks]  playlist['name']: %s\n" % playlist['name']

        filename = ''
        for component in playlist['path']:
            filename = os.path.join(filename, component)

        print "[get_playlist_tracks]  %s\n" % filename
        print "[get_playlist_tracks] creating m3u object..."
        m = m3u.m3u(filename, media_type)
        print "[get_playlist_tracks] getting tracks..."
        tracks = m.get_tracks()

        return tracks
Exemplo n.º 4
0
    def save_playlist_tracks(self, media_type, playlist, trackids):
        print "[save_playlist_tracks] <%s> playlist['name']: %s\n" % (media_type, playlist["name"])

        filename = ""
        for component in playlist["path"]:
            if filename == "":
                filename = component
            else:
                filename = os.path.join(filename, component)

        print "[save_playlist_tracks] full path: %s\n" % filename
        print "[save_playlist_tracks] creating m3u object..."
        m = m3u.m3u(filename, media_type)
        m.set_tracks(trackids)
        print "[save_playlist_tracks] saving playlist..."
        result = m.save()

        return result
Exemplo n.º 5
0
    def save_playlist_tracks(self, media_type, playlist, trackids):
        print "[save_playlist_tracks] <%s> playlist['name']: %s\n" % (
            media_type, playlist['name'])

        filename = ''
        for component in playlist['path']:
            if filename == '':
                filename = component
            else:
                filename = os.path.join(filename, component)

        print "[save_playlist_tracks] full path: %s\n" % filename
        print "[save_playlist_tracks] creating m3u object..."
        m = m3u.m3u(filename, media_type)
        m.set_tracks(trackids)
        print "[save_playlist_tracks] saving playlist..."
        result = m.save()

        return result
Exemplo n.º 6
0
    def create_playlist(self, media_type, playlist):
        print "[create_playlist] <%s> playlist['name']: %s\n" % (media_type, playlist["name"])

        ncomp = len(playlist["path"])
        last_component = urllib.quote(playlist["path"][ncomp - 1], " ()[],@!&%\"'")
        playlist["path"][ncomp - 1] = last_component

        filename = ""
        for component in playlist["path"]:
            if filename == "":
                filename = component
            else:
                filename = os.path.join(filename, component)

        print "[create_playlist] full path: %s\n" % filename
        print "[create_playlist] creating m3u object..."
        m = m3u.m3u(filename, media_type)
        print "[create_playlist] saving playlist..."
        result = m.save()

        if result:
            return last_component

        return False
Exemplo n.º 7
0
def parse(str):
	parser=m3u(str)
	parser.parse()
	
	return parser.json
Exemplo n.º 8
0
            print(option[0] + " " + option[1] + "%\n")

    if args.album:
        print("Album :\n")
        for option in args.artist:
            print(option[0] + " " + option[1] + "%\n")

    if args.title:
        print("Title :\n")
        for option in args.artist:
            print(option[0] + " " + option[1] + "%\n")

# Call the function on /lib/db.py
allPaths = fetchingPathFromDataBase(args.genre, args.artist, args.album, args.title)

# Creating the variable "trackFile" for the next using
trackFile = ""

# If the file is a m3u format
if args.format == "m3u":
    trackFile = m3u(namePL=fullName, durationPL=args.duration)
# If the file is not m3u format (then a xpsf format)
else:
    trackFile = xspf(namePL=fullName, durationPL=args.duration)

# Giving all paths of tracks found for all user's options and creating the file with the name of the playlist
trackFile.MakePL(allPaths)

# Print a message that inform the user for the creation of the playlist completed
print("The file " + fullName + " has been created.")