|
| 1 | +import json |
| 2 | +import os |
| 3 | + |
| 4 | +from listennotes import podcast_api, errors |
| 5 | + |
| 6 | +# Get your api key here: https://www.listennotes.com/api/dashboard/ |
| 7 | +api_key = os.environ.get("LISTEN_API_KEY", None) |
| 8 | + |
| 9 | +client = podcast_api.Client(api_key=api_key) |
| 10 | + |
| 11 | +# |
| 12 | +# Boilerplate to make an api call |
| 13 | +# |
| 14 | +try: |
| 15 | + response = client.typeahead(q="startup", show_podcasts=1) |
| 16 | + print(json.dumps(response.json(), indent=2)) |
| 17 | +except errors.APIConnectionError: |
| 18 | + print("Failed ot connect to Listen API servers") |
| 19 | +except errors.AuthenticationError: |
| 20 | + print("Wrong api key, or your account has been suspended!") |
| 21 | +except errors.InvalidRequestError: |
| 22 | + print("Wrong parameters!") |
| 23 | +except errors.NotFoundError: |
| 24 | + print("Endpoint not exist or the podcast / episode not exist!") |
| 25 | +except errors.RateLimitError: |
| 26 | + print("You have reached your quota limit!") |
| 27 | +except errors.ListenApiError: |
| 28 | + print("Something wrong on Listen Notes servers") |
| 29 | +except Exception: |
| 30 | + print("Other errors that may not be related to Listen API") |
| 31 | +else: |
| 32 | + headers = response.headers |
| 33 | + print("\n=== Some account info ===") |
| 34 | + print( |
| 35 | + "Free Quota this month: %s requests" |
| 36 | + % headers.get("X-ListenAPI-FreeQuota") |
| 37 | + ) |
| 38 | + print("Usage this month: %s requests" % headers.get("X-ListenAPI-Usage")) |
| 39 | + print("Next billing date: %s" % headers.get("X-Listenapi-NextBillingDate")) |
| 40 | + |
| 41 | +# response = client.search(q='startup') |
| 42 | +# print(response.json()) |
| 43 | + |
| 44 | +# response = client.fetch_best_podcasts() |
| 45 | +# print(response.json()) |
| 46 | + |
| 47 | +# response = client.fetch_best_podcasts() |
| 48 | +# print(response.json()) |
| 49 | + |
| 50 | +# response = client.fetch_podcast_by_id(id='4d3fe717742d4963a85562e9f84d8c79') |
| 51 | +# print(response.json()) |
| 52 | + |
| 53 | +# response = client.fetch_episode_by_id(id='6b6d65930c5a4f71b254465871fed370') |
| 54 | +# print(response.json()) |
| 55 | + |
| 56 | +# response = client.batch_fetch_episodes(ids='c577d55b2b2b483c969fae3ceb58e362,0f34a9099579490993eec9e8c8cebb82') |
| 57 | +# print(response.json()) |
| 58 | + |
| 59 | +# response = client.batch_fetch_podcasts(ids='3302bc71139541baa46ecb27dbf6071a,68faf62be97149c280ebcc25178aa731,' |
| 60 | +# '37589a3e121e40debe4cef3d9638932a,9cf19c590ff0484d97b18b329fed0c6a') |
| 61 | +# print(response.json()) |
| 62 | + |
| 63 | +# response = client.fetch_curated_podcasts_list_by_id(id='SDFKduyJ47r') |
| 64 | +# print(response.json()) |
| 65 | + |
| 66 | +# response = client.fetch_curated_podcasts_lists(page=2) |
| 67 | +# print(response.json()) |
| 68 | + |
| 69 | +# response = client.fetch_curated_podcasts_lists(page=2) |
| 70 | +# print(response.json()) |
| 71 | + |
| 72 | +# response = client.fetch_podcast_genres(top_level_only=0) |
| 73 | +# print(response.json()) |
| 74 | + |
| 75 | +# response = client.fetch_podcast_regions() |
| 76 | +# print(response.json()) |
| 77 | + |
| 78 | +# response = client.fetch_podcast_languages() |
| 79 | +# print(response.json()) |
| 80 | + |
| 81 | +# response = client.just_listen() |
| 82 | +# print(response.json()) |
| 83 | + |
| 84 | +# response = client.fetch_recommendations_for_podcast(id='25212ac3c53240a880dd5032e547047b', safe_mode=1) |
| 85 | +# print(response.json()) |
| 86 | + |
| 87 | +# response = client.fetch_recommendations_for_episode(id='914a9deafa5340eeaa2859c77f275799', safe_mode=1) |
| 88 | +# print(response.json()) |
| 89 | + |
| 90 | +# response = client.fetch_playlist_by_id(id='m1pe7z60bsw', type='podcast_list') |
| 91 | +# print(response.json()) |
| 92 | + |
| 93 | +# response = client.fetch_my_playlists() |
| 94 | +# print(response.json()) |
| 95 | + |
| 96 | +# response = client.submit_podcast(rss='https://feeds.megaphone.fm/committed') |
| 97 | +# print(response.json()) |
| 98 | + |
| 99 | +# response = client.delete_podcast( |
| 100 | +# id='4d3fe717742d4963a85562e9f84d8c79', reason='the podcaster wants to delete it') |
| 101 | +# print(response.json()) |
0 commit comments