Skip to content

Commit efb49ba

Browse files
committed
Added some more Discogs API endpoints
1 parent eba6a8a commit efb49ba

File tree

93 files changed

+16058
-12494
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

93 files changed

+16058
-12494
lines changed

.github/workflows/ci.yml

+10-11
Original file line numberDiff line numberDiff line change
@@ -12,32 +12,31 @@ env:
1212
TIDAL_PRIVATE_CLIENT_SECRET: ${{ secrets.TIDAL_PRIVATE_CLIENT_SECRET }}
1313
jobs:
1414
build:
15-
name: Continuous integration (Python ${{ matrix.python-version }})
15+
name: continuous-integration-${{ matrix.os }}-python-${{ matrix.python-version }}
1616
strategy:
1717
matrix:
18-
os: [macos-latest, ubuntu-latest, windows-latest]
18+
os: [ubuntu-latest, windows-latest]
1919
python-version: ["3.9", "3.10", "3.11"]
2020
runs-on: ${{ matrix.os }}
2121
defaults:
2222
run:
2323
shell: bash -el {0}
2424
timeout-minutes: 60
25-
steps:
25+
steps:
2626
- uses: actions/checkout@v3
2727
- uses: actions/setup-python@v4
2828
with:
2929
python-version: ${{ matrix.python-version }}
3030
- uses: FedericoCarboni/setup-ffmpeg@v2
3131
id: setup-ffmpeg
32-
- name: Install required dependencies using pip
33-
run: |
34-
python3 -m pip install -r requirements_minimal.txt
35-
- name: Lint with ruff
32+
- name: pip-install-dependencies
33+
run: python3 -m pip install -r requirements_minimal.txt
34+
- name: ruff-lint
3635
run: |
3736
python3 -m pip install ruff
38-
ruff --target-version=py39 .
37+
ruff check --target-version=py39 .
3938
continue-on-error: true
40-
- name: Test with coverage and pytest
39+
- name: pytest-test
4140
run: |
42-
python3 -m pip install coverage pytest
43-
coverage run -m pytest
41+
python3 -m pip install pytest
42+
pytest

docs/.doctrees/api.doctree

0 Bytes
Binary file not shown.
0 Bytes
Binary file not shown.
0 Bytes
Binary file not shown.
0 Bytes
Binary file not shown.
-120 Bytes
Binary file not shown.
0 Bytes
Binary file not shown.
0 Bytes
Binary file not shown.
0 Bytes
Binary file not shown.
290 KB
Binary file not shown.
232 Bytes
Binary file not shown.

docs/.doctrees/api/minim.doctree

0 Bytes
Binary file not shown.
Binary file not shown.
0 Bytes
Binary file not shown.
300 Bytes
Binary file not shown.
0 Bytes
Binary file not shown.
Binary file not shown.
2.48 KB
Binary file not shown.
0 Bytes
Binary file not shown.
29.5 KB
Binary file not shown.
334 Bytes
Binary file not shown.
0 Bytes
Binary file not shown.
0 Bytes
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

docs/.doctrees/environment.pickle

-199 KB
Binary file not shown.

docs/.doctrees/index.doctree

0 Bytes
Binary file not shown.
-2.17 KB
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

docs/.doctrees/user_guide.doctree

0 Bytes
Binary file not shown.

docs/_modules/index.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<meta name="viewport" content="width=device-width,initial-scale=1"/>
55
<meta name="color-scheme" content="light dark"><link rel="index" title="Index" href="../genindex.html" /><link rel="search" title="Search" href="../search.html" />
66

7-
<link rel="shortcut icon" href="../_static/favicon.ico"/><!-- Generated with Sphinx 7.2.6 and Furo 2023.09.10 -->
7+
<link rel="shortcut icon" href="../_static/favicon.ico"/><!-- Generated with Sphinx 7.2.6 and Furo 2024.01.29 -->
88
<title>Overview: module code - Minim 1.0.0 documentation</title>
99
<link rel="stylesheet" type="text/css" href="../_static/pygments.css?v=a746c00c" />
1010
<link rel="stylesheet" type="text/css" href="../_static/styles/furo.css?v=135e06be" />

docs/_modules/minim/audio.html

+151-140
Large diffs are not rendered by default.

docs/_modules/minim/discogs.html

+1,475-308
Large diffs are not rendered by default.

docs/_modules/minim/itunes.html

+47-47
Large diffs are not rendered by default.

docs/_modules/minim/qobuz.html

