Skip to content

Commit

Permalink
Add 'Spotify for Creators' impressions support
Browse files Browse the repository at this point in the history
  • Loading branch information
mre committed Dec 24, 2024
1 parent 3bf59c7 commit 93c6e8a
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
1 change: 1 addition & 0 deletions anchor/.env.sample
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@ OPENPODCAST_API_ENDPOINT=https://api.openpodcast.dev
OPENPODCAST_API_TOKEN=<OPENPODCAST_API_TOKEN>

ANCHOR_BASE_URL=https://podcasters.spotify.com/pod/api/proxy/v3
ANCHOR_BASE_GRAPHQL_URL=https://creators.spotify.com/pod/graphql
ANCHOR_PW_S=<ANCHOR_PW_S>
ANCHOR_WEBSTATION_ID=<ANCHOR_WEBSTATION_ID>
12 changes: 12 additions & 0 deletions anchor/job/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
"ANCHOR_BASE_URL", "https://podcasters.spotify.com/pod/api/proxy/v3"
)

BASE_GRAPHQL_URL = os.environ.get("ANCHOR_BASE_GRAPHQL_URL", "https://creators.spotify.com/pod/graphql")

# Anchor webstation ID which represents the podcast, which we fetch data for
ANCHOR_WEBSTATION_ID = load_file_or_env("ANCHOR_WEBSTATION_ID")

Expand Down Expand Up @@ -73,6 +75,7 @@

anchor = AnchorConnector(
base_url=BASE_URL,
base_graphql_url=BASE_GRAPHQL_URL,
webstation_id=ANCHOR_WEBSTATION_ID,
anchorpw_s=ANCHOR_PW_S,
)
Expand Down Expand Up @@ -181,6 +184,15 @@ def episode_all_time_video_data(connector, web_episode_id):
start_date=date_range.start,
end_date=date_range.end,
),
FetchParams(
openpodcast_endpoint="impressions",
anchor_call=get_request_lambda(
anchor.impressions,
date_range.end
),
start_date=date_range.start,
end_date=date_range.end,
),
FetchParams(
openpodcast_endpoint="totalPlaysByEpisode",
anchor_call=anchor.total_plays_by_episode,
Expand Down
2 changes: 1 addition & 1 deletion anchor/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
anchorconnector==0.4.0
anchorconnector==0.5.0
certifi==2022.12.7
charset-normalizer==3.1.0
idna==3.4
Expand Down

0 comments on commit 93c6e8a

Please sign in to comment.