Fix aggregator being blank on Sundays and BS4 warnings

This commit is contained in:
2023-03-26 13:52:17 -04:00
parent f082bea571
commit c571043788
8 changed files with 58 additions and 70 deletions

View File

@ -98,7 +98,9 @@ def live_charts(
seven_days_ago = now - timedelta(days=7)
thirty_days_ago = now - timedelta(days=30)
start_of_today = datetime.combine(now, datetime.min.time(), tzinfo)
start_day_of_week = now - timedelta(days=now.today().isoweekday() % 7)
start_day_of_week = start_of_today - timedelta(
days=now.today().isoweekday() % 7
)
start_day_of_month = now.replace(day=1)
start_day_of_year = now.replace(month=1, day=1)

View File

@ -40,7 +40,7 @@ def scrape_data_from_allmusic(url) -> dict:
headers = {"User-Agent": "Vrobbler 0.11.12"}
r = requests.get(url, headers=headers)
if r.status_code == 200:
soup = BeautifulSoup(r.text, "html")
soup = BeautifulSoup(r.text, "html.parser")
data_dict["rating"] = get_rating_from_soup(soup)
data_dict["review"] = get_review_from_soup(soup)
return data_dict
@ -67,7 +67,7 @@ def get_allmusic_slug(artist_name=None, album_name=None) -> str:
logger.info(f"Bad http response from Allmusic {r}")
return slug
soup = BeautifulSoup(r.text, "html")
soup = BeautifulSoup(r.text, "html.parser")
results = soup.find("ul", class_="search-results")
if not results:

View File

@ -28,7 +28,7 @@ def get_bandcamp_slug(artist_name=None, album_name=None) -> str:
logger.info(f"Bad http response from Bandcamp {r}")
return slug
soup = BeautifulSoup(r.text, "html")
soup = BeautifulSoup(r.text, "html.parser")
results = soup.find("ul", class_="result-items")

View File

@ -82,7 +82,7 @@ def scrape_data_from_google_podcasts(title) -> dict:
url = PODCAST_SEARCH_URL.format(query=title)
r = requests.get(url, headers=headers)
if r.status_code == 200:
soup = BeautifulSoup(r.text, "html")
soup = BeautifulSoup(r.text, "html.parser")
data_dict["title"] = _get_title_from_soup(soup)
data_dict["description"] = _get_description_from_soup(soup)
data_dict["producer"] = _get_producer_from_soup(soup)

View File

@ -125,7 +125,6 @@ SITE_ID = 1
MIDDLEWARE = [
"django.middleware.security.SecurityMiddleware",
"whitenoise.middleware.WhiteNoiseMiddleware",
"django.contrib.sessions.middleware.SessionMiddleware",
"django.middleware.common.CommonMiddleware",
"django.middleware.csrf.CsrfViewMiddleware",