Code Monkey home page Code Monkey logo

minim's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Forkers

acmosa emilot

minim's Issues

Required dependencies?

The installation of the 'minim' on Raspberry Pi forced to install Rust compiler and Ffmpeg library. Is it really required?
Thanks!

404 : Not Found You are requesting a page that does not exist!

I am getting a 404 error when I'm using this code:

from minim import spotify
import pandas as pd
client = spotify.WebAPI(flow="pkce", browser=True, web_framework="http.server",
                        scopes=spotify.WebAPI.get_scopes("all"), overwrite=True)

## Specify the target Spotify playlist's ID.
playlist_id = "bff27fb8fb714104"

## Get the first 100 playlist items/tracks.
resp = client.get_playlist_items(playlist_id, limit=100)

## Get the track IDs of the returned playlist items/tracks.
track_ids = [item["track"]["id"] for item in resp["items"]]

## Get the audio features for the 100 tracks.
afs = client.get_tracks_audio_features(track_ids)

## Create a DataFrame using the audio features data.
df = pd.DataFrame(afs)

## Iterate through the rest of the playlist items/tracks.
while True:

    ## Break the loop if all playlist items/tracks have been retrieved.
    if resp["offset"] + resp["limit"] >= resp["total"]:
        break

    ## Same procedure as above.
    resp = client.get_playlist_items(playlist_id, limit=100, 
                                     offset=resp["offset"] + resp["limit"])
    track_ids = [item["track"]["id"] for item in resp["items"]]
    afs = client.get_tracks_audio_features(track_ids)

    ## Concatenate the new audio features data to the existing DataFrame.
    df = pd.concat([df, pd.DataFrame(afs)])

I am working on a Jupyter Notebook and when I run the code I get a Spotify webpage with this authorization:

image

When I click on agree I get a new page with the error:

image

Not sure why this is happening. Before this I was getting the RuntimeError: minim.spotify.WebAPI.get_playlist_item() requires the 'playlist-modify-private' authorization scope. I used the overwrite=True paramater but now having the issue I mentioned above.

Hope you can help me. Thanks in advance!

ImportError: cannot import name 'FFMPEG_CODECS' from partially initialized module 'minim' (most likely due to a circular import)

Hello!

I was about to give minim a try, since it looks super interesting, and I'm getting this circular import error as soon as I try to import minim:
ImportError: cannot import name 'FFMPEG_CODECS' from partially initialized module 'minim' (most likely due to a circular import)

I followed the instructions to install the dependencies and the project in editable mode with virtualenv. I'm using Python 3.11 and macOS 14.3.1.

The error appears as soon as I import minim (python -c "import minim").

I've looked into it and indeed, src/minim/__init__.py contains from . import audio, itunes, qobuz, spotify, tidal, utility # noqa: E402 in line 42, and src/minim/audio.py has the following in line 22: from . import utility, FOUND_FFMPEG, FFMPEG_CODECS. FOUND_FFMPEG is defined in __init__.py.

Is it possible to reduce the installation footprint?

It needs more than 100MB of disk space when installed on a Raspberry Pi. Is it possible to reduce that size?

