Skip to main content

A python wrapper for the Podcast Index API (podcastindex.org).

Project description

Build Status codecov

python-podcastindex

A python wrapper for the Podcast Index API (podcastindex.org)

Installation

pip install python-podcastindex

Usage

  1. Init the podcast index
  2. Search
  3. Podcasts
  4. Episodes of a podcast
  5. Episode by ID
  6. Recent episodes

Init the podcast index

import podcastindex

config = {
    "api_key": "YOUR API KEY HERE",
    "api_secret": "YOUR API SECRET HERE"
}

index = podcast_index.init(config)

Search

result = index.search("This American Life")
result = index.search("This American Life", clean=True)
Click to see sample result!
  {
      "status": "true",
      "feeds": [
          {
              "id": 522613,
              "title": "This American Life",
              "url": "http://feed.thisamericanlife.org/talpodcast",
              "originalUrl": "http://feed.thisamericanlife.org/talpodcast",
              "link": "https://www.thisamericanlife.org",
              "description": "This American Life is a weekly public ...",
              "author": "This American Life",
              "ownerName": "",
              "image": "https://files.thisamericanlife.org/sites/all/themes/thislife/img/tal-name-1400x1400.png",
              "artwork": "https://files.thisamericanlife.org/sites/all/themes/thislife/img/tal-name-1400x1400.png",
              "lastUpdateTime": 1607323495,
              "lastCrawlTime": 1607632436,
              "lastParseTime": 1607323495,
              "lastGoodHttpStatusTime": 1607632436,
              "lastHttpStatus": 200,
              "contentType": "text/xml; charset=UTF-8",
              "itunesId": 201671138,
              "generator": null,
              "language": "en",
              "type": 0,
              "dead": 0,
              "crawlErrors": 0,
              "parseErrors": 0,
              "categories": {
                  "77": "Society",
                  "78": "Culture",
                  "1": "Arts",
                  "55": "News",
                  "59": "Politics"
              },
              "locked": 0,
              "imageUrlHash": 1124696616
          },
          ...
      ],
      "count": 8,
      "query": "This American Life",
      "description": "Found matching feeds."
  }

Podcasts

results = index.podcastByFeedId(522613)
results = index.podcastByFeedUrl("http://feed.thisamericanlife.org/talpodcast")
results = index.podcastByItunesId(201671138)
Click to see sample result!
  {
      "status": "true",
      "query": {
          "id": "201671138"
      },
      "feed": {
          "id": 522613,
          "title": "This American Life",
          "url": "http://feed.thisamericanlife.org/talpodcast",
          "originalUrl": "http://feed.thisamericanlife.org/talpodcast",
          "link": "https://www.thisamericanlife.org",
          "description": "This American Life is a weekly public radio show, heard by 2.2 million people on more than 500 stations. Another 2.5 million people download the weekly podcast. It is hosted by Ira Glass, produced in collaboration with Chicago Public Media, delivered to stations by PRX The Public Radio Exchange, and has won all of the major broadcasting awards.",
          "author": "This American Life",
          "ownerName": "",
          "image": "https://files.thisamericanlife.org/sites/all/themes/thislife/img/tal-name-1400x1400.png",
          "artwork": "https://files.thisamericanlife.org/sites/all/themes/thislife/img/tal-name-1400x1400.png",
          "lastUpdateTime": 1607927945,
          "lastCrawlTime": 1608430718,
          "lastParseTime": 1608376393,
          "lastGoodHttpStatusTime": 1608430718,
          "lastHttpStatus": 200,
          "contentType": "text/xml; charset=UTF-8",
          "itunesId": 201671138,
          "generator": null,
          "language": "en",
          "type": 0,
          "dead": 0,
          "crawlErrors": 0,
          "parseErrors": 0,
          "locked": 0
      },
      "description": "Found matching items."
  }

Episodes of a podcast

results = index.episodesByFeedId(522613)
results = index.episodesByFeedUrl("http://feed.thisamericanlife.org/talpodcast")
results = index.episodesByItunesId(201671138)

results = index.episodesByFeedId(522613, since=-525600)  # in the last year
results = index.episodesByFeedId(522613, since=1577836800)  # Jan 1st 2020
Click to see sample result!
  {
      "status": "true",
      "items": [
          {
              "id": 1270106072,
              "title": "726: Twenty-Five",
              "link": "http://feed.thisamericanlife.org/~r/talpodcast/~3/p41tfsPlK00/twenty-five",
              "description": "To commemorate our show\u2019s 25th year, we have a program about people who were born the year our show went on\u00a0the\u00a0air.",
              "guid": "44678 at https://www.thisamericanlife.org",
              "datePublished": 1607900400,
              "datePublishedPretty": "December 13, 2020 5:00pm",
              "dateCrawled": 1607927945,
              "enclosureUrl": "https://www.podtrac.com/pts/redirect.mp3/podcast.thisamericanlife.org/podcast/726.mp3",
              "enclosureType": "audio/mpeg",
              "enclosureLength": 0,
              "duration": 3561,
              "explicit": 0,
              "episode": null,
              "episodeType": null,
              "season": 0,
              "image": "",
              "feedItunesId": 201671138,
              "feedImage": "https://files.thisamericanlife.org/sites/all/themes/thislife/img/tal-name-1400x1400.png",
              "feedId": 522613,
              "feedLanguage": "en",
              "chaptersUrl": null,
              "transcriptUrl": null
          },
          ...
      ],
      "count": 28,
      "query": "201671138",
      "description": "Found matching items."
  }

