From 1db8f9839130d0a5a6f29cf9ca9de27dfae6e03f Mon Sep 17 00:00:00 2001 From: Cloudburst <18114966+C10udburst@users.noreply.github.com> Date: Tue, 12 Apr 2022 18:48:50 +0200 Subject: [PATCH] site list changes (#872) * site list changes - made site-list.json automatically create providers.json - removed site list from readme (now shows a link) - remove jquery dependency and split src into multiple files * update workflow file * oops wrong number * fix invalid regex * status 1 * revert providers.json --- .github/site-list.py | 77 +++++++++----------- .github/workflows/site_list.yml | 4 +- README.md | 52 +------------- docs/index.html | 120 +------------------------------- docs/script.js | 49 +++++++++++++ docs/style.css | 49 +++++++++++++ 6 files changed, 139 insertions(+), 212 deletions(-) create mode 100644 docs/script.js create mode 100644 docs/style.css diff --git a/.github/site-list.py b/.github/site-list.py index 450767c68..d6a13b58b 100644 --- a/.github/site-list.py +++ b/.github/site-list.py @@ -1,63 +1,54 @@ #!/usr/bin/python3 from glob import glob -from re import findall, compile, sub, DOTALL +from re import findall, compile, DOTALL +from json import dump, load from typing import List, Dict # Globals URL_REGEX = compile( "override\sva[lr]\smainUrl[^\"']+[\"'](https?://[a-zA-Z0-9\.-]+)[\"']") -NAME_REGEX = compile("class (.+?) ?: \w+\(\)\s\{") -START_MARKER = "" -END_MARKER = "" +NAME_REGEX = compile("([A-Za-z0-9]+)(?:.kt)$") +JSON_PATH = "docs/providers.json" GLOB = "app/src/main/java/com/lagradost/cloudstream3/*providers/*Provider.kt" -MAIN_API = "app/src/main/java/com/lagradost/cloudstream3/MainAPI.kt" -API_REGEX = compile( - "val\s*allProviders.*?{\s.*?arrayListOf\(([\W\w]*?)\)\s*\n*\s*}", DOTALL) -sites: Dict[str, str] = {} -enabled_sites: List[str] = [] - - -with open(MAIN_API, "r", encoding="utf-8") as f: - apis = findall(API_REGEX, f.read()) - for api_list in apis: - for api in api_list.split("\n"): - if not api.strip() or api.strip().startswith("/"): - continue - enabled_sites.append(api.strip().split("(")[0]) +old_sites: Dict[str, Dict] = load(open(JSON_PATH, "r", encoding="utf-8")) +sites: Dict[str, Dict] = {} +# parse all *Provider.kt files for path in glob(GLOB): with open(path, "r", encoding='utf-8') as file: try: site_text: str = file.read() - name: List[str] = findall(NAME_REGEX, site_text) - provider_text: str = findall(URL_REGEX, site_text) + name: str = findall(NAME_REGEX, path)[0] + provider_url: str = [*findall(URL_REGEX, site_text), ""][0] - if name: - if name[0] not in enabled_sites: - continue - sites[name[0]] = provider_text[0] + if name in old_sites.keys(): # if already in previous list use old status and name + sites[name] = { + "name": old_sites[name]['name'], + "url": provider_url if provider_url else old_sites[name]['url'], + "status": old_sites[name]['status'] + } + else: # if not in previous list add with new data + display_name = name + if display_name.endswith("Provider"): + display_name = display_name[:-len("Provider")] + sites[name] = { + "name": display_name, + "url": provider_url if provider_url else "", + "status": 1 + } except Exception as ex: print("{0}: {1}".format(path, ex)) + +# add sites from old_sites that are missing in new list +for name in old_sites.keys(): + if name not in sites.keys(): + sites[name] = { + "name": old_sites[name]['name'], + "url": old_sites[name]['url'], + "status": old_sites[name]['status'] + } - -with open("README.md", "r+", encoding='utf-8') as readme: - raw = readme.read() - if START_MARKER not in raw or END_MARKER not in raw: - raise RuntimeError("Missing start and end markers") - readme.seek(0) - - readme.write(raw.split(START_MARKER)[0]) - readme.write(START_MARKER+"\n") - - for site in enabled_sites: - if site in sites: - readme.write( - "- [{0}]({1}) \n".format(sub("^https?://(?:www\.)?", "", sites[site]), sites[site])) - - readme.write(END_MARKER) - readme.write(raw.split(END_MARKER)[-1]) - - readme.truncate() +dump(sites, open(JSON_PATH, "w+", encoding="utf-8"), indent=4, sort_keys=True) diff --git a/.github/workflows/site_list.yml b/.github/workflows/site_list.yml index 81a9dc1a6..ab2d30dd1 100644 --- a/.github/workflows/site_list.yml +++ b/.github/workflows/site_list.yml @@ -4,10 +4,10 @@ on: push: branches: [ master ] paths: - - 'README.md' - 'app/src/main/java/com/lagradost/cloudstream3/*providers/*Provider.kt' - '.github/workflows/site_list.yml' - '.github/site-list.py' + - 'docs/providers.json' - 'app/src/main/java/com/lagradost/cloudstream3/MainAPI.kt' concurrency: @@ -19,7 +19,7 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - - name: Edit README.md + - name: Edit providers.json run: | python3 .github/site-list.py - name: Commit to the repo diff --git a/README.md b/README.md index 1bdb95cbe..2d42a363e 100644 --- a/README.md +++ b/README.md @@ -58,53 +58,5 @@ It merely scrapes 3rd-party websites that are publicly accessable via any regula ***Sites used:*** -https://lagradost.github.io/CloudStream-3/ - - -- [pelisplus.icu](https://pelisplus.icu) -- [pelismart.com](https://pelismart.com) -- [melomovie.com](https://melomovie.com) -- [doramasyt.com](https://doramasyt.com) -- [cuevana3.me](https://cuevana3.me) -- [pelisflix.li](https://pelisflix.li) -- [seriesflix.video](https://seriesflix.video) -- [ihavenotv.com](https://ihavenotv.com) -- [lookmovie.io](https://lookmovie.io) -- [vmovee.watch](https://www.vmovee.watch) -- [allmoviesforyou.net](https://allmoviesforyou.net) -- [vidembed.cc](https://vidembed.cc) -- [vf-film.me](https://vf-film.me) -- [vf-serie.org](https://vf-serie.org) -- [asianembed.io](https://asianembed.io) -- [asiaflix.app](https://asiaflix.app) -- [fmovies.to](https://fmovies.to) -- [filman.cc](https://filman.cc) -- [dopebox.to](https://dopebox.to) -- [pinoymoviepedia.ru](https://pinoymoviepedia.ru) -- [pinoy-hd.xyz](https://www.pinoy-hd.xyz) -- [pinoymovies.es](https://pinoymovies.es) -- [trailers.to](https://trailers.to) -- [2embed.ru](https://www.2embed.ru) -- [dramasee.net](https://dramasee.net) -- [watchasian.sh](https://watchasian.sh) -- [kdramahood.com](https://kdramahood.com) -- [akwam.to](https://akwam.to) -- [mycima.tv](https://mycima.tv) -- [egy.best](https://www.egy.best) -- [hdm.to](https://hdm.to) -- [theflix.to](https://theflix.to) -- [v2.apimdb.net](https://v2.apimdb.net) -- [wcostream.com](https://www.wcostream.com) -- [gogoanime.film](https://gogoanime.film) -- [allanime.site](https://allanime.site) -- [animekisa.in](https://animekisa.in) -- [animeflick.net](https://animeflick.net) -- [tenshi.moe](https://tenshi.moe) -- [wcostream.cc](https://wcostream.cc) -- [9anime.id](https://9anime.id) -- [animeworld.tv](https://www.animeworld.tv) -- [zoro.to](https://zoro.to) -- [bestdubbedanime.com](https://bestdubbedanime.com) -- [monoschinos2.com](https://monoschinos2.com) -- [kawaiifu.com](https://kawaiifu.com) - + +Look [here](https://lagradost.github.io/CloudStream-3/) for a comprehensive list diff --git a/docs/index.html b/docs/index.html index a19815dae..2db8f3867 100644 --- a/docs/index.html +++ b/docs/index.html @@ -7,131 +7,17 @@