Successfully installed alabaster-0.7.16 anyio-4.3.0 argon2-cffi-23.1.0 argon2-cffi-bindings-21.2.0 arrow-1.3.0 async-lru-2.0.4 attrs-23.2.0 bleach-6.1.0 cffi-1.16.0 comm-0.2.2 coverage-7.5.0 debugpy-1.8.1 decorator-5.1.1 defusedxml-0.7.1 executing-2.0.1 fastjsonschema-2.19.1 fqdn-1.5.1 furo-2024.4.27 greenlet-3.0.3 h11-0.14.0 httpcore-1.0.5 httpx-0.27.0 imagesize-1.4.1 iniconfig-2.0.0 ipykernel-6.29.4 ipython-8.24.0 ipywidgets-8.1.2 isoduration-20.11.0 json5-0.9.25 jsonpointer-2.4 jsonschema-4.22.0 jsonschema-specifications-2023.12.1 jupyter-cache-1.0.0 jupyter-client-8.6.1 jupyter-core-5.7.2 jupyter-events-0.10.0 jupyter-lsp-2.2.5 jupyter-server-2.14.0 jupyter-server-terminals-0.5.3 jupyterlab-4.1.8 jupyterlab-pygments-0.3.0 jupyterlab-server-2.27.1 jupyterlab-widgets-3.0.10 levenshtein-0.25.1 markdown-it-py-3.0.0 matplotlib-inline-0.1.7 mdit-py-plugins-0.4.0 mdurl-0.1.2 mistune-3.0.2 mutagen-1.47.0 myst-nb-1.1.0 myst-parser-3.0.1 nbclient-0.10.0 nbconvert-7.16.4 nbformat-5.10.4 nest-asyncio-1.6.0 notebook-shim-0.2.4 numpydoc-1.7.0 overrides-7.7.0 packaging-24.0 pandocfilters-1.5.1 playwright-1.43.0 pluggy-1.5.0 prometheus-client-0.20.0 prompt-toolkit-3.0.43 pure-eval-0.2.2 pycparser-2.22 pyee-11.1.0 pytest-8.2.0 pytest-base-url-2.1.0 pytest-playwright-0.4.4 python-dateutil-2.9.0.post0 python-json-logger-2.0.7 python-slugify-8.0.4 pyyaml-6.0.1 pyzmq-26.0.2 rapidfuzz-3.8.1 referencing-0.35.0 requests-2.31.0 rfc3339-validator-0.1.4 rfc3986-validator-0.1.1 rpds-py-0.18.0 ruff-0.4.2 send2trash-1.8.3 sniffio-1.3.1 snowballstemmer-2.2.0 sphinx-7.3.7 sphinx-basic-ng-1.0.0b2 sphinx-copybutton-0.5.2 sphinx-togglebutton-0.3.2 sphinxcontrib-applehelp-1.0.8 sphinxcontrib-devhelp-1.0.6 sphinxcontrib-htmlhelp-2.0.5 sphinxcontrib-jsmath-1.0.1 sphinxcontrib-qthelp-1.0.7 sphinxcontrib-serializinghtml-1.1.10 sqlalchemy-2.0.29 stack-data-0.6.3 tabulate-0.9.0 terminado-0.18.1 text-unidecode-1.3 tinycss2-1.3.0 tornado-6.4 traitlets-5.14.3 types-python-dateutil-2.9.0.20240316 typing-extensions-4.11.0 uri-template-1.3.0 wcwidth-0.2.13 webcolors-1.13 websocket-client-1.8.0 widgetsnbextension-4.0.10

What could be safely deleted after installation or from the requirements.txt?

pi@raspberrypi:~ $ du -h minim
64K     minim/.git/hooks
8.0K    minim/.git/info
8.0K    minim/.git/logs/refs/heads
8.0K    minim/.git/logs/refs/remotes/origin
12K     minim/.git/logs/refs/remotes
24K     minim/.git/logs/refs
32K     minim/.git/logs
8.0K    minim/.git/refs/heads
8.0K    minim/.git/refs/remotes/origin
12K     minim/.git/refs/remotes
4.0K    minim/.git/refs/tags
28K     minim/.git/refs
4.0K    minim/.git/branches
4.0K    minim/.git/objects/info
76M     minim/.git/objects/pack
76M     minim/.git/objects
76M     minim/.git
2.3M    minim/assets
268K    minim/docs/notebooks/user_guide
400K    minim/docs/notebooks
2.5M    minim/docs/_modules/minim
2.5M    minim/docs/_modules
72K     minim/docs/source/notebooks/user_guide
148K    minim/docs/source/notebooks
16K     minim/docs/source/_templates/autosummary
20K     minim/docs/source/_templates
100K    minim/docs/source/api
296K    minim/docs/source
140K    minim/docs/_static/styles
44K     minim/docs/_static/scripts
416K    minim/docs/_static
72K     minim/docs/_sources/notebooks/user_guide
148K    minim/docs/_sources/notebooks
112K    minim/docs/_sources/api
276K    minim/docs/_sources
3.2M    minim/docs/api
152K    minim/docs/.doctrees/notebooks/user_guide
304K    minim/docs/.doctrees/notebooks
6.0M    minim/docs/.doctrees/api
12M     minim/docs/.doctrees
19M     minim/docs
7.8M    minim/tests/data/previews
916K    minim/tests/data/samples
8.7M    minim/tests/data
8.8M    minim/tests
8.0K    minim/.github/workflows
12K     minim/.github
912K    minim/src/minim
916K    minim/src
106M    minim

