Exemplo n.º 1
0
def download_release(releaseid, location, slugify=False):
    """Download the mp3s of all recordings in a release and save
    them to the specificed directory.

    :param release: The MBID of the release
    :param location: Where to save the mp3s to
    :param slugify: Boolean specifying whether to slugify the filepath or not
    """
    if not os.path.exists(location):
        raise Exception("Location %s doesn't exist; can't save" % location)

    release = get_release(releaseid)
    artists = " and ".join([a["name"] for a in release["release_artists"]])
    artists = slugify_tr(artists) if slugify else artists

    releasename = release["title"]
    releasename = slugify_tr(releasename) if slugify else releasename
    releasedir = os.path.join(location, "%s_%s" % (artists, releasename))

    if not os.path.exists(releasedir):
        os.makedirs(releasedir)

    for r in release["recordings"]:
        rid = r["mbid"]
        title = r["title"]
        title = slugify_tr(title) if slugify else title
        title = title.replace("/", "_")

        track = r["track"]
        contents = docserver.get_mp3(rid)
        name = "%d_%s_%s.mp3" % (track, artists, title)
        path = os.path.join(releasedir, name)
        open(path, "wb").write(contents)
Exemplo n.º 2
0
def download_release(releaseid, location, slugify = False):
    """Download the mp3s of all recordings in a release and save
    them to the specificed directory.

    :param release: The MBID of the release
    :param location: Where to save the mp3s to
    :param slugify: Boolean specifying whether to slugify the filepath or not
    """
    if not os.path.exists(location):
        raise Exception("Location %s doesn't exist; can't save" % location)

    release = get_release(releaseid)
    artists = " and ".join([a["name"] for a in release["release_artists"]])
    artists = slugify_tr(artists) if slugify else artists

    releasename = release["title"]
    releasename = slugify_tr(releasename) if slugify else releasename
    releasedir = os.path.join(location, "%s_%s" % (artists, releasename))

    if not os.path.exists(releasedir):
        os.makedirs(releasedir)

    for r in release["recordings"]:
        rid = r["mbid"]
        title = r["title"]
        title = slugify_tr(title) if slugify else title

        track = r["track"]
        contents = docserver.get_mp3(rid)
        name = "%d_%s_%s.mp3" % (track, artists, title)
        path = os.path.join(releasedir, name)
        open(path, "wb").write(contents)
Exemplo n.º 3
0
def download_mp3(recordingid, location, slugify=False):
    """Download the mp3 of a document and save it to the specificed directory.

    :param recordingid: The MBID of the recording
    :param location: Where to save the mp3 to
    :param slugify: Boolean specifying whether to slugify the filepath or not
    """
    if not os.path.exists(location):
        raise Exception("Location %s doesn't exist; can't save" % location)

    recording = get_recording(recordingid)
    title = recording["title"]
    title = slugify_tr(title) if slugify else title
    title = title.replace("/", "_")

    rels = recording["releases"]
    if rels:
        release = get_release(rels[0]["mbid"])
        artists = " and ".join([a["name"] for a in release["release_artists"]])
        artists = slugify_tr(artists) if slugify else artists

        name = "%s_%s.mp3" % (artists, title)
    else:
        name = "%s.mp3" % title

    contents = docserver.get_mp3(recordingid)
    path = os.path.join(location, name)
    open(path, "wb").write(contents)
    return path
Exemplo n.º 4
0
def download_mp3(recordingid, location, slugify = False):
    """Download the mp3 of a document and save it to the specificed directory.

    :param recordingid: The MBID of the recording
    :param location: Where to save the mp3 to
    :param slugify: Boolean specifying whether to slugify the filepath or not
    """
    if not os.path.exists(location):
        raise Exception("Location %s doesn't exist; can't save" % location)

    recording = get_recording(recordingid)
    title = recording["title"]
    title = slugify_tr(title) if slugify else title

    rels = recording["releases"]
    if rels:
        release = get_release(rels[0]["mbid"])
        artists = " and ".join([a["name"] for a in release["release_artists"]])
        artists = slugify_tr(artists) if slugify else title
        
        name = "%s_%s.mp3" % (artists, title)
    else:
        name = "%s.mp3" % title

    contents = docserver.get_mp3(recordingid)
    path = os.path.join(location, name)
    open(path, "wb").write(contents)
    return path
Exemplo n.º 5
0
def download_mp3(recordingid, location):
    if not os.path.exists(location):
        raise Exception("Location %s doesn't exist; can't save" % location)

    recording = get_recording(recordingid)
    concert = get_concert(recording["concert"]["mbid"])
    title = recording["title"]
    artists = " and ".join([a["name"] for a in concert["concert_artists"]])
    contents = docserver.get_mp3(recordingid)
    name = "%s - %s.mp3" % (artists, title)
    path = os.path.join(location, name)
    open(path, "wb").write(contents)
Exemplo n.º 6
0
def download_concert(concertid, location):
    if not os.path.exists(location):
        raise Exception("Location %s doesn't exist; can't save" % location)

    concert = get_concert(concert_id)
    artists = " and ".join([a["name"] for a in concert["concert_artists"]])
    concertname = concert["title"]
    concertdir = os.path.join(location, "%s - %s" % (artists, concertname))
    for r in concert["tracks"]:
        rid = r["mbid"]
        title = r["title"]
        contents = docserver.get_mp3(rid)
        name = "%s - %s.mp3" % (artists, title)
        path = os.path.join(concertdir, name)
        open(path, "wb").write(contents)
Exemplo n.º 7
0
def download_mp3(recordingid, location):
    """Download the mp3 of a document and save it to the specificed directory.

    :param recordingid: The MBID of the recording
    :param location: Where to save the mp3 to

    """
    if not os.path.exists(location):
        raise Exception("Location %s doesn't exist; can't save" % location)

    recording = get_recording(recordingid)
    concert = get_concert(recording["concert"]["mbid"])
    title = recording["title"]
    artists = " and ".join([a["name"] for a in concert["concert_artists"]])
    contents = docserver.get_mp3(recordingid)
    name = "%s - %s.mp3" % (artists, title)
    path = os.path.join(location, name)
    open(path, "wb").write(contents)
Exemplo n.º 8
0
def download_mp3(recordingid, location):
    """Download the mp3 of a document and save it to the specificed directory.

    :param recordingid: The MBID of the recording
    :param location: Where to save the mp3 to

    """
    if not os.path.exists(location):
        raise Exception("Location %s doesn't exist; can't save" % location)

    recording = get_recording(recordingid)
    concert = get_concert(recording["concert"][0]["mbid"])
    title = recording["title"]
    artists = " and ".join([a["name"] for a in concert["concert_artists"]])
    contents = docserver.get_mp3(recordingid)
    name = "%s - %s.mp3" % (artists, title)
    path = os.path.join(location, name)
    open(path, "wb").write(contents)
    return name
Exemplo n.º 9
0
def download_concert(concertid, location):
    """Download the mp3s of all recordings in a concert and save
    them to the specificed directory.

    :param concert: The MBID of the concert
    :param location: Where to save the mp3s to

    """
    if not os.path.exists(location):
        raise Exception("Location %s doesn't exist; can't save" % location)

    concert = get_concert(concert_id)
    artists = " and ".join([a["name"] for a in concert["concert_artists"]])
    concertname = concert["title"]
    concertdir = os.path.join(location, "%s - %s" % (artists, concertname))
    for r in concert["tracks"]:
        rid = r["mbid"]
        title = r["title"]
        contents = docserver.get_mp3(rid)
        name = "%s - %s.mp3" % (artists, title)
        path = os.path.join(concertdir, name)
        open(path, "wb").write(contents)
Exemplo n.º 10
0
def download_concert(concertid, location):
    """Download the mp3s of all recordings in a concert and save
    them to the specificed directory.

    :param concert: The MBID of the concert
    :param location: Where to save the mp3s to

    """
    if not os.path.exists(location):
        raise Exception("Location %s doesn't exist; can't save" % location)

    concert = get_concert(concert_id)
    artists = " and ".join([a["name"] for a in concert["concert_artists"]])
    concertname = concert["title"]
    concertdir = os.path.join(location, "%s - %s" % (artists, concertname))
    for r in concert["tracks"]:
        rid = r["mbid"]
        title = r["title"]
        contents = docserver.get_mp3(rid)
        name = "%s - %s.mp3" % (artists, title)
        path = os.path.join(concertdir, name)
        open(path, "wb").write(contents)
Exemplo n.º 11
0
def download_release(release_id, location):
    """Download the mp3s of all recordings in a release and save
    them to the specificed directory.

    :param release_id: The MBID of the release
    :param location: Where to save the mp3s to

    """
    if not os.path.exists(location):
        raise Exception("Location %s doesn't exist; can't save" % location)

    release = get_release(release_id)
    artists = " and ".join([a["name"] for a in release["release_artists"]])
    releasename = release["title"]
    releasedir = os.path.join(location, "%s - %s" % (artists, releasename))
    for r in release["tracks"]:
        rid = r["mbid"]
        title = r["title"]
        contents = docserver.get_mp3(rid)
        name = "%s - %s.mp3" % (artists, title)
        path = os.path.join(releasedir, name)
        open(path, "wb").write(contents)
Exemplo n.º 12
0
def download_release(release_id, location):
    """Download the mp3s of all recordings in a release and save
    them to the specificed directory.

    :param release_id: The MBID of the release
    :param location: Where to save the mp3s to

    """
    if not os.path.exists(location):
        raise Exception("Location %s doesn't exist; can't save" % location)

    release = get_release(release_id)
    artists = " and ".join([a["name"] for a in release["release_artists"]])
    releasename = release["title"]
    releasedir = os.path.join(location, "%s - %s" % (artists, releasename))
    for r in release["tracks"]:
        rid = r["mbid"]
        title = r["title"]
        contents = docserver.get_mp3(rid)
        name = "%s - %s.mp3" % (artists, title)
        path = os.path.join(releasedir, name)
        open(path, "wb").write(contents)