Skip to main content

spotify-flask-downloader

A Flask Based Backend To Search And Download Music From Spotify.

This is a little flask based backend to download music from YouTube by searching in Spotify, based on your network requests.

Install

pip3 install spotify-flask-downloader

Dependencies

Project Maintainer
flask pallets
flask-cors corydolphin
youtube-dl ytdl-org
youtube-search-python alexmercerind

Like the module?

Consider starring the repository. Feel free to use.

Feel free to open issue, in case you find one.

Usage

Start the server

Execute this script and let it run in the background as you play with this module.

from spotifyflaskdownloader import SpotifyFlaskDownloader

downloader = SpotifyFlaskDownloader("SPOTIFY-CLIENT-ID", "SPOTIFY-CLIENT-SECRET", 5000)

You can use something like requests or urllib to access this flask server.

Search for Music

import requests
response = requests.get(
    "http://localhost:5000/search",
    params= {
        "keyword": "Faded Alan Walker",    #Search Query
        "mode": "track",                   #Default is "album", Supports "album" & "track"
        "offset": 0,                       #Default is 0
        "limit": 1                         #Default is 50
    }
)
print(response.json())
  • Response
{
    "tracks": [
        {
            "track_id": "7gHs73wELdeycvS48JfIos",
            "track_name": "Faded",
            "track_artists": [
                "Alan Walker"
            ],
            "track_number": 1,
            "track_duration": 212626,
            "album_id": "5HMjpBO0v78ayq5lreAyDd",
            "album_name": "Faded",
            "year": "2015",
            "album_artists": [
                "Alan Walker"
            ],
            "album_art_640": "https://i.scdn.co/image/ab67616d00001e02c4d00cac55ae1b4598c9bc90",
            "album_art_300": "https://i.scdn.co/image/ab67616d0000b273c4d00cac55ae1b4598c9bc90",
            "album_art_64": "https://i.scdn.co/image/ab67616d00004851c4d00cac55ae1b4598c9bc90",
            "album_length": 4,
            "album_type": "single"
        }
    ]
}

Save Track To Device

import requests
response = requests.get(
    "http://localhost:5000/savetrack",
    params= {
        "track_id": "7gHs73wELdeycvS48JfIos"
    }
)
print(response.json())
  • Response
Downloading...
It saves the track to %userprofile%\.ReactMusic\Library

Get "Save Track To Device" Status

import requests
response = requests.get(
    "http://localhost:5000/savetrackstatus"
)
print(response.json())
  • Response

  • True

    • If no track is being downloaded and you can download a track.
  • False

    • If a track is being downloaded and you have to wait, until response becomes True
import requests
response = requests.get(
    "http://localhost:5000/trackdownload",
    params= {
        "track_id": "7gHs73wELdeycvS48JfIos"    #Alternatively you can provide "track_name" in place of "track_id"
    }
)
print(response.json())
  • Response
{
    "download_url": "https://r8---sn-gwpa-5bgs.googlevideo.com/videoplayback?expire=1594409257&ei=yWwIX_3rNJOWvQSFwI5A&ip=2409%3A4053%3A2196%3Ad6fa%3Ac8bf%3Ab2d8%3A81bb%3Aad05&id=o-AE3zCFHWH5aAUBwVqKVBijX3Vjd9xf4LSZ5uyIa8l2qY&itag=249&source=youtube&requiressl=yes&mh=Hp&mm=31%2C29&mn=sn-gwpa-5bgs%2Csn-gwpa-qxa6&ms=au%2Crdu&mv=m&mvi=8&pl=36&initcwndbps=175000&vprv=1&mime=audio%2Fwebm&gir=yes&clen=1360728&dur=212.501&lmt=1576159977750934&mt=1594387597&fvip=8&keepalive=yes&c=WEB&txp=5531432&sparams=expire%2Cei%2Cip%2Cid%2Citag%2Csource%2Crequiressl%2Cvprv%2Cmime%2Cgir%2Cclen%2Cdur%2Clmt&lsparams=mh%2Cmm%2Cmn%2Cms%2Cmv%2Cmvi%2Cpl%2Cinitcwndbps&lsig=AG3C_xAwRAIgP_4WHdnJO0h1wde12DLTcrfAQ8ShLLIezFkfO0AjRdoCIBqTZqhOP8kp7amBJObCMzKNJ_vzXZdvJcnY8j4PTAm0&sig=AOq0QJ8wRgIhAJe-DBmBKmfBx8dJcoKyp_WCeXg3Q3WKfxAvw4ztUwbVAiEApLFfh9DK9rRkkSRDSqPhXgUXdtStDUZOok2gxzEHhTY=&ratebypass=yes"
}

Get Track Info