Episode by ID

results = index.episodeById(1270106072)
Click to see sample result!
  {
      "status": "true",
      "id": "1270106072",
      "episode": {
          "id": 1270106072,
          "title": "726: Twenty-Five",
          "link": "http://feed.thisamericanlife.org/~r/talpodcast/~3/p41tfsPlK00/twenty-five",
          "description": "To commemorate our show\u2019s 25th year, we have a program about people who were born the year our show went on\u00a0the\u00a0air.",
          "guid": "44678 at https://www.thisamericanlife.org",
          "datePublished": 1607900400,
          "datePublishedPretty": "December 13, 2020 5:00pm",
          "dateCrawled": 1607927945,
          "enclosureUrl": "https://www.podtrac.com/pts/redirect.mp3/podcast.thisamericanlife.org/podcast/726.mp3",
          "enclosureType": "audio/mpeg",
          "enclosureLength": 0,
          "duration": 3561,
          "explicit": 0,
          "episode": null,
          "episodeType": null,
          "season": 0,
          "image": "",
          "feedItunesId": 201671138,
          "feedImage": "https://files.thisamericanlife.org/sites/all/themes/thislife/img/tal-name-1400x1400.png",
          "feedId": 522613,
          "feedTitle": "This American Life",
          "feedLanguage": "en",
          "chaptersUrl": null,
          "transcriptUrl": null
      },
      "description": "Found matching item."
  }

Recent episodes

results = index.recentEpisodes(max=5, excluding="trump", before_episode_id=1270106072)
Click to see sample result!
  {
      "status": "true",
      "items": [
          {
              "id": 1269804903,
              "title": "How epidemics and pandemics have changed history",
              "link": "http://www.abc.net.au/radionational/programs/rearvision/how-epidemics-and-pandemics-have-changed-history/12851986",
              "description": "Human history is usually understood through wars, economic changes, technological development or great leaders. What\u2019s frequently overlooked is the role of infectious disease epidemics and pandemics. But as the COVID-19 virus has reminded us, disease can change us in ways we could never imagine.",
              "guid": "http://www.abc.net.au/radionational/programs/rearvision/how-epidemics-and-pandemics-have-changed-history/12851986",
              "datePublished": 1608426300,
              "datePublishedPretty": "December 19, 2020 7:05pm",
              "dateCrawled": 1607923316,
              "enclosureUrl": "http://mpegmedia.abc.net.au/rn/podcast/2020/12/rvn_20201220.mp3",
              "enclosureType": "audio/mp3",
              "enclosureLength": 27955968,
              "explicit": 0,
              "episode": null,
              "episodeType": null,
              "season": 0,
              "image": "",
              "feedItunesId": 135114451,
              "feedImage": "http://www.abc.net.au/cm/rimage/9860262-1x1-thumbnail.jpg?v=2",
              "feedId": 990878,
              "feedTitle": "Rear Vision",
              "feedLanguage": "en-AU"
          },
          ...
      ],
      "count": 5,
      "max": "5",
      "description": "Found matching items."
  }

Running the tests

  • Export the api key and secret
export PODCAST_INDEX_API_KEY="7B3U8VVP87QWSZUFXJRE"
export PODCAST_INDEX_API_SECRET="4QwK83LA7RttCDdms9MnCn3HMYqGPG6CDEvnkL2w"
  • Run the tests
coverage run -m pytest --log-cli-level=INFO

Contributing

  • Fork the repo
  • Add your awesome code
  • Submit a pull request
  • Ensure all existing tests pass
  • Bonus: include tests for your awesome new feature

Support

I am passionate about podcasting and work on this in my spare time. Hit me up and we can grab a virtual coffee together.

Buy Me A Coffee

Updating the pip package

This is mostly for myself since I have to lookup these commands every time ;)

  1. Update version number in setup.py
  2. Run the following commands

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

python-podcastindex-1.6.0.tar.gz (7.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

python_podcastindex-1.6.0-py3-none-any.whl (8.0 kB view details)

Uploaded Python 3

File details

Details for the file python-podcastindex-1.6.0.tar.gz.

File metadata

  • Download URL: python-podcastindex-1.6.0.tar.gz
  • Upload date:
  • Size: 7.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.6.1 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.7.9

File hashes

Hashes for python-podcastindex-1.6.0.tar.gz
Algorithm Hash digest
SHA256 4d1fe7489d78ee44bb6e46b05001b16786508bbb398f54f9e271a71f50ff838c
MD5 42236d84a194bfc9cedaf128767286ec
BLAKE2b-256 8d15882156d3c0cdfff56d32933e10f81a60acd5b24942d9d15aff239ea3ef22

See more details on using hashes here.

File details

Details for the file python_podcastindex-1.6.0-py3-none-any.whl.

File metadata

  • Download URL: python_podcastindex-1.6.0-py3-none-any.whl
  • Upload date:
  • Size: 8.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.6.1 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.7.9

File hashes

Hashes for python_podcastindex-1.6.0-py3-none-any.whl
Algorithm Hash digest
SHA256 cdfd3d8598678f1636f23ae8e811626d7e1798a0a4a35d06ad7c4563c055e36e
MD5 8618dbb882c689f7d64a4c1ea72a40fe
BLAKE2b-256 5f2312b5352bd3c119c90b4a9b459494c89646e729b6fc221892519044c30ebe

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page