darthbatman / billboard-top-100 Goto Github PK
View Code? Open in Web Editor NEW:chart_with_upwards_trend: Node.js API to retrieve the top songs, albums, and artists from Billboard's charts
License: MIT License
:chart_with_upwards_trend: Node.js API to retrieve the top songs, albums, and artists from Billboard's charts
License: MIT License
Good job guys, however, you should follow callback best practice where first argument is error and second is the result.
I am getting list from 2nd to 100 not from 1st and I need from 1st.
Can you please help me for that.
Here is the sample code How I am using this
`
var billboard = require("billboard-top-100").getChart;
billboard('hot-100', function(err, songs) {
if (err) console.log(err);
res.end(JSON.stringify(songs));
});
`
Clean up code and make sure it conforms to https://github.com/felixge/node-style-guide
Thanks for tool :-) it was very useful. There are more than just 'hot-100' chart and you need just change url suffix.
Hi,
I can only get data for about 12 weeks until I hit Cloudflare DDOS protection page and it errors with "Songs not found".
https://www.npmjs.com/package/cloudscraper is able to overcome the problem with Cloudflare.
Would you consider integrating this into your library, if you think it helps?
Everything returns a blank response.
Hot 100 Chart
"1961-09-16" : after rank 64
"1961-09-23": after rank 45
"1961-09-23": after rank 40
etc.
Thanks so much for making this! It seems like songObject.position
isn't being returned. I see it was possible removed back in this commit: b3dbd20#diff-5eeab9e25ee821ebaa8cabd29b38c351
Is that a bug, or does this no longer support that position
object being returned?
Hey, this is a great web scraper to retrieve billboard music chart metadata. Thanks a lot for this service.
I'm getting an error involving the date parameter of getChart(). I have a for loop that loops through 2001 to 2011 and template the current date using a JavaScript object. I then concatenate that together to satisfy the date format YYYY-MM-DD
(you can ignore addSong)
However, I get this error, saying songs not found
After running my server a few more times, I can get the chart data
Is there a way to guarantee that getChart() will work all the time? Does getChart() work with await/async?
Thanks for any fixes! :)
Hi, first thank you for making this. It is incredibly useful. Could you add the year in addition to the cover, group, title and rank?
How difficult would it to implement a function to ask for the top-100 of a given year, month or week?
position: { positionLastWeek: NaN, peakPosition: NaN, weeksOnChart: NaN }
Hi! I have been using this API for a personal project and I'm kinda stuck in this situation.
Consider the following case
//initialize an empty array
const songTitles = []
//make API call
getChart('hot-100', (err, chart) => {
if (err) console.log(err);
//push titles of all songs on the chart to songTitles array
chart.songs.map(song => {
songTitles.push(song.title)
})
});
//log the array
console.log(songs);
An empty array is logged upon executing this piece of code.
So, basically, how do I wait for the callback to mutate the array before it is logged to the console? Any help would be greatly appreciated!
First off - love you. Scraping is a pain, but this is so valuable. If you need help maintaining this, I'd be glad to offer assistance.
And you should be a tip jar at the bottom of the README so I can buy you a coffee ๐
But currently seems like artist-100 isn't able to be parsed, as I throw an uncaughtException at the following line:
const d = moment(new Date($('.chart-results')
...
For clarity, here's the exact requestURL: http://www.billboard.com/charts/artist-100/
This happening for you as well? Thanks
It seems to me the best way to return the url for the cover is just the url. However, the url is currently being parsed as "background-image: url(https://charts-static.billboard.com/img/2017/01/bon-jovi.jpg"
This isn't the end of the world, however, it isn't even correct in its current implementation. It doesn't have a closing parenthese for the 'url('.
We need to change https://www.billboard.com/charts
to "https://www.billboard.com
.
billboard-top-100/billboard-top-100.js
Line 398 in eeb660d
The HTML for billboard.com's Hot 100 page has changed, and the scraper no longer works for this chart. A user (Gabriel Littman) made a Pull Request here . I tried it out and it does fix the issue (though, like the user said, it may introduce another issue regarding images...not sure).
Using 2.4.4.
Array returns:
rank: 1,
title: 'Old Town Road',
artist: 'Lil Nas X Featuring Billy Ray Cyrus',
cover: '',
position: { positionLastWeek: NaN, peakPosition: NaN, weeksOnChart: NaN } },
Hello!
Thanks for creating this package! I've installed the package and copied over the example code but I'm getting an empty array and 'no chart found' message when trying to run the file. Just wondering if anything could have changed that would have effected how .getChart works on billboard's end. Thanks!
Just noticed that billboard chart page was changed again and the first ranked songs appears twice:
An easy fix, though
"dependencies": {
"billboard-top-100": "^2.5.5",
"prop-types": "^15.7.2",
"react": "^16.10.2",
"react-dom": "^16.10.2",
"react-router-dom": "^5.1.2",
"react-scripts": "3.2.0",
"styled-components": "^4.4.0",
"styled-reset": "^4.0.2"
},
componentDidMount() {
try {
this.setState({ loading: true });
getChart((err, chart) => {
if (err) console.log(err);
else console.log(chart);
});
} catch (e) {
console.log(e);
} finally {
this.setState({ loading: false });
}
}
TypeError: Failed to fetch
Access to fetch at 'http://www.billboard.com/charts/hot-100/' from origin 'http://127.0.0.1:3000' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.
When trying to retrieve current week's list the there is an exception thrown trying to read next week's link.
it files on line 281:
date: $('.dropdown__date-selector-option ')[1].children[1].attribs.href.split('/')[3]
The link does not contain href link because there isn't one :)
The code flies with the following error:
TypeError: Cannot read property 'split' of undefined #
getting the following console errors when attempting to use getChart function:
Failed to load resource: net::ERR_SSL_PROTOCOL_ERROR
TypeError: Failed to fetch
following from network information on request:
Request URL: https://www.billboard.com:80/charts/hot-100/2021-02-04
Referrer Policy: strict-origin-when-cross-origin
Referer: https:// ***(my site)
sec-ch-ua: "Chromium";v="88", "Google Chrome";v="88", ";Not A Brand";v="99"
sec-ch-ua-mobile: ?0
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 11_2_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.96 Safari/537.36
note: the function does work locally (https://localhost:3000) using chrome without CORS security
Would it be possible in the getChart
function to also return the week that the results are actually from?
For example, if you go to http://www.billboard.com/charts/hot-100/1958-08-23
, that August 23rd was in the middle of a week so the site is smart enough to actually give you the results for the week of 1958-08-25
(http://bluetide.pro/gSZvgc).
Would it be possible to just add some of that basic info to the top of the return when you build the array? Maybe some basic info like that "week of" date, and maybe the links for the prev/next week (http://bluetide.pro/2Tpqcr). You could just add selectors for those 3 things and append or prepend the array with that info. Or make an object at the start or finish that has that sorta "meta" data of the query in it.
I think it would be super useful info to have. It would also help be able to programmatically cycle that prev/next week by knowing those dates that the site has. Kinda like a "paging" mechanism you see in most api requests.
I want to make recursive calls to the getChart function but I don't know how to get the return value if the date that the function is called with is wrong?
(Wrong could mean that we have not yet reached the date)
I am trying to fetch full history of all charts and call your great function repeatedly (and more important synchronously) with shifted date:
const date = new Date('2016-11-19');
// loop
const formattedDate = format('yyyy-MM-dd', date);
billboard (formattedDate,....)
date.setDate(date.getDate() - 7);
// end of loop
And everything works great but sometimes there is no chart for the given date for some reason. For now billboard function just silently finishes. It would be great to emit some exception or error callback. There is no info that this date should be skipped and it is ok to try to fetch data for the next week.
It would bring things in line with node conventions and enable us to promisify the function easily.
I saw the issue was closed, but I am still getting songs 2->99 chart but not the top song. Here's some code that handles the hot 100 list for getting the top ranked song, haven't tested but should work for most of the other charts as well:
// Rank 1 is a special case that isn't in the list, so grab that separately
const topTrackInfo = $('.chart-number-one__details');
const track = topTrackInfo.children('.chart-number-one__title').text().trim();
const artist = topTrackInfo.children('.chart-number-one__artist').text().trim();
const rank = 1;
Hello!
Can it do smething like mentioned in the topic? I used to use modulo.site API, but not it is deprecated. I am looking for a tool to fetch album positions every time it was on the list with dates of it.
Certain pages like hot-100 and billboard-200 no longer work
I get this error on those pages
TypeError: Cannot read property 'children' of undefined
at Request._callback (/home/kyler/discordbots/adorabot/node_modules/billboard-top-100/billboard-top-100.js:319:101)
at Request.self.callback (/home/kyler/discordbots/adorabot/node_modules/request/request.js:185:22)
at Request.emit (node:events:369:20)
at Request.<anonymous> (/home/kyler/discordbots/adorabot/node_modules/request/request.js:1154:10)
at Request.emit (node:events:369:20)
at IncomingMessage.<anonymous> (/home/kyler/discordbots/adorabot/node_modules/request/request.js:1076:12)
at /home/kyler/discordbots/adorabot/node_modules/dd-trace/packages/dd-trace/src/scope/base.js:54:19
at Scope._activate (/home/kyler/discordbots/adorabot/node_modules/dd-trace/packages/dd-trace/src/scope/async_resource.js:53:14)
at Scope.activate (/home/kyler/discordbots/adorabot/node_modules/dd-trace/packages/dd-trace/src/scope/base.js:12:19)
at IncomingMessage.bound (/home/kyler/discordbots/adorabot/node_modules/dd-trace/packages/dd-trace/src/scope/base.js:53:20)
That line is this
chart.week = yyyymmddDateFromMonthDayYearDate($('.chart-detail-header__date-selector-button')[0].children[0].data.replace(/\n/g, ''));
So that jquery selector basically no longer works
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.