Code Monkey home page Code Monkey logo

spotifyscraper's Introduction

Build Status Documentation Status

Spotify Scraper

Overview

Python Spotify Web Player Scraper, a fast high-level Spotify Web Player Scraper, to scrape and extract data from Spotify Web Player with the most efficient and fastest methods. instead of using Selenium, I used requests library to increase the speed of scraping. You can set cookies, headers and proxy and download the cover and preview mp3 song of Spotify songs beside the scraping.

Requirements

  • Python 3.6 +
  • Works on Linux, Windows, macOS, BSD
  • Internet connection

Installing

You can install this package as simple as type a command in your CMD or Terminal. The quick way:

$ pip install -U spotifyscraper

or do it in the hard way:

$ git clone https://github.com/AliAkhtari78/SpotifyScraper.git
$sudo python setup.py install

Documentation

Check out Read The Docs for a more in-depth explanation, with examples, troubleshooting issues, and more useful information.

Extract Spotify track information by URL

  • from SpotifyScraper.scraper import Scraper, Request

Import SpotifyScraper to use it

  • request = Request().request()

Create requests using Request which was imported before, You can also pass cookie_file, header and proxy inside Request(). Default is None.

  • print(Scraper(session=request).get_track_url_info(url='https://open.spotify.com/track/7wqpAYuSk84f0JeqCIETRV?si=b35Rzak1RgWvBAnbJteHkA'))

Call get_track_url_info function from Scraper to extract all the infromation from url. If the given URL is valid, it will return a dict with the below keys:

  • title
  • preview_mp3
  • duration
  • artist_name
  • artist_url
  • album_title
  • album_cover_url
  • album_cover_height
  • album_cover_width
  • release_date
  • total_tracks
  • type_
  • ERROR
  • $ { 'title': 'The Future Never Dies', 'preview_mp3': 'https://p.scdn.co/mp3-preview/2d706ceae19cfbc778988df6ad5c60828dbd8389?cid=a46f5c5745a14fbf826186da8da5ecc3', 'duration': '4:3', 'artist_name': 'Scorpions', 'artist_url':'https://open.spotify.com/artist/27T030eWyCQRmDyuvr1kxY', 'album_title': 'Humanity Hour 1', 'album_cover_url':'https://i.scdn.co/image/ab67616d0000b273e14019d431204ff27785e349', 'album_cover_height': 640, 'album_cover_width': 640, 'release_date': '2007-01-01', 'total_tracks': 12, 'type_': 'album', 'ERROR': None}

Extract Spotify playlist information by URL

  • from SpotifyScraper.scraper import Scraper, Request

  • request = Request().request()

  • playlist_info = Scraper(session=request).get_playlist_url_info(url='https://open.spotify.com/playlist/37i9dQZF1DX74DnfGTwugU')

Call get_playlist_url_info function from Scraper to extract all the infromation from url. If the given URL is valid, it will return a dict with the below keys:

  • album_title
  • cover_url
  • author
  • author_url
  • playlist_description
  • tracks_list
  • ERROR

Download Spotify song cover by URL

  • from SpotifyScraper.scraper import Scraper, Request

  • request = Request().request()

  • path = Scraper(session=request).download_cover(url='https://open.spotify.com/track/7wqpAYuSk84f0JeqCIETRV?si=b35Rzak1RgWvBAnbJteHkA')

Call download_cover function from Scraper to download the cover of the provided song.

if the provided URL is valid, it will return the path of downloaded cover to you.

Download Spotify preview song by URL

  • from SpotifyScraper.scraper import Scraper, Request

  • request = Request().request()

  • path = Scraper(session=request).download_preview_mp3(url='https://open.spotify.com/track/7wqpAYuSk84f0JeqCIETRV?si=b35Rzak1RgWvBAnbJteHkA')

Call download_preview_mp3 function from Scraper to download the preview mp3 song of the provided URL.

if the provided URL is valid, it will return the path of downloaded mp3 to you.

Get in touch

  • Report bugs, suggest features, or view the source code on GitHub.
  • Read the doc to use all provided functions of this library.
  • get in touch with me by my website: Ali Akhtari

spotifyscraper's People

Contributors

aliakhtari78 avatar

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  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  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

spotifyscraper's Issues

Error thrown on pip install

When running pip install spotifyscraper after never having installed the package, I get an error which fails the install.

Steps to reproduce the behavior:

  1. Open a cmd on windows 10 (probably all OSes though) without spotifyscraper installed on it
  2. run pip install spotifyscraper
  3. See error

Normally it should be installed, it is not
image

  • OS: Windows 10 home
  • Browser: None used
  • Version [Python 3.11.1]

Issue with Extract Spotify Playlist Informations

Getting {'ERROR': 'The provided url is malformed.'} message when I try to extract
any playlist URL. Even using the example in github I faced the same issue.

To Reproduce
Steps to reproduce the behavior:
url = 'https://open.spotify.com/playlist/34pAXwKX0zTQc2ZTgSxyEq'
from SpotifyScraper.scraper import Scraper, Request
request = Request().request()
scraper = Scraper(session=request, log=True)
playlist_information = scraper.get_playlist_url_info(url=url)
print(playlist_information)

Expected behavior
It list down the tracks in the playlist

Screenshots
N/A

Desktop (please complete the following information):

  • OS: [e.g. iOS] Windows 10
  • Browser [e.g. chrome, safari] chrome
  • Version [e.g. 22] 84.0.4147.135

Additional context
I'm a new user, no experience using the SpotifyScraper before

Support for albums?

Would support for albums be possible rather than just individual songs and playlists?

Only download the information for first 30 songs for a playlist.

Describe the bug
get_playlist_url_info() only download first 30 songs (first page?) for a given playlist. My playlist has 192 songs, and this function only downloaded the information for first 30 songs.

To Reproduce
Steps to reproduce the behavior:

from SpotifyScraper.scraper import Scraper, Request
request = Request().request()
s = Scraper(session=request)
url='https://open.spotify.com/playlist/37i9dQZF1DXebGqmpCVcEO?si=DWloNa88RcGyoyaxzfb1Lw'
pl = s.get_playlist_url_info(url=url)
print( len(pl['tracks_list']))   
#  The result here is 30 or 31.
  1. Use the same URL on browser, you can see 50 songs
  2. Scroll down you can see all other songs.

Expected behavior
Expected all 50 songs in pl variable, not first 30.

Screenshots
Not applicable.

Desktop (please complete the following information):

  • OS: [e.g. iOS]
  • Browser [e.g. chrome, safari]
  • Version [e.g. 22]

Smartphone (please complete the following information):

  • Device: VM
  • OS: Linux ubuntu 4.15.0-106-generic #107~16.04.1-Ubuntu SMP x86_64
  • Browser: Google Chrome Version 83.0.4103.116 (Official Build) (64-bit)
  • Version: Python 3.6.10 :: Anaconda, Inc.

Additional context
None

Artist info

Is there any solution to get artist information, monthly listener & follower, popular playcount on artist track?

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.