Powershell script to take data to fill data missing data from Wikidata by requesting it from the Apple Podcast API
I have chosen Powershell as it is a language I have to use (and learn) in my working life and has the advantage of being able to be run in Windows without anything having to be manually installed
This script finds podcasts on Wikidata that are missing information and fills the gaps using data from Apple Podcasts.
For each Wikidata item in the list at the top of the script, it:
-
Looks up the item on Wikidata and finds its Apple Podcasts ID (P5842).
-
Asks the Apple Podcasts lookup API for that podcast's details.
-
Compares the two and prepares edits for anything Wikidata is missing or has out of date:
- Number of episodes (P1113): adds Apple's current count and removes older, lower counts.
- Genre (P136): maps Apple's genre codes to the matching Wikidata podcast genres.
- Podcast logo (P10286): uses the largest artwork Apple provides.
- Web feed (P1019): adds the podcast's RSS feed URL.
- End date (P582): if there has been no new episode for over a year, records the last release date as the end date.
- Multilingual label (
mul): adds the podcast's name as a label if it has none. - Name (P2561): removes any existing name statements.
Edits cite Apple Podcasts as the source, and most also record the date the data was retrieved.
-
Collects the edits into a QuickStatements batch and opens it in Chrome. Nothing changes on Wikidata until you review the batch and run it yourself.
-
Edit the
$Qline at the top ofApplePodcastToWikidata.ps1to list the Wikidata items (Q-numbers) you want to check. -
Run the script in PowerShell:
.\ApplePodcastToWikidata.ps1
-
A QuickStatements tab opens in Chrome for each batch. Log in, check the edits and click Run.
Long lists are split into several QuickStatements batches so the URL doesn't get too long.
- The script identifies itself with a User-Agent, as Wikimedia requires.
- It pauses for 60 seconds after every 20 items.
- If either service replies with "429 Too Many Requests", the script waits for
the time given in the
Retry-Afterheader and tries again, up to 3 times.
- Windows PowerShell 5.1 or PowerShell 7+. Nothing else needs installing.
- Google Chrome, which the script uses to open the QuickStatements batches.
- A Wikimedia account to run the batches in QuickStatements.