Unverified Commit b2025767 authored by TheTechRobo's avatar TheTechRobo Committed by GitHub
Browse files

Merge pull request #59 from mattwright324/master

parents 44b9d256 7e3f7033
Loading
Loading
Loading
Loading
+6 −2
Original line number Diff line number Diff line
version: 3

methods:
  youtube:
    title: YouTube
    enabled: true

  ia_wayback:
    title: Wayback Machine
    enabled: true
@@ -24,9 +28,9 @@ methods:
    password:

  distributed_youtube_archive:
    title: "Distributed YouTube Archive"
    title: Distributed YouTube Archive
    enabled: false
    key: ""
    key:

  hobune_stream:
    title: Hobune.stream
+31 −0
Original line number Diff line number Diff line
@@ -6,6 +6,37 @@ import random, time, urllib.parse, aiohttp, asyncio
from switch import Switch
from .types import YouTubeService, T, methods

class YouTube(YouTubeService):
    """
    Checks if the video is still available on YouTube.
    Thumbnail method has a few edge cases but seems the most reliable for all tested cases.
    """
    name = methods["youtube"]["title"]
    configId = "youtube"

    @classmethod
    async def _run(cls, id, session: aiohttp.ClientSession, includeRaw=True) -> T:
        lien = f"https://i.ytimg.com/vi/{id}/hqdefault.jpg"
        async with session.head(lien, allow_redirects=False, timeout=15) as response:
            code = response.status

        rawraw = code if includeRaw else None
        archived = None
        link = f"https://youtu.be/{id}"

        if code == 200:
            archived = True
        else:
            archived = False

        capcount = int(archived)
        available = link if archived else None
        lastupdated = time.time()
        return cls(
            archived=archived, available=available, capcount=capcount, lastupdated=lastupdated, name=cls.getName(), note="", rawraw=rawraw,
            metaonly=False, comments=False
        )

class WaybackMachine(YouTubeService):
    """
    Queries the Wayback Machine for the video you requested.
+1 −1
Original line number Diff line number Diff line
@@ -78,7 +78,7 @@ function finish(vid1) {
                } else {
                    colour = "red";
                }
                var isarchived = wbm.archived ? "Archived" : "Not Archived";
                var isarchived = wbm.archived ? "Available" : "Not Available";
                if (wbm.error !== null) {
                    isarchived = "Unknown";
                    wbm.note = wbm.note + wbm.error;