Unverified Commit 45644982 authored by TheTechRobo's avatar TheTechRobo
Browse files

Update docs

parent 92f5c175
Loading
Loading
Loading
Loading
+18 −1
Original line number Diff line number Diff line
@@ -27,10 +27,27 @@ async def youtube(v, id, site="youtube"):
async def index():
    return render_template("init.html")

def parseChangelog(changelog):
    parsed = {}
    for i in changelog.split("API VERSION "):
        restOfLine = i.split("\n")[0]
        others = i.split("\n")[1:]
        parsed[restOfLine] = others
    return parsed

@app.route("/api")
async def api():
    responseDocstring = lostmediafinder.YouTubeResponse.__doc__
    serviceDocstring = lostmediafinder.Service.__doc__
    changelog = [{}, {}]
    rChangelog = responseDocstring.split("=Changelog=")
    sChangelog = serviceDocstring.split("=Changelog=")
    responseDocstring = rChangelog[0]
    serviceDocstring = sChangelog[0]
    if len(rChangelog) > 1:
        changelog[0] = parseChangelog(rChangelog[1].strip())
    if len(sChangelog) > 1:
        changelog[1] = parseChangelog(sChangelog[1].strip())
    # TODO: Parse that
    # This works fine for now tho
    return render_template("api.html", fields=responseDocstring, services=serviceDocstring, type=type)
    return render_template("api.html", fields=responseDocstring, services=serviceDocstring, changelog=changelog)
+3 −3
Original line number Diff line number Diff line
@@ -37,9 +37,9 @@ class Service(JSONDataclass):

    Attributes:
        archived (bool): Whether the video is archived or not.
        available (int): A link to the archived material if it can be produced; null otherwise.
        available (Optional[str]): A link to the archived material if it can be produced; null otherwise.
        capcount (int): The number of captures. Currently deprecated - the capture count sent may or may not be the true number of captures. However, it will always be a positive non-zero number if the video is archived.
        error (bool): Whether or not the request failed.
        error (Optional[str]): An error message if an error was encountered; otherwise, null.
        lastupdated (int): The timestamp the data was retrieved from the server. Used internally to expire cache entries.
        name (str): The name of the service. Used in the UI.
        note (str): A footnote about the service. This could be different depending on conditions. For example, the Internet Archive has an extra passage if the item is dark. Used in the UI.
@@ -138,7 +138,7 @@ class YouTubeResponse(JSONDataclass):
        id (str): The interpreted video ID.
        status (str): bad.id if invalid ID.
        keys (list[YouTubeService]): An array with all the server responses. THIS IS DIFFERENT THAN BEFORE! Before, this would be an array of strings. You'd use the strings as keys. Now, this array has the data directly!
        api_version (int): The API version. Currently set to %s. Breaking API changes are made by incrementing this. There may be a way to request a specific version in the future.
        api_version (int): The API version. Breaking API changes are made by incrementing this.
    """
    id: str
    status: str
+32 −2
Original line number Diff line number Diff line
@@ -10,9 +10,25 @@ body {
  <body>
    <p>Please don't spam my servers - anyone that spams too much may be banned. Contact me on Discord (TheTechRobo#7420) or IRC (TheTechRobo on hackint) to discuss.</p>
    <h1>API Documentation</h1>
    <h3>Call: GET <code>/find/$videoid</code></h3>
    <h3>Call: GET <code>/api/:version/:videoid</code></h3>
    <h4>Current versions available: v2, v3</h4>
    <p>
    <b>Fields</b>
    {% if changelog[0] %}<div id="Fcl">
      <u>Changelog</u>
      <ul>
        {% for log, logitems in changelog[0].items() %}
          {% if log %}
            <li>Api version {{log}}</li>
            <ul>
              {% for logitem in logitems %}
                <li>{{logitem}}</li>
              {% endfor %}
            </ul>
          {% endif %}
        {% endfor %}
      </ul>
    </div>{%endif%}
    <br>
    <dl>
      {% if fields is mapping %}
@@ -30,7 +46,21 @@ body {
      {% endif %}
    </dl>
    <b>Service Objects</b>
    <p>One object for every service searched.</p>
    {% if changelog[1] %}<div id="Scl">
      <u>Changelog</u>
      <ul>
        {% for log, logitems in changelog[1].items() %}
          {% if log %}
            <li>Api version {{log}}</li>
            <ul>
              {% for logitem in logitems %}
                <li>{{logitem}}</li>
              {% endfor %}
            </ul>
          {% endif %}
        {% endfor %}
      </ul>
    </div>{%endif%}
    {% if services is mapping %}
      <dl>
        {% for field, value in services.items() %}