Commit 248271b4 authored by mattwright324's avatar mattwright324
Browse files

convert config to yml format; enabled and name flags for all methods; add wayback cdx thumb check

parent 89f7b669
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
config.py
README.md.backup
*.pyc
nohup.out
.idea
static/ign
config.py
config.yml
 No newline at end of file
+1 −0
Original line number Diff line number Diff line
@@ -6,3 +6,4 @@ nest_asyncio
cachetools
click
asyncache
pyyaml
 No newline at end of file
+21 −5
Original line number Diff line number Diff line
from flask import Flask, render_template, request, Response, redirect

import re, urllib.parse

import re, urllib.parse, yaml
import lostmediafinder

app = Flask(__name__)

with open('config.yml', 'r') as file:
    config_yml = yaml.safe_load(file)

@app.route("/robots.txt")
async def robots():
    return """
@@ -76,6 +77,14 @@ def coerce_to_id(vid):
            return newVid
    return None

def get_enabled_methods():
    titles = []
    for key in config_yml["methods"]:
        method = config_yml["methods"][key]
        if method["enabled"]:
            titles.append(method["title"])
    return titles

@app.route("/noscript_load.html")
async def noscript_load():
    if not request.args.get("d"):
@@ -137,7 +146,11 @@ async def index():
    """
    default = request.args.get("q") or ""
    default_id = coerce_to_id(default) or ""
    return render_template("index.html", default=default, default_id=default_id)
    return render_template("index.html",
                           default=default,
                           default_id=default_id,
                           methods=get_enabled_methods(),
                           )

def parse_changelog(changelog):
    """
@@ -197,4 +210,7 @@ async def api():
    # Parse the attributes list
    responseDocstring = await parse_lines(rChangelog[0].split("Attributes:\n")[1].strip().split("\n"))
    serviceDocstring  = await parse_lines(sChangelog[0].split("Attributes:\n")[1].strip().split("\n"))
    return render_template("api.html", fields=responseDocstring, services=serviceDocstring, changelog=changelog)
    return render_template("api.html",
                           fields=responseDocstring,
                           services=serviceDocstring,
                           changelog=changelog)

config.example.py

deleted100644 → 0
+0 −9
Original line number Diff line number Diff line
class ya:
    enabled  = False
    username = "fill this in"
    password = "fill this in"

class filmot:
    key = "fill this in"

config_version = 2
 No newline at end of file

config.template.yml

0 → 100644
+37 −0
Original line number Diff line number Diff line
version: 3

methods:
  ia_wayback:
    title: Wayback Machine
    enabled: true

  ia_details:
    title: Archive.org Details
    enabled: true

  ia_cdx:
    title: Archive.org CDX
    enabled: true

  ghostarchive:
    title: GhostArchive
    enabled: true

  hackint_ya:
    title: "#youtubearchive"
    enabled: false
    username:
    password:

  filmot:
    title: Filmot
    enabled: false
    api_key:

  playboard_co:
    title: playboard.co
    enabled: true

  hobune_archive:
    title: hobune.archive
    enabled: true
 No newline at end of file
Loading