Skip to main content

PyDeezer

A package to search and download musics on Deezer.

Installation

Install from release

pip install py-deezer

Install from repository

git clone https://github.com/Chr1st-oo/pydeezer.git
cd pydeezer
pip install .

Usage as a CLI

Usage: pydeezer [OPTIONS] COMMAND [ARGS]...

  PyDeezer CLI

Options:
  --help  Show this message and exit.

Commands:
  download  Download tracks

Commands

Usage: pydeezer download [OPTIONS]

  Download tracks

Options:
  -a, --arl TEXT                  Used to be able to login to Deezer. Check
                                  the docs on how to get one.

  --media-type [Track|Album|Playlist|Artist]
                                  Sets the media type and how it searches the
                                  api.

  -d, --download-dir DIRECTORY    Sets the directory on where the tracks are
                                  to be saved.

  -q, --quality [MP3_128|MP3_256|MP3_320|FLAC]
                                  Sets the quality of the tracks. if the
                                  provided quality is not supported, the
                                  default quality of the track will be used.

  --help                          Show this message and exit.

Usage as a package

Logging In

from pydeezer import Deezer

arl = "edit_this"
deezer = Deezer(arl=arl)
user_info = deezer.user
# or
# deezer = Deezer()
# user_info = deezer.login_via_arl(arl)

You can get the your arl by manually logging into Deezer using your browser and check the cookies and look for the value of arl.

Searching

# Some login code here

# Search tracks
track_search_results = deezer.search_tracks("IM DOPE")
# Search albums
album_search_results = deezer.search_albums("DAMN", limit=10)
# Search artists
artist_search_results = deezer.search_artists("J. Cole", limit=5)
# Search playlists
playlist_search_results = deezer.search_playlists("top", index=2)

Getting Information and Downloading

# Some login code here

# Some download stuffs

from pydeezer import Downloader
from pydeezer.constants import track_formats

download_dir = "C:\\Users\\User\\Music"

track_id = "547653622"
track = deezer.get_track(track_id)
# track is now a dict with a key of info, download, tags, and get_tag
# info and tags are dict
track_info = track["info"]
tags_separated_by_comma = track["tags"]
# download and get_tag are partial functions
track["download"](download_dir, quality=track_formats.MP3_320) # this will download the file, default file name is Filename.[mp3 or flac]
tags_separated_by_semicolon = track["get_tag"](separator="; ") # this will return a dictionary similar to track["tags"] but this will override the default separator

artist_id = "53859305"
artist = deezer.get_artist(artist_id)

album_id = "39949511"
album = deezer.get_album(album_id) # returns a dict containing data about the album

playlist_id = "1370794195"
playlist = deezer.get_playlist(playlist_id) # returns a dict containing data about the playlist

# Multithreaded Downloader

list_of_id = ["572537082",
              "921278352",
              "927432162",
              "547653622"]

downloader = Downloader(deezer, list_of_ids, download_dir,
                        quality=track_formats.MP3_320, concurrent_downloads=2)
downloader.start()

Custom ProgressHandler

This example uses the amazing tqdm package.

Code

from pydeezer import Deezer
from pydeezer.ProgressHandler import BaseProgressHandler
from tqdm import tqdm

# Extend BaseProgressHandler and override its initialize, update and close methods accordingly

class MyProgressHandler(BaseProgressHandler):
    def __init__(self):
        pass

    def initialize(self, *args):
        super().initialize(*args)

        self.pbar = tqdm(self.iterable, total=self.total_size,
                         unit="B", unit_scale=True, unit_divisor=1024, 
                         leave=False, desc=self.track_title)

    def update(self):
        self.pbar.update(self.current_chunk_size)

    def close(self):
        self.pbar.close()


# When starting a download, pass your ProgressHandler instance in progress_handler keyword argument.

print("DefaultProgressHandler")
track["download"](download_dir, quality=track_formats.FLAC)

print()

my_progress_handler = MyProgressHandler()

print("CustomProgressHandler")
track["download"](download_dir, quality=track_formats.FLAC,
                  progress_handler=my_progress_handler)

Output

progresshandlergif

TODO

  • More CLI features, save used Arls for convenience.
  • Multithreaded downloader (1 song / 1 thread)
  • Binary file
  • GUI

Disclaimer

I will and should not be held responsible for the usage of this package.

Don't use this package illegaly and against Deezer's Terms Of Use.

This is licensed under GNU GPL v3.

Metadata

Release files for py-deezer 1.1.4.post1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for py-deezer 1.1.4.post1
File Size Uploaded
py-deezer-1.1.4.post1.tar.gz 15.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for py-deezer 1.1.4.post1
File Interpreter ABI Platform
py_deezer-1.1.4.post1-py3-none-any.whl Python 3 none any Details

Total release size: 35.1 kB

Release files / py-deezer-1.1.4.post1.tar.gz

Download URL py-deezer-1.1.4.post1.tar.gz
Size 15.8 kB
Tags Source
SHA-256 checksum
How to use checksums
c5daaa6b46b337bcbca971434da71cc7f602f1c58ba7198d210c8c8ca13fa414
BLAKE2b-256 checksum
How to use checksums
64d061368c8ab7dedae5c3ee7364bd3f26879a953d5d4f0a455a612422d393dd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.3.0 pkginfo/1.6.1 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.55.1 CPython/3.9.1

Release files / py_deezer-1.1.4.post1-py3-none-any.whl

Download URL py_deezer-1.1.4.post1-py3-none-any.whl
Size 19.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
19ed6dee251cb51d8834279f6aa189f37895e3e0868b9ce5ec3c347263da11f2
BLAKE2b-256 checksum
How to use checksums
dbac9911f5e0b175aeb2f8fe15058f984a32f446e1d02dc30574abf461bfad6e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.3.0 pkginfo/1.6.1 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.55.1 CPython/3.9.1
Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page