Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Create a song class Attributes 1. Title 2. Band members: a dictionary with name

ID: 3784787 • Letter: C

Question

Create a song class Attributes 1. Title 2. Band members: a dictionary with name as the key and instrument as the values. 3. (Highest place on the charts. Methods 1. init Has a filepointer as an optional parameter. If filepointer is None have the user input the attributes. If the filepointer is not None input the song from the file. 2. str Output the attributes in a nice way 3. save Save a song to a file, the filepointer should be a parameter. Create an album class Attributes 1. Title 2. Year 3. Producer 4. Songs a list of songs each of which are of type class song Methods 1. init Has a filepointer as an optional parameter. If filepointer is None have the user input the attributes. If the filepointer is not None input the album from the file. In both cases, when you input a song make sure to use the songs method for input The song attribute should be an optional para If the value is None keep inputting songs until the user is done 2. str Output the attributes of the album in a nice way. 3. save saves the entire album to a file, makes use of the song.save attribute for the songs. The filepointer is a parameter

Explanation / Answer

class SongData(object):

    def __init__(self, title="", artist="", directory=""):

        self.title, self.artist, self.directory = title, artist, directory

    def __str__(self):

        desc_str = "Title: %s Artist: %s Directory: %s " %(self.title,

                                            self.artist, self.directory)

        print desc_str

songNames = ['song1', 'song2', 'song3']

artistNames = ['artist1', 'artist2', 'artist3']

dirNames = ['dir1', 'dir2', 'dir3']

songs = {name: SongData(title=name) for name in songNames}

artists = {band: SongData(artist=band) for band in artistNames}

directorys = {direc: SongData(directory=direc) for direc in dirNames}

2) from songdetails import SongFileDetails

from songdetails.mp3details import audio

from songdetails.mp3details import id3

from songdetails.mp3details import exceptions

from songdetails.mp3details.audio import MPEGAudioDescriptor

from songdetails.mp3details.id3 import ID3TagDescriptor, _track_convert,

    _genre_convert

from songdetails.mp3details.exceptions import MP3DetailsException

__all__ = ["audio", "id3", 'scan', "MP3Details", "MP3DetailsException"]

class MP3Details(SongFileDetails):

    """MP3 details"""

    title = ID3TagDescriptor("TIT2", "TIT2", "TT2", "title")

    artist = ID3TagDescriptor("TPE1", "TPE1", "TP1", "artist")

    album = ID3TagDescriptor("TALB", "TALB", "TAL", "album")

    year = ID3TagDescriptor("TYER", "TYER", "TYE", "year")

    track = ID3TagDescriptor("TRCK", "TRCK", "TRK", "track", _track_convert)

    genre = ID3TagDescriptor("TCON", "TCON", "TCO", "genre", _genre_convert)

    composer = ID3TagDescriptor("TCOM", "TCOM", "TCM")

    comment = ID3TagDescriptor("COMM", "COMM", "COM")

    duration = MPEGAudioDescriptor("duration")

   

    def __init__(self, filepath):

        """

        :param filepath: File path to MP3.

        :type filepath: string, unicode

       

        :raise MP3DetailsException: Raised if the file is not MP3.

       

        """

        super(MP3Details, self).__init__(filepath)

        ID3TagDescriptor.initialize_owner(self, filepath)

        MPEGAudioDescriptor.initialize_owner(self, filepath)

       

    def save(self):

        """Save changes to the MP3"""

        ID3TagDescriptor.save(self)

def scan(filepath):

    """Scan files for MP3Details.

   

    :param filepath: Path to file.

   

    :rtype: :mod:`MP3Details`, or None

   

    """

    try:

        return MP3Details(filepath)

    except MP3DetailsException:

        return None

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote