Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add 'Spotify for Creators' impressions support #90

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it is always last 30 days. so we have to send the correct date range to the api as the values are stored with this date range in the DB

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
Loading