diff options
| author | techchud <protrude_paying969@simplelogin.com> | 2025-08-17 19:35:25 -0500 | 
|---|---|---|
| committer | techchud <protrude_paying969@simplelogin.com> | 2025-08-17 19:35:25 -0500 | 
| commit | 6310c1d4ee8b1bd7d4edec7255ee92a33d5976a6 (patch) | |
| tree | 21283b103546b6e72349f6505887009463afe3a3 | |
| parent | bd4a3a8458ca6f9ff6f0cde3ab43c6509b3bbb4f (diff) | |
| download | stashley-master.tar.gz stashley-master.tar.bz2 stashley-master.zip | |
| -rw-r--r-- | stashley/stashley.py | 97 | 
1 files changed, 64 insertions, 33 deletions
| diff --git a/stashley/stashley.py b/stashley/stashley.py index 16af706..94538ef 100644 --- a/stashley/stashley.py +++ b/stashley/stashley.py @@ -32,51 +32,80 @@ def legalfy(url: str) -> str:      return ''.join(letter for letter in url if letter.isalnum()) -def figureUse(lore: dict, keyname: str) -> str: +def figureUse(lore: dict, keyname: str) -> dict: +     +    normopts = {'allsubtitles': True, + 'extract_flat': 'discard_in_playlist', + 'format': 'bestvideo[height>=720][fps>=60]+bestaudio/bestvideo+bestaudio/best', + 'fragment_retries': 10, + 'ignoreerrors': True, + 'outtmpl': {'default': keyname + '/%(uploader|author)s/%(title)s.%(ext)s'}, + 'postprocessors': [ +                     {'key': 'FFmpegConcat', +                     'only_multi_video': True, +                     'when': 'playlist'}], + 'retries': 10, + 'writeannotations': True, + 'writedescription': True, + 'writeinfojson': True, + 'writesubtitles': True, + 'writethumbnail': True} +  +    tiktokopts = {'allsubtitles': True, + 'extract_flat': 'discard_in_playlist', + 'format': 'bestvideo[height>=720][fps>=60]+bestaudio/bestvideo+bestaudio/best', + 'fragment_retries': 10, + 'ignoreerrors': True, + 'outtmpl': {'default': keyname + '/%(uploader|author)s/%(title)s.%(ext)s'}, + 'postprocessors': [ +                     {'key': 'FFmpegConcat', +                     'only_multi_video': True, +                     'when': 'playlist'}, +                     {'key': 'FFmpegVideoConvertor', +                      'preferedformat': 'webm'} +                     ], + 'retries': 10, + 'writeannotations': True, + 'writedescription': True, + 'writeinfojson': True, + 'writesubtitles': True, + 'writethumbnail': True} + + + +      if "use" in lore:          match lore["use"]:              case "yt-dlp": -                return "ytdl" +                return {"tool": "ytdl", "opts": normopts}              case "ytdlp": -                return "ytdl" +                return {"tool": "ytdl", "opts": normopts}              case "youtube-dl": -                return "ytdl" +                return {"tool": "ytdl", "opts": normopts}              case "yt-dl": -                return "ytdl" +                return {"tool": "ytdl", "opts": normopts}              case "website": -                return "website" +                return {"tool": "website"} +            case "websites": +                return {"tool": "website"}              case "site": -                return "website" +                return {"tool": "website"}          return "gallerydl"      else:          match keyname.lower():              case "youtube": -                return "ytdl" +                return {"tool": "ytdl", "opts": normopts}              case "tiktok": -                return "ytdl" +                return {"tool": "ytdl", "opts": tiktokopts}              case "website": -                return "website" +                return {"tool": "website"} +            case "websites": +                return {"tool": "website"}              case "site": -                return "website" -        return "gallerydl" - -def videohost(sitename: str, urls: list[str]): -    opts = {'allsubtitles': True, - 'extract_flat': 'discard_in_playlist', - 'format': 'bestvideo[height>=720][fps>=60]+bestaudio/bestvideo+bestaudio/best', - 'fragment_retries': 10, - 'ignoreerrors': True, - 'outtmpl': {'default': sitename + '/%(uploader|author)s/%(title)s.%(ext)s'}, - 'postprocessors': [{'key': 'FFmpegConcat', -                     'only_multi_video': True, -                     'when': 'playlist'}], - 'retries': 10, - 'writeannotations': True, - 'writedescription': True, - 'writeinfojson': True, - 'writesubtitles': True, - 'writethumbnail': True} +                return {"tool": "website"} +        return {"tool": "gallerydl"} +def videohost(sitename: str, urls: list[str], opts):      with yt_dlp.YoutubeDL(opts) as ydl:          ydl.download(urls) @@ -98,14 +127,16 @@ def archivesite(urls: list[str]):  for key in input["sites"]:      print("Downloading for " + key) -    program = figureUse(input["sites"][key], key) +    programData = figureUse(input["sites"][key], key) -    print("Opting to use: " + program) -    match program: +    print("Opting to use: " + programData["tool"]) +    match programData["tool"]:          case "ytdl": -            videohost(key, input["sites"][key]["urls"]) +            videohost(key, input["sites"][key]["urls"], programData["opts"])          case "gallerydl":              gallery(input["sites"][key]["urls"])          case "website":              archivesite(input["sites"][key]["urls"]) +        case "websites": +            archivesite(input["sites"][key]["urls"]) | 