+156-156
Large diffs are not rendered by default.

docs/_modules/minim/spotify.html

+639-638
Large diffs are not rendered by default.

docs/_modules/minim/tidal.html

+800-653
Large diffs are not rendered by default.

docs/_modules/minim/utility.html

+14-13
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<meta name="viewport" content="width=device-width,initial-scale=1"/>
55
<meta name="color-scheme" content="light dark"><link rel="index" title="Index" href="../../genindex.html" /><link rel="search" title="Search" href="../../search.html" />
66

7-
<link rel="shortcut icon" href="../../_static/favicon.ico"/><!-- Generated with Sphinx 7.2.6 and Furo 2023.09.10 -->
7+
<link rel="shortcut icon" href="../../_static/favicon.ico"/><!-- Generated with Sphinx 7.2.6 and Furo 2024.01.29 -->
88
<title>minim.utility - Minim 1.0.0 documentation</title>
99
<link rel="stylesheet" type="text/css" href="../../_static/pygments.css?v=a746c00c" />
1010
<link rel="stylesheet" type="text/css" href="../../_static/styles/furo.css?v=135e06be" />
@@ -173,6 +173,7 @@
173173
<li class="toctree-l3"><a class="reference internal" href="../../api/minim.audio.FLACAudio.html">FLACAudio</a></li>
174174
<li class="toctree-l3"><a class="reference internal" href="../../api/minim.audio.MP3Audio.html">MP3Audio</a></li>
175175
<li class="toctree-l3"><a class="reference internal" href="../../api/minim.audio.MP4Audio.html">MP4Audio</a></li>
176+
<li class="toctree-l3"><a class="reference internal" href="../../api/minim.audio.OggAudio.html">OggAudio</a></li>
176177
<li class="toctree-l3"><a class="reference internal" href="../../api/minim.audio.WAVEAudio.html">WAVEAudio</a></li>
177178
</ul>
178179
</li>
@@ -269,9 +270,9 @@ <h1>Source code for minim.utility</h1><div class="highlight"><pre>
269270
<span class="k">def</span> <span class="nf">format_multivalue</span><span class="p">(</span>
270271
<span class="n">value</span><span class="p">:</span> <span class="n">Any</span><span class="p">,</span> <span class="n">multivalue</span><span class="p">:</span> <span class="nb">bool</span><span class="p">,</span> <span class="o">*</span><span class="p">,</span> <span class="n">primary</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span><span class="p">,</span>
271272
<span class="n">sep</span><span class="p">:</span> <span class="n">Union</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="nb">tuple</span><span class="p">[</span><span class="nb">str</span><span class="p">]]</span> <span class="o">=</span> <span class="p">(</span><span class="s2">&quot;, &quot;</span><span class="p">,</span> <span class="s2">&quot; &amp; &quot;</span><span class="p">))</span> <span class="o">-&gt;</span> <span class="n">Union</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="nb">list</span><span class="p">[</span><span class="n">Any</span><span class="p">]]:</span>
272-
<span class="w"> </span>
273+
273274
<span class="w"> </span><span class="sd">&quot;&quot;&quot;</span>
274-
<span class="sd"> Format a field value based on whether multivalue for that field is </span>
275+
<span class="sd"> Format a field value based on whether multivalue for that field is</span>
275276
<span class="sd"> supported.</span>
276277

277278
<span class="sd"> Parameters</span>
@@ -280,7 +281,7 @@ <h1>Source code for minim.utility</h1><div class="highlight"><pre>
280281
<span class="sd"> Field value to format.</span>
281282

282283
<span class="sd"> multivalue : `bool`</span>
283-
<span class="sd"> Determines whether multivalue tags are supported. If </span>
284+
<span class="sd"> Determines whether multivalue tags are supported. If</span>
284285
<span class="sd"> :code:`False`, the items in `value` are concatenated using the</span>
285286
<span class="sd"> separator(s) specified in `sep`.</span>
286287

@@ -289,11 +290,11 @@ <h1>Source code for minim.utility</h1><div class="highlight"><pre>
289290
<span class="sd"> `value` is a `list` and :code:`multivalue=False`.</span>
290291