Is it OK to use requirements_minimal.txt instead of requirements.txt?

Thank you!

zsh: number expected

Hello, I'm just getting started using minim, but I tried to install via both venv and virtualenv and when I run scopes = spotify.WebAPI.get_scopes("all") I get the following:

zsh: number expected

My zsh version is 5.9.

And when I tried installing minim without a virtual environment and run python3 minim -v I get:

python3 minim -v
/Library/Frameworks/Python.framework/Versions/3.12/bin/python3: can't find '__main__' module in '/Users/username/minim/minim'

What am I doing wrong? Thanks!

P.S. Sorry, I would open a discussion as I know this isn't necessarily a bug, but Discussions aren't enabled.

Recent changes in the Tidal API?

Hello, I tried invoking the Tidal Private APIs that your library provides but keep getting 404 or 400 errors. I picked apart the code and invoked the backing APIs directly with curl but got similar results. Do you know if these APIs are still active? Namely I want to modify my favorite tracks

Tidal Private API authentication error

Getting an error on Tidal's web player when trying to authenticate saying "Error
Something went wrong. Please try again. If the error persists, contact customer support."

Tried with and without the browser.

client_tidal = tidal.PrivateAPI(client_id=os.getenv('TIDAL_CLIENT_ID'), client_secret=os.getenv('TIDAL_CLIENT_SECRET'), flow="pkce", browser=False)

Getting Tidal API Link

When i login through tidal with the PKCE flow, i dont understand how to do this step:

After authorizing Minim to access TIDAL on your behalf, copy and paste the URI beginning with 'tidal://login/auth' below.

Because my browser just shows me this:

Where do I copy it from?
Thank you

Future Plans, Collaboration, and Integration Questions

Dear Benjamin,

I'm planning to develop a comprehensive music app.
I am happy to have discovered your library and am intending to incorporate it in my project.

The app would integrate several online sources and local files and it would include a local database of all account data (playlists, favourites, etc) and have several unique features.

I have some questions about minim so I can plan my development better.

  1. Is there a plan to integrate YouTube as well? And if not, would you help me extend your library with that capability?
  2. What's the general plan with minim? Will it be maintained actively indefinitely? What are your plans with it?
  3. Would you like to have a say in the design of my app? Since minim will be the backbone of it, I figure it'd make sense to include you, if that'd be of your interest, of course.

Thank you and kind regards,
Klemen

SyntaxWarnings in file spotify.py

The Python 3.12.3 shows warnings in file spotify.py:

