Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for Spotify web player #13

Closed
wants to merge 45 commits into from

Conversation

JamesVStone
Copy link

@JamesVStone JamesVStone commented Dec 8, 2019

I have added methods to communicate track information from the chrome extension here.

This relies on this pull request being merged into the chrome extension. here.

@pep8speaks
Copy link

pep8speaks commented Dec 8, 2019

Hello @JamesVStone! Thanks for updating this PR.

There are currently no PEP 8 issues detected in this Pull Request. Cheers! 🍻

Comment last updated at 2019-12-26 13:58:16 UTC

@codecov
Copy link

codecov bot commented Dec 8, 2019

Codecov Report

❗ No coverage uploaded for pull request base (master@7e1c8d8). Click here to learn what that means.
The diff coverage is 60%.

Impacted file tree graph

@@            Coverage Diff            @@
##             master      #13   +/-   ##
=========================================
  Coverage          ?   65.54%           
=========================================
  Files             ?        3           
  Lines             ?      119           
  Branches          ?       11           
=========================================
  Hits              ?       78           
  Misses            ?       37           
  Partials          ?        4
Impacted Files Coverage Δ
SwSpotify/spotify_web.py 54.28% <54.28%> (ø)
SwSpotify/spotify.py 76.62% <80%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 7e1c8d8...abea4d7. Read the comment docs.

@aadibajpai
Copy link
Member

You've bundled the extension here as well?

@aadibajpai
Copy link
Member

Additionally, can you explain exactly how everything works so it is easier and faster to review?

@JamesVStone
Copy link
Author

JamesVStone commented Dec 8, 2019

sure! Right so my solution consists of two pull requests (this one and one to the chrome extension which was referenced in the description).

NOTE: the extension is not here I have created a second pull request at here

@aadibajpai

How it works

I have added a file called web_player.py which spawns a web server which will last for 2 seconds or until it receives a post request from the chrome plugin.

This data is than passed to get_info_chrome method which allows the track and artist collected from Spotify Web Player to be included in the SwSpotify library.

My modification to the chrome plugin makes it send the data more frequently so we can capture it more efficiently in this program.

Tests

I still need to improve coverage of the new code which I have added as the bot is telling me.

As for functionality it should work on all supported platforms (Windows, Mac and Linux).

I have tested it progressively with SwagLyrics which works with the new version of my program. It successfully gets the track information and collects the lyrics!

@JamesVStone JamesVStone marked this pull request as ready for review December 10, 2019 20:19
@JamesVStone
Copy link
Author

@aadibajpai All finished. Fully threaded implementation which has timeout and memory safe fallback to complete. Apologies for my early submission. There are no dangling threads in the latest commit.

@JamesVStone
Copy link
Author

To clarify this PR requires on these changes to the chrome extension.

Copy link
Member

@aadibajpai aadibajpai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's a lot going on in the web_player file, can you explain it a bit? Also, a server is spawned every time get_info_web() is called and it keeps running until it receives a request from the extension?

SwSpotify/spotify.py Outdated Show resolved Hide resolved
SwSpotify/spotify.py Outdated Show resolved Hide resolved
SwSpotify/spotify.py Outdated Show resolved Hide resolved
SwSpotify/spotify_web.py Outdated Show resolved Hide resolved
@aadibajpai
Copy link
Member

You should aim to fully cover testing spotify_web.py especially since it's being added newly and we want it to be future proof. A good way to write tests is to imagine the flow of control and structure tests accordingly. The existing testsuite for the other functions should give you an insight 🙂

@aadibajpai
Copy link
Member

@JamesVStone let me know when it's ready for review

@JamesVStone JamesVStone reopened this Dec 14, 2019
@JamesVStone
Copy link
Author

acc clicked comment and close :/

@aadibajpai
Copy link
Member

acc clicked comment and close :/

no worries 😄

@JamesVStone
Copy link
Author

Update

The program is now completely synchronous and does not need threading to work. As a result, the program now works better as I have seen in concurrency diagrams. In addition, I have refactored some of the identifier names and improved the interface between the files. I have removed some tests and added some more meaningful and ones that actually prove that the program works (as opposed to just adding coverage).

This is how the programs works now:

  • attempts native connection
  • when this fails it calls get_info_web
  • get info web spawns web server synchronously
  • if the server times out then it will return None and `get_info_web' will raise spotifyClosed
  • On the other hand, If data has been received it will output the respective values

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants