Open LithosphereRocketry opened 1 year ago
Looks like this is a known issue.
It doesn't look like the Billboard page provides a link to a previous or next chart date anymore. Am I missing one of those links on this page?
I didn't realize that was deprecated - apologies! Is there a new recommended way to iterate through charts over time? Should I just de-format and re-format the date a week earlier?
No need to apologize! I didn't realize it was deprecated till I dug into the code.
I think manually iterating through the dates you're interested in is your best bet. Here's an example from ChatGPT of how you could do it:
import datetime
def iterate_dates_in_month(year, month):
# Create a date object for the first day of the month
current_date = datetime.date(year, month, 1)
# Calculate the last day of the month
last_day = (current_date.replace(month=current_date.month % 12 + 1, day=1) - datetime.timedelta(days=1))
# Iterate through the dates in the month
while current_date <= last_day:
yield current_date
current_date += datetime.timedelta(days=1)
# Example usage:
import billboard
year = 2023
month = 9
for date in iterate_dates_in_month(year, month):
print(date)
chart = billboard.ChartData('hot-100', date=date)
print(chart)
What do you think?
I'm trying to retrieve chart data for consecutive weeks, and I have some basic test code that looks like this:
The correct chart is retrieved, but the previousDate field is always
None
. This is true whether I query for a specific date or leave it as the default latest chart.