1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import json
import requests
from flask import (
Flask,
render_template,
request,
)
from bs4 import BeautifulSoup
app = Flask(__name__, static_folder='.', root_path='/home/runner')
APPLE_PODCAST_DOMAIN = "https://podcasts.apple.com/"
@app.route('/', methods=["GET", "POST"])
def index():
url_input = ""
feed_url = ""
if request.method == 'POST':
url_input = request.form['url']
if url_input.startswith(APPLE_PODCAST_DOMAIN):
feed_url = _get_feed_url(url_input)
return render_template(
'index.html',
url_input=url_input,
feed_url=feed_url
)
def _get_feed_url(url):
response = requests.get(url, timeout=10)
if not response.status_code == requests.codes.ok:
return
soup = BeautifulSoup(response.text, "html.parser")
ember_store = soup.find(id="shoebox-ember-data-store").string
json_store = json.loads(ember_store)
return json_store['data']['attributes']['feedUrl']
if __name__ == '__main__':
app.run(host='0.0.0.0', port='3000')