This is a library of helper functions that allows users to process images in Spotify.
Some tasks that it performs include:
-
process_user_profile_pic: extracts user profile picture given its html
-
get_public_playlists_albums: extracts all public playlist album covers from a user's html page
-
get_individual_album_covers_from_mosaic: extracts four individual cover photos from a mosaic cover photo
-
get_playlist_profile_pic: extracts the profile picture from a playlist
-
process_artist_album: extracts all the album covers of an artist
-
make_request: accepts a html string and requests a session with the html with a response code
-
get_soup: accepts the return object from make_request and parses into content acceptable in tasks 1-5
-
filter_all_other_color: gets rid of all the color (BGR) that is not within a certain range and save those that are
-
filter_this_color: filters the color (BGR) within a specific range and save those that aren't
-
smooth_img: smoothes and blurs the image. Without the parameter threshold, it will default to (5, 5)
-
return_most_common_color: returns the most common color (BGR) and its count in a picture
-
overlay_two_images: overlays two images with the same size on top of each other. Can change the weight of each image.
-
Install the library by running: pip install SpotifyPictureHelper
-
Import the library in Python by including from SpotifyPictureHelper import main
The following are commands included in the Makefile:
make develop: install the library's dependencies usingpipmake build: build the library usingsetuptoolsmake lint: perform static analysis of this library withblackandflake8make format: autoformat this library withblackmake test: run automated tests withpytestmake coverage: run automated tests withpytestand collect coverage information (passes with coverage >50%)make clean: cleans the repo
- To start: Call get_soup(make_request('https://open.spotify.com/user/rosycarina')) to get the BeautifulSoup object from a html page
- process_user_profile_pic(get_soup(make_request('https://open.spotify.com/user/rosycarina'))) will return the user profile picture
- get_public_playlists_albums(get_soup(make_request('https://open.spotify.com/user/rosycarina'))) will return all the album covers of the user's public playlists
- get_individual_album_covers_from_mosaic('https://mosaic.scdn.co/300/ab67616d00001e022a6ab83ec179747bc3b190dcab67616d00001e02335534788cbc39cfd23ee993ab67616d00001e02d6df3bccf3ec41ea2f76debcab67616d00001e02f0855ff71aa79ab842164fc6') will return the four individual images from this mosaic image
- get_playlist_profile_pic(get_soup(make_request('https://open.spotify.com/playlist/6snlZhdBpJK0cxYURvqhFU?si=8e7eb1f3db5f438b&nd=1'))) will return the profile pic of this playlist
- process_artist_album(get_soup(make_request('https://open.spotify.com/artist/06HL4z0CvFAxyc27GXpf02'))) will return all the artist albums on the artist page.
- filter_all_other_color("SpotifyPictureHelper/tests/test2.png", (0, 0, 0), (25, 25, 25)) leaves the image with pixels that fall between (0, 0, 0) and (25, 25, 25)
- filter_this_color("SpotifyPictureHelper/tests/test2.png", (0, 0, 0), (25, 25, 25)) filters all pixels that fall between (0, 0, 0) and (25, 25, 25)
- smooth_img("SpotifyPictureHelper/tests/test2.png") will smooth the image with the kernel size (5,5)
- return_most_common_color("SpotifyPictureHelper/tests/test2.png") will return the most common color in this image file
- overlay_two_images("SpotifyPictureHelper/tests/test2.png", "SpotifyPictureHelper/tests/blackWhite.png", 0.5, 0.5) will return a blended image with the first image weighing 50% and the second image weighing also 50%