I'm a developer seeking to integrate Spotify's Web API into my project for podcast analytics. I'm specifically interested in obtaining information about the total consumption time for podcast episodes, not limited to the default 7-day period.
Upon reviewing the existing examples in the repository, I couldn't find any related to podcast analytics or retrieving total consumption time for episodes. Would it be possible to add examples or provide guidance on how to retrieve this type of data using the Spotify Web API?
Any assistance or insights on this matter would be highly appreciated. Thank you for your attention to this request.
Here is what I got so far
support@powerhousemethod:/var/www/powerhousemethod.com/POWERHOUSEMETHOD/podcast$ python3 spotify_audience_retention_scraper.py Title: Spotify audience retention Consumption Time (Beyond 7 Days): Median play time: 3m 35s • Beyond 7 days
Hello,
I'm a developer seeking to integrate Spotify's Web API into my project for podcast analytics. I'm specifically interested in obtaining information about the total consumption time for podcast episodes, not limited to the default 7-day period.
Upon reviewing the existing examples in the repository, I couldn't find any related to podcast analytics or retrieving total consumption time for episodes. Would it be possible to add examples or provide guidance on how to retrieve this type of data using the Spotify Web API?
Any assistance or insights on this matter would be highly appreciated. Thank you for your attention to this request.
Here is what I got so far
support@powerhousemethod:/var/www/powerhousemethod.com/POWERHOUSEMETHOD/podcast$ python3 spotify_audience_retention_scraper.py Title: Spotify audience retention Consumption Time (Beyond 7 Days): Median play time: 3m 35s • Beyond 7 days
support@powerhousemethod:/var/www/powerhousemethod.com/POWERHOUSEMETHOD/podcast$ cat -n spotify_audience_retention_scraper.py 1 from bs4 import BeautifulSoup 2 3 html_content = """ 4 <div> 5 <h3 data-encore-id="type" class="Type__TypeElement-sc-goli3j-0 krOKFN">Spotify audience retention 6 <span class="Trigger-sc-1q.mjssw-0 eOwnFz sc-jIYCZY jroJcV" data-encore-id="overlayTrigger"> 7 <span class="TooltipTrigger__TriggerContainer-sc-13ojzs2-0 dEyddL"> 8 <button aria-label="Info" data-encore-id="buttonTertiary" class="Button-sc-1dqy6lx-0 lnZOiz"> 9 <span aria-hidden="true" class="IconWrapper__Wrapper-sc-16usrgb-0 gpFeMd"> 10 <svg data-encore-id="icon" role="img" aria-hidden="true" viewBox="0 0 16 16" class="Svg-sc-ytk21e-0 dbYkfl"> 11 <path d="M8 14.5a6.5 6.5 0 1 1 0-13 6.5 6.5 0 0 1 0 13zM0 8a8 8 0 1 0 16 0A8 8 0 0 0 0 8z"></path> 12 <path d="M7.25 7v5h1.5V7h-1.5zm0-3.026v1.5h1.5v-1.5h-1.5z"></path> 13 </svg> 14 </span> 15 </button> 16 </span> 17 </span> 18 </h3> 19 <div data-encore-id="type" class="Type__TypeElement-sc-goli3j-0 jXQPBp">Median play time: 3m 35s • Beyond 7 days</div> 20 </div> 21 """ 22 23 soup = BeautifulSoup(html_content, 'html.parser') 24 25 # Find the h3 tag containing audience retention data 26 h3_tag = soup.find('h3', class_='krOKFN') 27 if h3_tag: 28 title = h3_tag.text.strip() 29 print("Title:", title) 30 31 # Find the div containing consumption time for beyond 7 days 32 div_tag = soup.find('div', class_='jXQPBp') 33 if div_tag: 34 consumption_time_beyond_7_days = div_tag.text.strip() 35 print("Consumption Time (Beyond 7 Days):", consumption_time_beyond_7_days) 36 else: 37 print("Failed to find the h3 tag containing audience retention data") 38