291292
<span class="sd"> sep : `str` or `tuple`, keyword-only, default: :code:`(&quot;, &quot;, &quot; &amp; &quot;)`</span>
292-
<span class="sd"> Separator(s) to use to concatenate multivalue tags. If a </span>
293+
<span class="sd"> Separator(s) to use to concatenate multivalue tags. If a</span>
293294
<span class="sd"> :code:`str` is provided, it is used to concatenate all values.</span>
294295
<span class="sd"> If a :code:`tuple` is provided, the first :code:`str` is used to</span>
295-
<span class="sd"> concatenate all values except the last, and the second </span>
296-
<span class="sd"> :code:`str` is used to append the final value. </span>
296+
<span class="sd"> concatenate all values except the last, and the second</span>
297+
<span class="sd"> :code:`str` is used to append the final value.</span>
297298

298299
<span class="sd"> Returns</span>
299300
<span class="sd"> -------</span>
@@ -321,7 +322,7 @@ <h1>Source code for minim.utility</h1><div class="highlight"><pre>
321322
<span class="p">)</span> <span class="o">-&gt;</span> <span class="n">Union</span><span class="p">[</span><span class="nb">float</span><span class="p">,</span> <span class="nb">list</span><span class="p">[</span><span class="nb">float</span><span class="p">],</span> <span class="s2">&quot;np.ndarray[float]&quot;</span><span class="p">]:</span>
322323

323324
<span class="w"> </span><span class="sd">&quot;&quot;&quot;</span>
324-
<span class="sd"> Compute the Gestalt or Ratcliff–Obershelp ratios, a measure of </span>
325+
<span class="sd"> Compute the Gestalt or Ratcliff–Obershelp ratios, a measure of</span>
325326
<span class="sd"> similarity, for strings with respect to a reference string.</span>
326327

327328
<span class="sd"> Parameters</span>
@@ -336,8 +337,8 @@ <h1>Source code for minim.utility</h1><div class="highlight"><pre>
336337
<span class="sd"> -------</span>
337338
<span class="sd"> ratios : `float`, `list`, or `numpy.ndarray`</span>
338339
<span class="sd"> Gestalt or Ratcliff–Obershelp ratios. If `strings` is a `str`, a</span>
339-
<span class="sd"> `float` is returned. If `strings` is a `list`, a `numpy.ndarray` </span>
340-
<span class="sd"> is returned if NumPy is installed; otherwise, a `list` is </span>
340+
<span class="sd"> `float` is returned. If `strings` is a `list`, a `numpy.ndarray`</span>
341+
<span class="sd"> is returned if NumPy is installed; otherwise, a `list` is</span>
341342
<span class="sd"> returned.</span>
342343
<span class="sd"> &quot;&quot;&quot;</span>
343344

@@ -371,15 +372,15 @@ <h1>Source code for minim.utility</h1><div class="highlight"><pre>
371372
<span class="sd"> -------</span>
372373
<span class="sd"> ratios : `float`, `list`, or `numpy.ndarray`</span>
373374
<span class="sd"> Levenshtein ratios. If `strings` is a `str`, a `float` is</span>
374-
<span class="sd"> returned. If `strings` is a `list`, a `numpy.ndarray` is </span>
375+
<span class="sd"> returned. If `strings` is a `list`, a `numpy.ndarray` is</span>
375376
<span class="sd"> returned if NumPy is installed; otherwise, a `list` is returned.</span>
376377
<span class="sd"> &quot;&quot;&quot;</span>
377378

378379
<span class="k">if</span> <span class="ow">not</span> <span class="n">FOUND_LEVENSHTEIN</span><span class="p">:</span>
379380
<span class="n">emsg</span> <span class="o">=</span> <span class="p">(</span><span class="s2">&quot;The Levenshtein module was not found, so &quot;</span>
380381
<span class="s2">&quot;minim.utility.levenshtein_ratio() is unavailable.&quot;</span><span class="p">)</span>
381382
<span class="k">raise</span> <span class="ne">ImportError</span><span class="p">(</span><span class="n">emsg</span><span class="p">)</span>
382-
383+
383384
<span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">strings</span><span class="p">,</span> <span class="nb">str</span><span class="p">):</span>
384385
<span class="k">return</span> <span class="n">Levenshtein</span><span class="o">.</span><span class="n">ratio</span><span class="p">(</span><span class="n">reference</span><span class="p">,</span> <span class="n">strings</span><span class="p">)</span>
385386
<span class="n">gen</span> <span class="o">=</span> <span class="p">(</span><span class="n">Levenshtein</span><span class="o">.</span><span class="n">ratio</span><span class="p">(</span><span class="n">reference</span><span class="p">,</span> <span class="n">s</span><span class="p">)</span> <span class="k">for</span> <span class="n">s</span> <span class="ow">in</span> <span class="n">strings</span><span class="p">)</span>
@@ -399,7 +400,7 @@ <h1>Source code for minim.utility</h1><div class="highlight"><pre>
399400
<div class="bottom-of-page">
400401
<div class="left-details">
401402
<div class="copyright">
402-
Copyright &#169; 2023, Benjamin Ye
403+
Copyright &#169; 2023–2024 Benjamin Ye
403404
</div>
404405
Made with <a href="https://www.sphinx-doc.org/">Sphinx</a> and <a class="muted-link" href="https://pradyunsg.me">@pradyunsg</a>'s
405406

