Unverified Commit 7f10696b authored by TheTechRobo's avatar TheTechRobo
Browse files

hopefully fix all the problems?

also migrate frontend to v3
parent 85ffb870
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -159,7 +159,7 @@ class Filmot(YouTubeService):
        capcount = int(archived)
        available = f"https://filmot.com/video/{id}" if archived else None
        return cls(
                archived=archived, capcount=capcount, error=None,
                archived=archived, capcount=capcount,
                lastupdated=lastupdated, name=cls.getName(), note="",
                rawraw=rawraw, metaonly=True, comments=False,
                available=available
+8 −14
Original line number Diff line number Diff line
@@ -145,23 +145,15 @@ class YouTubeResponse(JSONDataclass):
    keys: list[YouTubeService]
    api_version: int = 3

    def coerce_to_api_version(self, target):
        """
        Downgrades the API version to one of your choice, then returns self.
        PLEASE NOTE! While it returns the coerced response, it itself is also downgraded.
        So:
            >>> original_response = Response(...)
            >>> original_response.api_version
            3
            >>> coerced = original_response.coerce_to_api_version(2)
            >>> coerced.api_version
            2
            >>> original_response.api_version
            2
    def coerce_to_api_version(selfNEW, target):
        """
        Downgrades the API version to one of your choice, then returns it.

        Arguments:
            target (int): The target API version. Must be lower than self.api_version
        """
        import copy
        self = copy.deepcopy(selfNEW)
        currentApiVersion = self.api_version
        if currentApiVersion < target:
            raise ValueError("cannot upgrade api version")
@@ -169,11 +161,13 @@ class YouTubeResponse(JSONDataclass):
            fname = f"_convert_v{self.api_version}_to_v{self.api_version-1}"
            if not hasattr(self, fname):
                raise ValueError("cannot downgrade any further")
            getattr(self, fname)()
            self = getattr(self, fname)()
        assert self.api_version == target
        return self

    def _convert_v3_to_v2(self):
    def _convert_v3_to_v2(selfNEW):
        import copy
        self = copy.deepcopy(selfNEW)
        assert self.api_version == 3
        self.api_version = 2
        for index, service in enumerate(self.keys):
+14 −3
Original line number Diff line number Diff line
@@ -64,6 +64,10 @@ button {
  color: yellow;
  background-color: black;
}
.white {
  color: white;
  background-color: black;
}
</style>
    <script>
      function coerceToVid(vid) {
@@ -102,7 +106,7 @@ button {
        let url = "{{ url_for('static', filename='ab79a231234507.564a1d23814ef.gif') }}";
        let src = "https://www.behance.net/gallery/31234507/Open-source-Loading-GIF-Icons-Vol-1/modules/199929391";
        document.getElementById("data").innerHTML = `<img src="${url}" width="25" height="25" /> Loading could take up to 30 seconds.`;
        fetch(`api/v2/youtube/${vid}`)
        fetch(`api/v3/youtube/${vid}`)
                .then((response) => {
                        if (response.status == 410 || response.status == 404) {
                                document.getElementById("data").innerHTML = `<span style="color: red;">api version is not supported - this should never happen</span>`;
@@ -122,7 +126,10 @@ button {
            let keys = data.keys;
            keys.forEach((wbm) => {
              var colour;
              if (wbm.archived && wbm.metaonly) {
              if (wbm.error) {
                colour = "white";
              }
              else if (wbm.archived && wbm.metaonly) {
                colour = "yellow";
              }
              else if (wbm.archived) {
@@ -131,7 +138,11 @@ button {
              else {
                colour = "red";
              }
              let isarchived = wbm.archived ? "Archived" : "Not Archived";
              var isarchived = wbm.archived ? "Archived" : "Not Archived";
              if (wbm.error !== null) {
                isarchived = "Unknown";
                wbm.note = wbm.note + wbm.error;
              }
              let archived = `<span class='${colour}'>${isarchived}</span>`;
              let metaonly = (wbm.metaonly && wbm.archived) ? " (metadata only) " : " ";
              let comments = (wbm.archived && wbm.comments) ? " (incl. comments) ": " ";