Skip to content

Commit

Permalink
Added additional fields to be imported from Deezer
Browse files Browse the repository at this point in the history
  • Loading branch information
arsaboo committed Jul 9, 2023
1 parent 9481402 commit 5419a78
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions beetsplug/deezer.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,24 @@

import collections

import unidecode
import requests
import unidecode

from beets import ui
from beets.autotag import AlbumInfo, TrackInfo
from beets.plugins import MetadataSourcePlugin, BeetsPlugin
from beets.dbcore import types
from beets.plugins import BeetsPlugin, MetadataSourcePlugin
from beets.util.id_extractors import deezer_id_regex


class DeezerPlugin(MetadataSourcePlugin, BeetsPlugin):
data_source = 'Deezer'

item_types = {
'deezer_track_rank': types.INTEGER,
'deezer_track_id': types.INTEGER,
}

# Base URLs for the Deezer API
# Documentation: https://developers.deezer.com/api/
search_url = 'https://api.deezer.com/search/'
Expand Down Expand Up @@ -113,6 +119,7 @@ def album_for_id(self, album_id):
mediums=max(medium_totals.keys()),
data_source=self.data_source,
data_url=album_data['link'],
cover_art_url=album_data['cover_xl'],
)

def _get_track(self, track_data):
Expand All @@ -129,11 +136,14 @@ def _get_track(self, track_data):
return TrackInfo(
title=track_data['title'],
track_id=track_data['id'],
deezer_track_id=track_data['id'],
isrc=track_data.get('isrc'),
artist=artist,
artist_id=artist_id,
length=track_data['duration'],
index=track_data.get('track_position'),
medium=track_data.get('disk_number'),
deezer_track_rank=track_data.get('rank'),
medium_index=track_data.get('track_position'),
data_source=self.data_source,
data_url=track_data['link'],
Expand Down

0 comments on commit 5419a78

Please sign in to comment.