docs/_sources/api/minim.discogs.API.rst.txt

+7-1

docs/_sources/api/minim.tidal.API.rst.txt

+3-2

docs/_sources/notebooks/user_guide/editing_audio_metadata.ipynb.txt

+21-24
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,8 @@
6060
"metadata": {},
6161
"outputs": [],
6262
"source": [
63-
"audio_files = [f for f in (Path().resolve().parents[3] \n",
64-
" / \"tests/data/previews\").glob(\"**/*\") \n",
63+
"audio_files = [f for f in (Path().resolve().parents[3]\n",
64+
" / \"tests/data/previews\").glob(\"**/*\")\n",
6565
" if f.suffix == \".flac\"]"
6666
]
6767
},
@@ -86,7 +86,7 @@
8686
" if field in {\"artwork\", \"lyrics\"}:\n",
8787
" if value:\n",
8888
" value = type(value)\n",
89-
" field = (field.upper() if field == \"isrc\" \n",
89+
" field = (field.upper() if field == \"isrc\"\n",
9090
" else field.replace(\"_\", \" \").capitalize())\n",
9191
" print(f\"{field}: {value}\")"
9292
]
@@ -325,14 +325,14 @@
325325
"itunes_track = itunes_results[\n",
326326
" np.argmax(\n",
327327
" utility.levenshtein_ratio(\n",
328-
" query, \n",
329-
" [f\"{r['artistName']} {r['trackName']}\".lower() \n",
328+
" query,\n",
329+
" [f\"{r['artistName']} {r['trackName']}\".lower()\n",
330330
" for r in itunes_results]\n",
331331
" )\n",
332332
" )\n",
333333
"]\n",
334334
"itunes_album = client_itunes.lookup(itunes_track[\"collectionId\"])[\"results\"][0]\n",
335-
"audio_file.set_metadata_using_itunes(itunes_track, album_data=itunes_album, \n",
335+
"audio_file.set_metadata_using_itunes(itunes_track, album_data=itunes_album,\n",
336336
" overwrite=True)\n",
337337
"print_metadata(audio_file)"
338338
]
@@ -401,14 +401,14 @@
401401
"spotify_track = spotify_results[\n",
402402
" np.argmax(\n",
403403
" utility.levenshtein_ratio(\n",
404-
" query, \n",
405-
" [f\"{r['artists'][0]['name']} {r['name']}\".lower() \n",
404+
" query,\n",
405+
" [f\"{r['artists'][0]['name']} {r['name']}\".lower()\n",
406406
" for r in spotify_results]\n",
407407
" )\n",
408408
" )\n",
409409
"]\n",
410410
"audio_file.set_metadata_using_spotify(\n",
411-
" spotify_track, \n",
411+
" spotify_track,\n",
412412
" audio_features=client_spotify.get_track_audio_features(spotify_track[\"id\"])\n",
413413
")\n",
414414
"print_metadata(audio_file)"
@@ -422,7 +422,7 @@
422422
"\n",
423423
"* searching for the track on TIDAL via `minim.tidal.PrivateAPI.search()`,\n",
424424
"* selecting the correct result by matching the ISRC,\n",
425-
"* getting the track's composers and lyrics using `minim.tidal.PrivateAPI.get_track_composers()` and `minim.tidal.PrivateAPI.get_track_lyrics()`, respectively, and\n",
425+
"* getting the track's composers using `minim.tidal.PrivateAPI.get_track_composers()`, and\n",
426426
"* populating the file handler's metadata with the JSON results using `minim.audio.FLACAudio.set_metadata_using_tidal()`."
427427
]
428428
},
@@ -469,16 +469,15 @@
469469
"tidal_results = client_tidal.search(query)[\"tracks\"][\"items\"]\n",
470470
"tidal_track = next((r for r in tidal_results if r[\"isrc\"] == audio_file.isrc), None)\n",
471471
"tidal_composers = client_tidal.get_track_composers(tidal_track[\"id\"])\n",
472-
"tidal_lyrics = client_tidal.get_track_lyrics(tidal_track[\"id\"])\n",
473-
"audio_file.set_metadata_using_tidal(tidal_track, composers=tidal_composers, lyrics=tidal_lyrics)\n",
472+
"audio_file.set_metadata_using_tidal(tidal_track, composers=tidal_composers)\n",
474473
"print_metadata(audio_file)"
475474
]
476475
},
477476
{
478477
"cell_type": "markdown",
479478
"metadata": {},
480479
"source": [
481-
"The metadata for the track is now complete. (For this example, TIDAL did not have songwriting credits for the track. This happens sometimes when the track is not very popular.)\n",
480+
"The metadata for the track is now practically complete. Lyrics are available through either `minim.spotify.PrivateLyricsService.get_lyrics()` or `minim.tidal.PrivateAPI.get_track_lyrics()` with active subscriptions. (For this example, TIDAL did not have songwriting credits for the track. This happens sometimes when the track is not very popular.)\n",
482481
"\n",
483482
"Don't forget to write the changes to file using `minim.audio.FLACAudio.write()`!"
484483
]
@@ -604,7 +603,7 @@
604603
"cell_type": "markdown",
605604
"metadata": {},
606605
"source": [
607-
"The file has a poorly formatted copyright string and is missing lyrics, tempo, and cover art information. We can fix this by querying the three APIs as we did in the previous example, and overwrite the existing metadata:"
606+
"The file has a poorly formatted copyright string and is missing tempo and cover art information. We can fix this by querying the three APIs as we did in the previous example, and overwrite the existing metadata:"
608607
]
609608
},
610609
{
@@ -620,40 +619,38 @@
620619
"itunes_track = itunes_results[\n",
621620
" np.argmax(\n",
622621
" utility.levenshtein_ratio(\n",
623-
" query, \n",
624-
" [f\"{r['artistName']} {r['trackName']}\".lower() \n",
622+
" query,\n",
623+
" [f\"{r['artistName']} {r['trackName']}\".lower()\n",
625624
" for r in itunes_results]\n",
626625
" )\n",
627626
" )\n",
628627
"]\n",
629628
"itunes_album = client_itunes.lookup(itunes_track[\"collectionId\"])[\"results\"][0]\n",
630-
"audio_file.set_metadata_using_itunes(itunes_track, album_data=itunes_album, \n",
629+
"audio_file.set_metadata_using_itunes(itunes_track, album_data=itunes_album,\n",
631630
" overwrite=True)\n",
632631
"\n",
633632
"# Spotify Web API\n",
634633
"spotify_results = client_spotify.search(query, type=\"track\")[\"items\"]\n",
635634
"spotify_track = spotify_results[\n",
636635
" np.argmax(\n",
637636
" utility.levenshtein_ratio(\n",
638-
" query, \n",
639-
" [f\"{r['artists'][0]['name']} {r['name']}\".lower() \n",
637+
" query,\n",
638+
" [f\"{r['artists'][0]['name']} {r['name']}\".lower()\n",
640639
" for r in spotify_results]\n",
641640
" )\n",
642641
" )\n",
643642
"]\n",
644643
"audio_file.set_metadata_using_spotify(\n",
645-
" spotify_track, \n",
644+
" spotify_track,\n",
646645
" audio_features=client_spotify.get_track_audio_features(spotify_track[\"id\"])\n",
647646
")\n",
648647
"\n",
649648
"# Private TIDAL API\n",
650649
"tidal_results = client_tidal.search(query)[\"tracks\"][\"items\"]\n",
651-
"tidal_track = next((r for r in tidal_results if r[\"isrc\"] == audio_file.isrc), \n",
650+
"tidal_track = next((r for r in tidal_results if r[\"isrc\"] == audio_file.isrc),\n",
652651
" None)\n",
653652
"tidal_composers = client_tidal.get_track_composers(tidal_track[\"id\"])\n",
654-
"tidal_lyrics = client_tidal.get_track_lyrics(tidal_track[\"id\"])\n",
655-
"audio_file.set_metadata_using_tidal(tidal_track, composers=tidal_composers, \n",
656-
" lyrics=tidal_lyrics)"
653+
"audio_file.set_metadata_using_tidal(tidal_track, composers=tidal_composers)"
657654
]
658655
},
659656
{

0 commit comments

Comments
 (0)