Skip to content

Commit db58c75

Browse files
authored
Merge pull request #28 from luuktimmermans/main
Added Zenrows functionality
2 parents 940a7a9 + 5e93ed4 commit db58c75

File tree

4 files changed

+20
-8
lines changed

4 files changed

+20
-8
lines changed

README.md

+10-3
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,13 @@ This tool allows you to stream Podimo podcasts with your preferred podcast playe
88

99

1010
## Usage
11-
The easiest way to use it is via [podimo.thijs.sh](https://podimo.thijs.sh). You can also host it yourself by following the instructions below.
11+
The easiest way to use it is via [podimo.thijs.sh](https://podimo.thijs.sh). You can also host it yourself by following the instructions below. It's necessary to create a Zenrows account to bypass Podimo's anti-bot mechanisms.
12+
13+
## Setting up a Zenrows account
14+
You can create a free account, which gives you 1000 free api credits.
15+
16+
1. Go to [app.zenrows.com/register](https://app.zenrows.com/register) and create a free account
17+
2. Copy your API key and make sure to add it to the `ZENROWS_API` environment variable (`-e`) in the Docker run command
1218

1319
## Instructions for self-hosting (with Docker)
1420
1. Clone this repository and enter the newly created directory
@@ -24,11 +30,11 @@ docker build -t podimo:latest .
2430

2531
3. Run the Docker image
2632
```sh
27-
docker run --rm -e PODIMO_HOSTNAME=localhost -e PODIMO_BIND_HOST=0.0.0.0:12104 -e PODIMO_PROTOCOL=http -p 12104:12104 podimo:latest
33+
docker run --rm -e PODIMO_HOSTNAME=yourip:12104 -e PODIMO_BIND_HOST=0.0.0.0:12104 -e PODIMO_PROTOCOL=http -e ZENROWS_API=APIKEY -p 12104:12104 podimo:latest
2834
```
2935
For an explaination of what each environmental variable (`-e`) does, see the section on [configuration with environmental variables](#configuration).
3036

31-
4. Visit http://localhost:12104. You should see the site now!
37+
4. Visit http://yourip:12104. You should see the site now!
3238

3339
## Installation for self-hosting (without Docker)
3440
Make sure you have a recent Python 3 version installed, as this is required for the steps below.
@@ -63,6 +69,7 @@ There are a few environmental variables that can configure this tool
6369
- `PODIMO_BIND_HOST` Sets the IP and port to which this tool should bind, defaults to `127.0.0.1:12104`.
6470
- `PODIMO_PROTOCOL` Sets the protocol that is displayed in the interface. For local
6571
deployments it can be useful to set this to `http`. Defaults to `https`.
72+
- `ZENROWS_API` Sets the Zenrows API key for it to be used.
6673
- `DEBUG` Shows a bit more information that can be useful while debugging
6774
- `HTTP_PROXY` A URL for an HTTP proxy that can be used to rotate IP addresses to avoid being blocked by CloudFlare.
6875

podimo/client.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,14 @@
1717
# See the Licence for the specific language governing
1818
# permissions and limitations under the Licence.
1919

20-
from podimo.config import GRAPHQL_URL
20+
from podimo.config import GRAPHQL_URL, ZENROWS_API
2121
from podimo.utils import (is_correct_email_address, token_key,
2222
randomFlyerId, generateHeaders as gHdrs, debug,
2323
async_wrap)
2424
from podimo.cache import insertIntoPodcastCache, getCacheEntry, podcast_cache
2525
from time import time
2626
from os import getenv
27+
from zenrows import ZenRowsClient
2728
import sys
2829

2930
class PodimoClient:
@@ -48,6 +49,8 @@ def generateHeaders(self, authorization):
4849
return gHdrs(authorization, self.locale)
4950

5051
async def post(self, headers, query, variables, scraper):
52+
if ZENROWS_API is not None:
53+
scraper = ZenRowsClient(ZENROWS_API)
5154
response = await async_wrap(scraper.post)(GRAPHQL_URL,
5255
headers=headers,
5356
cookies=self.cookie_jar,

podimo/config.py

+5-4
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,10 @@
2626
# Defaults to "127.0.0.1:12104"
2727
# - `PODIMO_PROTOCOL`: what protocol is being used for all links that are
2828
# displayed to the user. Defaults to "https".
29-
PODIMO_HOSTNAME = os.environ.get("PODIMO_HOSTNAME", "podimo.thijs.sh")
30-
PODIMO_BIND_HOST = os.environ.get("PODIMO_BIND_HOST", "127.0.0.1:12104")
31-
PODIMO_PROTOCOL = os.environ.get("PODIMO_PROTOCOL", "https")
29+
PODIMO_HOSTNAME = os.environ.get("PODIMO_HOSTNAME", "yourip:12104")
30+
PODIMO_BIND_HOST = os.environ.get("PODIMO_BIND_HOST", "0.0.0.0:12104")
31+
PODIMO_PROTOCOL = os.environ.get("PODIMO_PROTOCOL", "http")
32+
ZENROWS_API = os.environ.get("ZENROWS_API", None)
3233

3334
# Enable extra logging in debugging mode
3435
DEBUG = os.environ.get("DEBUG", False)
@@ -41,7 +42,7 @@
4142
TOKEN_TIMEOUT = 3600 * 24 * 5 # seconds = 5 days
4243

4344
# The time that a podcast feed is stored in cache
44-
PODCAST_CACHE_TIME = 15 * 60 # seconds = 15 minutes
45+
PODCAST_CACHE_TIME = 43200 # seconds = 12 hours
4546

4647
# The time that the content information is cached
4748
HEAD_CACHE_TIME = 7 * 60 * 60 * 24 # seconds = 7 days

requirements.txt

+1
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@ quart~=0.18.4
44
hypercorn~=0.14.4
55
cloudscraper~=1.2.71
66
werkzeug~=2.3.7
7+
zenrows~=1.3.2

0 commit comments

Comments
 (0)