Skip to main content

This project port "@TooTallNate/spotify-uri" to Python.

Project description

pyspotify-uri

LICENSEpyversionsUpload PyPI

This project port "@TooTallNate/spotify-uri" to Python.

Parse and format the various Spotify URI formats

Spotify URIs get passed around in a variety of flavors.
You can also convert them back into Spotify URIs or HTTP URLs.

Installation

pip install spotify-uri

Example

import spotify_uri

# parse Spotify URIs or HTTP URLs:

parsed = spotify_uri.parse("spotify:track:3GU4cxkfdc3lIp9pFEMMmw")
print(parsed.__dict__)
# {
#     'type': 'track', 
#     'id': '3GU4cxkfdc3lIp9pFEMMmw', 
#     'uri': 'spotify:track:3GU4cxkfdc3lIp9pFEMMmw'
# }

parsed = spotify_uri.parse("http://open.spotify.com/track/1pKYYY0dkg23sQQXi0Q5zN")
print(parsed.__dict__)
# {
#     'type': 'track', 
#     'id': '1pKYYY0dkg23sQQXi0Q5zN', 
#     'uri': 'http://open.spotify.com/track/1pKYYY0dkg23sQQXi0Q5zN'
# }


# you can also format the parsed objects back into a URI or HTTP URL:

uri = spotify_uri.formatURI("http://open.spotify.com/track/1pKYYY0dkg23sQQXi0Q5zN")
print(uri)
# spotify:track:1pKYYY0dkg23sQQXi0Q5zN

uri = spotify_uri.formatOpenURL("spotify:track:3GU4cxkfdc3lIp9pFEMMmw")
print(uri)
# http://open.spotify.com/track/3GU4cxkfdc3lIp9pFEMMmw

uri = spotify_uri.formatPlayURL("spotify:track:3GU4cxkfdc3lIp9pFEMMmw")
print(uri)
# https://play.spotify.com/track/3GU4cxkfdc3lIp9pFEMMmw

uri = spotify_uri.formatEmbedURL("spotify:track:3GU4cxkfdc3lIp9pFEMMmw")
print(uri)
# https://embed.spotify.com/?uri=spotify:track:3GU4cxkfdc3lIp9pFEMMmw

License

Distributed under the MIT License:

Copyright © 2021 Euiseo Cha

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

spotify_uri-1.0.3.tar.gz (6.9 kB view details)

Uploaded Source

Built Distribution

spotify_uri-1.0.3-py3-none-any.whl (9.4 kB view details)

Uploaded Python 3

File details

Details for the file spotify_uri-1.0.3.tar.gz.

File metadata

  • Download URL: spotify_uri-1.0.3.tar.gz
  • Upload date:
  • Size: 6.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.5.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.9.5

File hashes

Hashes for spotify_uri-1.0.3.tar.gz
Algorithm Hash digest
SHA256 8140b45c222b4a0dcac4b47e47058cb3c0942853f5cdfe65cbe3b1f87a099024
MD5 aea1b3433224b5caaf685402ba535d77
BLAKE2b-256 db749a98d53baea4d2b7d2a99e958446b06c9d8ce9faffa5c3209ed376337859

See more details on using hashes here.

File details

Details for the file spotify_uri-1.0.3-py3-none-any.whl.

File metadata

  • Download URL: spotify_uri-1.0.3-py3-none-any.whl
  • Upload date:
  • Size: 9.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.5.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.9.5

File hashes

Hashes for spotify_uri-1.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 1830e0f74d578c7b30bbc15a016ee7d29233a0461782f27c194cdf1b4fd562a5
MD5 7c40a97ceaca8d8626628f57c4692d54
BLAKE2b-256 f48b7bee5c6df7cc6f391d4af3041ffb60e47d6898095cf8d477ebfc5d8e2d39

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page