>>> from minim.spotify import WebAPI
/home/pi/minim/src/minim/spotify.py:785: SyntaxWarning: invalid escape sequence '\?'
  re.search(f'{self._redirect_uri}\?(.*?)"',
/home/pi/minim/src/minim/spotify.py:1153: SyntaxWarning: invalid escape sequence '\d'
  self._port = re.search("localhost:(\d+)",

NameError: name 'Session' is not defined

Hello bbye98
Thanks for Your great job.
Which API are you using?
I've just contacted the qobuz team today for another issue and they told me there is no open API for security reasons.
That said. I am trying your module.
It does not load, with the following traceback:

File "", line 1, in
File "/archivi/Downloads/minim/src/minim/qobuz.py", line 1635, in
class Album:
File "/archivi/Downloads/minim/src/minim/qobuz.py", line 1776, in Album
session: Session = None, **kwargs):
^^^^^^^
NameError: name 'Session' is not defined

Having a quick look, I can't find any

class Session

defined in qobuz.py.

Regards, and thank You

Minim 1.0.0 release

There are a few ambitious overhauls I'd like to do before the 1.0.0 release of Minim:

General

  • Update documentation to have consistency between the different submodules, with the Spotify one being used as a baseline.
  • Shorten repository README by moving most of the usage and installation instructions to the documentation and adding simple examples of the existing APIs.
  • Enable continuous integration via GitHub Actions.
  • Add user guides to showcase how Minim can be used: editing audio metadata, getting recommendations, and transferring music libraries.
  • Add the Gestalt or Ratcliff–Obershelp ratio from difflib.
  • Enforce rate limits for all APIs.

Audio

  • Rewrite the from_<service> methods for the updated Spotify, TIDAL, and Qobuz APIs.

Discogs

  • Finish implementation.

iTunes

  • Wrap endpoints in the minim.itunes.SearchAPI class.
  • Add response status code checking.
  • Add sample responses from endpoints.

Qobuz

  • Add sample responses from endpoints.
  • Implement client credential storage.
  • Gracefully deprecate/remove Qobuz objects. (Ultimately, this doesn't fall in line with what I envision Minim to be--a simple interface to interact with music service APIs.)
  • Write unit tests for endpoints that do not require authentication.

Spotify

  • Refactor Spotify Web API OAuth 2.0 authorization flows.
  • Add Playwright authentication route for minim.spotify.PrivateLyricsService.
  • Implement client credential storage.
  • Fix/enhance logic for storing/updating Spotify client credentials.
  • Write unit tests for endpoints that do not require authentication.

TIDAL

  • Add support for the new open TIDAL API.
  • Add sample responses from endpoints for the new open TIDAL API.
  • Implement client credential storage for the new open TIDAL API.
  • Refactor the existing private TIDAL API.
  • Add sample responses from endpoints for the existing private TIDAL API.
  • Implement client credential storage for the existing private TIDAL API.
  • Figure out which clients can use which authorization flows.
  • Figure out which endpoints are enabled by the three possible authorization scopes.
  • Write unit tests for endpoints that do not require authentication.

Planned for future release(s)

  • Add support for more APIs, like the Amazon Music, Beatport, Deezer, Discogs, Last.fm, MusicBrainz, SoundCloud, and YouTube Music APIs.
  • Maybe add asynchronous I/O for certain endpoints using asyncio?

Some questions

Hi,

Thanks a lot for this library!
Here are some questions and proposals.

  • The library doesn't work with Python 3.7.4 which I'm currently using. I think if you remove type declarations from functions' input and output parameters it will work with any Python version. This is what I did to make it working.
  • When you create a Qobuz session without user credentials you get some app_id and app_secret from the downloaded JavaScript. The process takes some time because the script is pretty large - several MBs. To avoid that delay I'm thinking to hard code the current values and wondering for how long they will be valid/working?
  • How can I search Qobuz service by Album name? How can I find info about Artists? Which 'type' should be specified in this case?
  • IMHO the Qobuz search function should be smart enough to know which result to return. If you search for tracks it should return tracks, if you search for albums it should return albums etc. Or maybe create alternative search functions like smart_search to avoid processing/filtering search results.

Best regards

Spotify Access token expired

i'm trying to use Minim on a headless server, running a cron job for updating my dynamic Spotify playlists to Qobuz.
The authentication for Qobuz is working, but i'm experiencing issues with the Spotify Auth.

how can i use the refresh token to generate a new access token when the old one expires?

code i have so far, which allows me to update spotify to qobuz (but where the access token expires after 1 hour )

SPOTIFY_CLIENT_ID = "<spotify_clientid>"
SPOTIFY_CLIENT_SECRET = "<spotify_client_secret>"
SPOTIFY_ACCESS_TOKEN = "<spotify_access_token>"
SPOTIFY_REFRESH_TOKEN = "<spotify_refresh_token>"
SPOTIFY_REDIRECT_URL = "http://localhost:8888/callback"

scopes = spotify.WebAPI.get_scopes("all")
client_spotify = spotify.WebAPI(client_id=SPOTIFY_CLIENT_ID, client_secret=SPOTIFY_CLIENT_SECRET, flow="pkce",
                                scopes=scopes, web_framework="http.server")

using the access_token and refresh token in unfortunately does not work

client_spotify = spotify.WebAPI(client_id=SPOTIFY_CLIENT_ID, client_secret=SPOTIFY_CLIENT_SECRET, flow="pkce",
                                scopes=scopes, web_framework="http.server", access_token=SPOTIFY_ACCESS_TOKEN, 
                                refresh_token=SPOTIFY_REFRESH_TOKEN, redirect_uri=SPOTIFY_REDIRECT_URL)

Qobuz: "album-of-the-week" is not supported

There is the following error if you use it:

{'status': 'error', 'code': 400, 'message': 'Invalid argument: type (accepted values are 
most-streamed, best-sellers, new-releases, press-awards, editor-picks, most-featured, 
harmonia-mundi, universal-classic, universal-jazz, universal-jeunesse, universal-chanson, 
new-releases-full, recent-releases, ideal-discography, qobuzissims)'}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.