Skip to content

Instantly share code, notes, and snippets.

@Igglybuff
Created December 20, 2018 13:06
Show Gist options
  • Save Igglybuff/a49c850910cdc4ae7e3353cd110fba8c to your computer and use it in GitHub Desktop.
Save Igglybuff/a49c850910cdc4ae7e3353cd110fba8c to your computer and use it in GitHub Desktop.
Python Flask app for generating a match releases expression for autodl-irssi from dvdsreleasedates.com
from flask import Flask, Response
import requests
from bs4 import BeautifulSoup
app = Flask(__name__)
@app.route("/")
def index():
resp = scrape_releases()
return Response(resp, mimetype='text/plain')
def scrape_releases():
headers = {
'Connection': 'keep-alive',
'Cache-Control': 'max-age=0',
'Upgrade-Insecure-Requests': '1',
'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.102 Safari/537.36',
'DNT': '1',
'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8',
'Accept-Encoding': 'gzip, deflate, br',
'Accept-Language': 'en-GB,en;q=0.9,en-US;q=0.8,pt;q=0.7',
}
page = requests.get('https://www.dvdsreleasedates.com/', headers=headers)
soup = BeautifulSoup(page.text, 'html.parser')
requested_table = soup.find("div", {"id": 'requested'})
requested_hrefs = requested_table.find_all('a')
movie_names_raw = []
for movie in requested_hrefs:
name = movie.contents[0]
movie_names_raw.append(name)
movie_names_starred = [ movie + "*," for movie in movie_names_raw ]
movie_names = []
for movie in movie_names_starred:
movie_names.append(movie.replace(' ', '?'))
return movie_names
if __name__ == "__main__":
app.run(host="0.0.0.0", debug=False)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment