tootallnate / iheart Goto Github PK
View Code? Open in Web Editor NEWiHeart Radio JavaScript API
iHeart Radio JavaScript API
https://cors.now.sh/ seems to be dead
I removed any references to corsProxy
variable to make this module work.
Either remove it or make it a configurable option, in case if anyone still needs a proxy.
Thanks
I feel like I misunderstand how to use this module, but all I know is when requiring it in node.js it doesn't work xD
/node_modules/iheart/index.js:1
(function (exports, require, module, __filename, __dirname) { import { extname } from 'path'
^^^^^^
SyntaxError: Unexpected token import
at createScript (vm.js:80:10)
at Object.runInThisContext (vm.js:139:10)
at Module._compile (module.js:576:28)
at Object.Module._extensions..js (module.js:623:10)
at Module.load (module.js:531:32)
at tryModuleLoad (module.js:494:12)
at Function.Module._load (module.js:486:3)
at Module.require (module.js:556:17)
at require (internal/module.js:11:18)
at eval (eval at execute (/home/firecontroller1847/discord-bots/pandora-v7/src/commands/Owner/eval.js:15:42), <anonymous>:1:16)
I can offer to create a function getById(_station)
which returns a whole JSON of radio station taking numeric station id as an argument. It is almost identical to streamURL(_station)
, but it stops before streams are extracted and returns body.hits[0]
instead.
It can be useful, for example, if one stores station ids in a favourites list, and needs to resolve a station name, its description, logo etc. In this case there will be no need to store entire station JSON object in the favourites. Also, cached station information can be outdated otherwise.
Caveat
Apparently, https://api.iheart.com/api/v1/catalog/searchAll
and https://api.iheart.com/api/v2/content/liveStations/
and thus iheart.search(...)
and iheart.streamURL(...)
respectively return a little bit different JSON objects. For instance, newlogo
property exits in one but does not in another. logo
property, in its turn, contains {img_url_1}
string in the former case, which makes logo URL unusable unless substitution value is found and replaced.
The Iheart radio api server will return the results in XML but with an 500 error to,
this means that the fetch request will not resolve as it doesn't know that the results are actually returned.
I used keyword "pop" with the search function which resolves to this url:
https://api.iheart.com/api/v1/catalog/searchAll?keywords=pop
and returns the following result when a get request is made:
with the following response headers:
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.