Fetch your Pocket Casts statistics and put them into Airtable with about 80 lines of code. 🎉
For this tool to work you'll need a free Airtable account. If you don't have one - make one.
- Go to this example base: https://airtable.com/shryxs3YOERmBeHl1
- Click on
Copy base
in the upper-right corner of the page. - Once copied, delete all of the example records.
- Click on your avatar in the upper-right corner of the page and select
Account
. - On the account page, click on
Generate API key
on the right side under API.- Save the key and for use later as the
AIRTABLE_API_KEY
variable value.
- Save the key and for use later as the
- Go to this page and select your copied base: https://airtable.com/api
- Select
AUTHENTICATION
on the left side of the page. - On the right side there should be a dark area with text that resembles this:
$ curl https://api.airtable.com/v0/appr9hgXPZbBPqV4n/PocketCasts?api_key=YOUR_API_KEY
- Save the part after
v0/
until the following/
for later use (here, it would beappr9hgXPZbBPqV4n
) as theAIRTABLE_BASE_ID
value.
- Proceed to the directions in the section directly below.
For this to work, you'll need a free Gitlab.com account. If you don't have one - make one.
- Make a new project on Gitlab.com.
- Import this repository as the base for your project.
- Setup all environment variables in the project.
- Go to
Settings
>CI / CD
on the left side of the repository settings. - Insert variables under
Variables
(click expand, also seeEnvironment variables
)
- Go to
- Setup the Pipeline Scheduler.
- Go to
CI / CD
>Schedules
on the left side of the page. - Click the green button on the right labelled
New schedule
. - Give it a description, such as "Get new stats every 2h".
- Select
Custom ( Cron syntax )
where it asks for anInterval Pattern
. - Insert the following into the field:
0 */2 * * *
(this is a Cron syntax instruction to run every two hours, seven days a week). - Make sure that the
Target Branch
selected is yourmaster
branch. - Make sure the
Active
option is checked. - Click the
Save pipeline schedule
button.
- Go to
- Profit! :)
POCKETCASTS_EMAIL
- the email address you login to Pocket Casts withPOCKETCASTS_PASSWORD
- your Pocket Casts passwordAIRTABLE_BASE_ID
- the ID of the Airtable base which will store the dataAIRTABLE_API_KEY
- your Airtable account API keyAIRTABLE_POCKETCASTS_TABLE
- the table to store the Pocket Casts data
Important
You cannot use special characters like .!$/\|
in environment variable names!
- Copy the
.env_example
file and name itpocketcasts-stats.env
. - Edit the
pocketcasts-stats.env
file and fill in your credentials as mentioned above in Environment variables. - Test the project using Docker with the
make
command. - Profit! :)
Please make sure you run black
on your code
before you commit it!
This project uses about 80 lines of code according to
cloc
:
➜ cloc app.py .gitlab-ci.yml
2 text files.
2 unique files.
0 files ignored.
github.com/AlDanial/cloc v1.80 T=0.01s (157.1 file, 12570.7 lines)
-------------------------------------------------------------------------------
Language files blank comment code
-------------------------------------------------------------------------------
Python 1 28 43 70
YAML 1 4 0 15
-------------------------------------------------------------------------------
SUM: 2 32 43 85
-------------------------------------------------------------------------------
- Pocket Casts for being an awesome podcast player!
- airtable-python-wrapper, an awesome library to connect to Airtable.
- furgoose/Pocket-Casts, a good reference for how to query the Pocket Casts API.
- Airtable, for being an awesome tool!
- GitLab and
GitLabCI
, for being an all-in-one solution. - Gitlab Scheduler for Pipelines, because without it you would need a server.
- gitmoji, for better understandable commits through emojis. 🎉
- pylama, for checking code quality.
- pytest, for being an awesome testing framework.
- pytest-cov, for generating coverage reports.
- black, an awesome code formatter for Python.
- codecov, for showing the code coverage and helping improve it.
- PyUp.io, for helping to keep this project secure.
- codacy, for helping improve the code quality.