import requests
response = requests.get(
    "http://localhost:5000/trackinfo",
    params= {
        "track_id": "7gHs73wELdeycvS48JfIos",
    }
)
print(response.json())
  • Response
{
    "track_id": "7gHs73wELdeycvS48JfIos",
    "track_name": "Faded",
    "track_artists": [
        "Alan Walker"
    ],
    "track_number": 1,
    "track_duration": 212626,
    "album_art_640": "https://i.scdn.co/image/ab67616d00001e02c4d00cac55ae1b4598c9bc90",
    "album_art_300": "https://i.scdn.co/image/ab67616d0000b273c4d00cac55ae1b4598c9bc90",
    "album_art_64": "https://i.scdn.co/image/ab67616d00004851c4d00cac55ae1b4598c9bc90",
    "album_id": "5HMjpBO0v78ayq5lreAyDd",
    "album_name": "Faded",
    "year": "2015",
    "album_artists": [
        "Alan Walker"
    ],
    "album_length": 4,
    "album_type": "single"
}

Get Tracks Of An Album

import requests
response = requests.get(
    "http://localhost:5000/albuminfo",
    params= {
        "album_id": "5HMjpBO0v78ayq5lreAyDd",
    }
)
print(response.json())
  • Response
{
    "tracks": [
        {
            "track_id": "7gHs73wELdeycvS48JfIos",
            "track_name": "Faded",
            "track_artists": [
                "Alan Walker"
            ],
            "track_number": 1,
            "track_duration": 212626
        },
        {
            "track_id": "0HmONWWIU1FXkwWLDpqrjl",
            "track_name": "Faded - Instrumental",
            "track_artists": [
                "Alan Walker"
            ],
            "track_number": 2,
            "track_duration": 214013
        },
        {
            "track_id": "34F4GJFUzPvPJmGrTpyqlZ",
            "track_name": "Faded (Restrung)",
            "track_artists": [
                "Alan Walker"
            ],
            "track_number": 3,
            "track_duration": 217053
        },
        {
            "track_id": "0RLjnX1vYWvtdThB8LABwo",
            "track_name": "Faded - Piano Version",
            "track_artists": [
                "Alan Walker"
            ],
            "track_number": 4,
            "track_duration": 215080
        }
    ]
}

Search On YouTube

import requests
response = requests.get(
    "http://localhost:5000/searchyoutube",
    params= {
        "keyword": "Faded Alan Walker",    #Search Query
        "mode": "json",                    #Default is "json", Supports "json", "list" & "dict"
        "offset": 1,                       #Default is 1
        "max_results": 1                   #Default is 1
    }
)
print(response.json())
  • Response
{
    "search_result": [
        {
            "index": 0,
            "id": "60ItHLz5WEA",
            "link": "https://www.youtube.com/watch?v=60ItHLz5WEA",
            "title": "Alan Walker - Faded",
            "channel": "Alan Walker",
            "duration": "3:33",
            "views": 2806875809,
            "thumbnails": [
                "https://img.youtube.com/vi/60ItHLz5WEA/default.jpg",
                "https://img.youtube.com/vi/60ItHLz5WEA/hqdefault.jpg",
                "https://img.youtube.com/vi/60ItHLz5WEA/mqdefault.jpg",
                "https://img.youtube.com/vi/60ItHLz5WEA/sddefault.jpg",
                "https://img.youtube.com/vi/60ItHLz5WEA/maxresdefault.jpg"
            ]
        }
    ]
}

Metadata

Release files for spotify-flask-downloader 0.0.2

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

Source distribution (sdist)

Source distribution for spotify-flask-downloader 0.0.2
File Size Uploaded Provenance
spotify-flask-downloader-0.0.2.tar.gz 7.1 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for spotify-flask-downloader 0.0.2
File Interpreter ABI Platform
spotify_flask_downloader-0.0.2-py3-none-any.whl Python 3 none any Details

Total release size: 15.4 kB

Release files / spotify-flask-downloader-0.0.2.tar.gz

Download URL spotify-flask-downloader-0.0.2.tar.gz
Size 7.1 kB
Tags Source
SHA-256 checksum
How to use checksums
436944a1076128966b45814142ad26e352374a29e488c583e02d0fa047dc1248
BLAKE2b-256 checksum
How to use checksums
fb04c7cfbd6ad311530b42969a6e5039c0e2451d88189376e643b696b9d39b86
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.3.2 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.8.0

Release files / spotify_flask_downloader-0.0.2-py3-none-any.whl

Download URL spotify_flask_downloader-0.0.2-py3-none-any.whl
Size 8.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1fac8cbd79c58e685dcfbd3a051b0f8afac0569667234bbced927015736056dc
BLAKE2b-256 checksum
How to use checksums
fbfb93b342ebc204783ec9cf989c8b0845f99028971a50a800cb1c55d7270be3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.3.2 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.8.0

Security for spotify-flask-downloader 0.0.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Release history Release notifications | RSS feed

This release

0.0.2 This release

2 release files No provenance

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