Commit 2108b3fa authored by TheTechRobo's avatar TheTechRobo
Browse files

lostmediafinder -> findyoutubevideo

This has been bugging me for awhile.
There are no current plans to support sites other than YouTube.
parent f9c03d20
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -2,7 +2,7 @@ FROM python:3.11-slim-bullseye
RUN pip install --no-cache-dir hypercorn quart
RUN apt install -y openssl
RUN apt clean
# The following line does not necessarily have to be updated with the requirements.txt as this is just to speed up the requirements.txt part (to improve cachability)
# The following line just improves cachability. It doesn't necessarily have to be kept up to date with requirements.txt.
RUN pip install --no-cache-dir snscrape==0.4.3.20220106 aiohttp[speedups] requests click pyyaml

EXPOSE 8000
+5 −8
Original line number Diff line number Diff line
# lostmediafinder
Currently YouTube is the only supported site, but that might change.
# youtubevideofinder
Searches through various places for archived YouTube content.

Contributions are welcome!

## CLI tool
Currently no documentation exists for the CLI tool.

## Usage as a module
There are docstrings included in the module (it is contained in `lostmediafinder`), but no `setup.py` or PyPI package is currently included. This is because it is not yet 100% stable (and I plan on adding support for more websites soon).
There are docstrings included in the module (it is contained in `youtubevideofinder`), but no `setup.py` or PyPI package is currently included. This is because it is not yet 100% stable, and the API still isn't great.

## Frontend
### Running in Docker (recommended):
@@ -18,7 +15,7 @@ Instead of modiying the Hypercorn config, use `HYPERCORN_<VARIABLE_NAME>` enviro
A command like this should work (runs on port 8000; change the `-p` flag to `<whatever port you want>:8000` to change that):

```
docker run --restart=unless-stopped -p 8000:8000 -e GUNICORN_WORKERS=4 thetechrobo/findyoutubevideo
docker run --restart=unless-stopped -p 8000:8000 -e thetechrobo/findyoutubevideo
```

### Running outside of Docker (unsupported)
@@ -53,7 +50,7 @@ Scrapers should try to yield the best or near-best link first, for best compatib

## Licence

Copyright (c) 2022-2025 TheTechRobo
Copyright (c) 2022-2026 TheTechRobo

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
+10 −10
Original line number Diff line number Diff line
import dataclasses, itertools
from quart import Quart, render_template, request, Response, redirect, send_from_directory, url_for
import re, yaml, json
import lostmediafinder
import findyoutubevideo

class EscapingQuart(Quart):
    def select_jinja_autoescape(self, filename: str) -> bool:
@@ -21,22 +21,22 @@ async def youtubev2(id):
    """
    Provides backwards compatibility for the old endpoint.
    """
    return (await lostmediafinder.YouTubeResponse.generate(id)).coerce_to_api_version(2).json(), {"Content-Type": "application/json"}
    return (await findyoutubevideo.YouTubeResponse.generate(id)).coerce_to_api_version(2).json(), {"Content-Type": "application/json"}

async def wrapperYT(id, includeRaw):
    """
    Wrapper for generate
    """
    try:
        return await lostmediafinder.YouTubeResponse.generate(id, includeRaw)
    except lostmediafinder.types.InvalidVideoIdError:
        return await findyoutubevideo.YouTubeResponse.generate(id, includeRaw)
    except findyoutubevideo.types.InvalidVideoIdError:
        return {"status": "bad.id", "id": None}

async def wrapperYTS(id, includeRaw):
    """
    Wrapper for generateStream
    """
    return await lostmediafinder.YouTubeResponse.generateStream(id, includeRaw)
    return await findyoutubevideo.YouTubeResponse.generateStream(id, includeRaw)

@app.route("/api/v<int:v>/<site>/<id>")
@app.route("/api/v<int:v>/<id>")
@@ -128,7 +128,7 @@ async def load_thing():
    if not request.args.get("id"):
        return "Missing id parameter", 400
    t = await youtube(5, request.args['id'], "youtube", jsn=False)
    assert isinstance(t, lostmediafinder.YouTubeResponse)
    assert isinstance(t, findyoutubevideo.YouTubeResponse)
    t.keys = list(itertools.chain(
        (k for k in t.keys if k.archived and not k.error),
        (k for k in t.keys if k.error),
@@ -160,7 +160,7 @@ async def index():
# The following code should be taken out and shot
def parse_changelog(changelog):
    """
    Parses a changelog out of a lostmediafinder docstring
    Parses a changelog out of a findyoutubevideo docstring
    """
    parsed = {}
    for i in changelog.split("API VERSION "):
@@ -202,9 +202,9 @@ async def api():
    """
    API docs
    """
    responseDocstring = lostmediafinder.YouTubeResponse.__doc__
    serviceDocstring = lostmediafinder.Service.__doc__
    linkDocstring = lostmediafinder.Link.__doc__
    responseDocstring = findyoutubevideo.YouTubeResponse.__doc__
    serviceDocstring = findyoutubevideo.Service.__doc__
    linkDocstring = findyoutubevideo.Link.__doc__
    # Parse the attributes list
    responseDocstring = await parse_lines(responseDocstring.split("Attributes:\n")[1].strip().split("\n"))
    serviceDocstring  = await parse_lines(serviceDocstring.split("Attributes:\n")[1].strip().split("\n"))
+0 −4
Original line number Diff line number Diff line
"""
LostMediaFinder
"""

from .types import *
from .finder import *
+2 −7
Original line number Diff line number Diff line
"""
The CLI interface of LostMediaFinder.
None of this is public API!
"""

import asyncio

import click

from . import YouTubeResponse

@click.group(help="CLI tool to search for lost media")
@click.group(help="CLI tool to search for archived YouTube content")
def main():
    """
    Error codes:
@@ -26,7 +21,7 @@ def youtube(ctx, id: str, format: str) -> int:
    """
    Parses CLI arguments and returns the Response for the video ID <IDENT>.
    """
    click.echo("\033[1m\033[4m\033[1;31mUsing LostMediaFinder from the command-line is unstable!\033[0m", err=True)
    click.echo("\033[1m\033[4m\033[1;31m* The command-line interface is unstable and does not include all features.\033[0m", err=True)
    click.echo("Generating report, this could take some time...", err=True)
    response = asyncio.run(YouTubeResponse.generate(id))
    if response.status == "bad.id":
Loading