Skip to content

Commit

Permalink
Atom feeds: Properly link to art API
Browse files Browse the repository at this point in the history
Currently the use of _external_url_for results in a bad link to the API (lb.org/1/art/....) resulting in an error message "Please use the API at api.listenbrainz.org"

We need to manually construct a link to api.lb.org/1/art/... to fix that
  • Loading branch information
MonkeyDo committed Jan 14, 2025
1 parent 4b65efc commit ebc3906
Showing 1 changed file with 9 additions and 16 deletions.
25 changes: 9 additions & 16 deletions listenbrainz/webserver/views/atom.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
get_non_negative_param,
is_valid_uuid,
)
from listenbrainz.webserver import db_conn, ts_conn
from listenbrainz.webserver import db_conn, ts_conn, API_PREFIX
from listenbrainz.db.fresh_releases import get_sitewide_fresh_releases
from listenbrainz.db.fresh_releases import get_fresh_releases as db_get_fresh_releases
from data.model.common_stat import StatisticsRange
Expand Down Expand Up @@ -881,14 +881,9 @@ def get_cover_art_grid_stats(user_name):
)

# Generate the data URL for the art
data_url = _external_url_for(
"art_api_v1.cover_art_grid_stats",
user_name=user_name,
time_range=range,
dimension=dimension,
layout=layout,
image_size=image_size,
)
# Using API_URL + API_PREFIX otherwise we link to lb.org/1/art/...
# which returns an error message to use api.lb.org/1/art/...
data_url = f'{current_app.config["API_URL"]}{API_PREFIX}/art/grid-stats/{user_name}/{range}/{dimension}/{layout}/{image_size}'

this_feed_url = _external_url_for(".get_cover_art_grid_stats", user_name=user_name, range=range)
user_stats_url = _external_url_for("user.index", path="stats", user_name=user_name, range=range)
Expand Down Expand Up @@ -983,13 +978,11 @@ def get_cover_art_custom_stats(user_name):
f"Image size must be between {MIN_IMAGE_SIZE} and {MAX_IMAGE_SIZE}."
)

data_url = _external_url_for(
"art_api_v1.cover_art_custom_stats",
custom_name=custom_name,
user_name=user_name,
time_range=range,
image_size=image_size,
)
# Generate the data URL for the art
# Using API_URL + API_PREFIX otherwise we link to lb.org/1/art/...
# which returns an error message to use api.lb.org/1/art/...
data_url = f'{current_app.config["API_URL"]}{API_PREFIX}/art/{custom_name}/{user_name}/{range}/{image_size}'

this_feed_url = _external_url_for(".get_cover_art_custom_stats", user_name=user_name, range=range)
user_stats_url = _external_url_for("user.index", path="stats", user_name=user_name, range=range)

Expand Down

0 comments on commit ebc3906

Please sign in to comment.