mpolden / nrk-spotify Goto Github PK
View Code? Open in Web Editor NEWListen to NRK radio channels in Spotify
License: MIT License
Listen to NRK radio channels in Spotify
License: MIT License
Set a timeout for HTTP requests, so that we don't wait forever for slow requests.
See Timeout
in http.Client
: http://golang.org/pkg/net/http/#Client
In some cases duplicate tracks might be added to the playlist.
This happens because failed requests are retried and Spotify sometimes returns 504 even if a request succeeds.
Example:
2014/08/04 08:49:12 Running sync
2014/08/04 08:49:12 NRK P3 Pyro is currently playing: Extreme - Decadence Dance (03:45/06:48) [======----]
2014/08/04 08:49:12 Searching for: Extreme - Decadence Dance
2014/08/04 08:49:12 Already added: Decadence Dance (4nJVAkLR6nd6cX5BmOuDmx)
2014/08/04 08:49:12 Searching for: Saxon - 747 (Strangers in the Night)
2014/08/04 08:49:15 Add track failed: request failed (504):
2014/08/04 08:49:15 Retrying...
2014/08/04 08:49:16 Added track: 747 (Strangers in the Night) - 2009 - Remaster (1EORu8Coheibl21VjHtbRg)
2014/08/04 08:49:16 Cache size: 100/100
2014/08/04 08:49:16 Next sync in 5m0s
In the above example the track 747 (Strangers in the Night) is added twice.
Spotify API docs recommend using snapshot_id
when removing tracks from a playlist.
Currently tracks will be added to the Spotify playlist until the playlist limit is reached.
This is because Spotify did not initially provide methods for removing tracks, but a method for setting tracks has now been added: https://developer.spotify.com/set-playlists-tracks/
Add a parameter which specifies if the playlist size should reflect the cache size. Then use the new method to stay within this limit. The cache can then be used to keep track of URIs which should be (re)set.
If adaptive interval is enabled it should consider if the track was added when determining the next interval.
2014/08/05 09:04:42 Running sync
2014/08/05 09:04:42 NRK P3 Pyro is currently playing: Tool - Lateralis (04:48/09:22) [======----]
2014/08/05 09:04:42 Searching for: Tool - Lateralis
2014/08/05 09:04:43 Track not found: Tool - Lateralis
2014/08/05 09:04:43 Searching for: Cancer Bats - Breathe Armageddon
2014/08/05 09:04:43 Added track: Breathe Armageddon (3QEHSMT7krLnAzj4WrZcpB)
2014/08/05 09:04:43 Cache size: 100/100
2014/08/05 09:04:43 Next sync in 5m0s
If adaptive interval had been enabled in the above case, the duration of Tool - Lateralis should not have been included in the calculated interval.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.