[Feature] Display language on github page site list. (#1038)

* add language to gh page

* display language on page

* fixes

* log for debugging

* handle error on parsing language

* minor change

* rename some providers for consistency on naming conventions.

* fixes on site-list generator script:
- fix key name, use classname from content. defaults to filename.
- fix provider display name, use name from content. defaults to filename.
- only build from animeproviders and movieproviders path. prevents unnecessary objects populating json file.
This commit is contained in:
Jace 2022-05-08 20:57:30 +08:00 committed by GitHub
parent cb4ab7ea23
commit 6f05154f50
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 100 additions and 39 deletions

31
.github/site-list.py vendored
View file

@ -6,41 +6,52 @@ from json import dump, load
from typing import List, Dict from typing import List, Dict
# Globals # Globals
URL_REGEX = compile(
"override\sva[lr]\smainUrl[^\"']+[\"'](https?://[a-zA-Z0-9\.-]+)[\"']")
NAME_REGEX = compile("([A-Za-z0-9]+)(?:.kt)$")
JSON_PATH = "docs/providers.json" JSON_PATH = "docs/providers.json"
GLOB = "app/src/main/java/com/lagradost/cloudstream3/*providers/*Provider.kt" GLOB_ANIME = "app/src/main/java/com/lagradost/cloudstream3/animeproviders/*Provider.kt"
GLOB_MOVIE = "app/src/main/java/com/lagradost/cloudstream3/movieproviders/*Provider.kt"
URL_REGEX = compile("override\sva[lr]\smainUrl[^\"']+[\"'](https?://[a-zA-Z0-9\.-]+)[\"']")
FILENAME_REGEX = compile("([A-Za-z0-9]+)(?:.kt)$")
PROVIDER_CLASSNAME_REGEX = compile("(?<=class\s)([a-zA-Z]+)(?=\s:\sMainAPI\(\))")
NAME_REGEX = compile("override\sva[lr]\sname[^\"']+[\"']([a-zA-Z-.\s]+)")
LANG_REGEX = compile("override\sva[lr]\slang[^\"']+[\"']([a-zA-Z]+)")
old_sites: Dict[str, Dict] = load(open(JSON_PATH, "r", encoding="utf-8")) old_sites: Dict[str, Dict] = load(open(JSON_PATH, "r", encoding="utf-8"))
sites: Dict[str, Dict] = {} sites: Dict[str, Dict] = {}
animelist = glob(GLOB_ANIME)
movielist = glob(GLOB_MOVIE)
allProvidersList = animelist + movielist
# parse all *Provider.kt files # parse all *Provider.kt files
for path in glob(GLOB): for path in allProvidersList:
with open(path, "r", encoding='utf-8') as file: with open(path, "r", encoding='utf-8') as file:
try: try:
site_text: str = file.read() site_text: str = file.read()
name: str = findall(NAME_REGEX, path)[0] filename: str = findall(FILENAME_REGEX, path)[0]
name: str = [*findall(PROVIDER_CLASSNAME_REGEX, site_text), filename][0]
provider_url: str = [*findall(URL_REGEX, site_text), ""][0] provider_url: str = [*findall(URL_REGEX, site_text), ""][0]
lang: str = [*findall(LANG_REGEX, site_text), "en"][0]
if name in old_sites.keys(): # if already in previous list use old status and name if name in old_sites.keys(): # if already in previous list use old status and name
sites[name] = { sites[name] = {
"name": old_sites[name]['name'], "name": old_sites[name]['name'],
"url": provider_url if provider_url else old_sites[name]['url'], "url": provider_url if provider_url else old_sites[name]['url'],
"status": old_sites[name]['status'] "status": old_sites[name]['status'],
"language": lang
} }
else: # if not in previous list add with new data else: # if not in previous list add with new data
display_name = name display_name: str = [*findall(NAME_REGEX, site_text), name][0]
if display_name.endswith("Provider"): if display_name.endswith("Provider"):
display_name = display_name[:-len("Provider")] display_name = display_name[:-len("Provider")]
sites[name] = { sites[name] = {
"name": display_name, "name": display_name,
"url": provider_url if provider_url else "", "url": provider_url if provider_url else "",
"status": 1 "status": 1,
"language": lang
} }
except Exception as ex: except Exception as ex:
print("{0}: {1}".format(path, ex)) print("Error => {0}: {1}".format(path, ex))
# add sites from old_sites that are missing in new list # add sites from old_sites that are missing in new list
for name in old_sites.keys(): for name in old_sites.keys():

View file

@ -1,110 +1,120 @@
{ {
"AkwamProvider": { "AkwamProvider": {
"language": "ar",
"name": "Akwam", "name": "Akwam",
"status": 1, "status": 1,
"url": "https://akwam.to" "url": "https://akwam.to"
}, },
"AllAnimeProvider": { "AllAnimeProvider": {
"language": "en",
"name": "AllAnime", "name": "AllAnime",
"status": 1, "status": 1,
"url": "https://allanime.site" "url": "https://allanime.site"
}, },
"AllMoviesForYouProvider": { "AllMoviesForYouProvider": {
"language": "en",
"name": "AllMoviesForYou", "name": "AllMoviesForYou",
"status": 1, "status": 1,
"url": "https://allmoviesforyou.net" "url": "https://allmoviesforyou.net"
}, },
"AnimeFlickProvider": { "AnimeFlickProvider": {
"language": "en",
"name": "AnimeFlick", "name": "AnimeFlick",
"status": 1, "status": 1,
"url": "https://animeflick.net" "url": "https://animeflick.net"
}, },
"AnimePaheProvider": { "AnimePaheProvider": {
"language": "en",
"name": "AnimePahe", "name": "AnimePahe",
"status": 0, "status": 0,
"url": "https://animepahe.com" "url": "https://animepahe.com"
}, },
"AnimeWorldProvider": { "AnimeWorldProvider": {
"language": "it",
"name": "AnimeWorld", "name": "AnimeWorld",
"status": 1, "status": 1,
"url": "https://www.animeworld.tv" "url": "https://www.animeworld.tv"
}, },
"AnimeflvProvider": {
"name": "Animeflv",
"status": 1,
"url": "https://www3.animeflv.net"
},
"AnimeflvnetProvider": { "AnimeflvnetProvider": {
"language": "es",
"name": "Animeflv.net", "name": "Animeflv.net",
"status": 1, "status": 1,
"url": "https://www3.animeflv.net" "url": "https://www3.animeflv.net"
}, },
"AnimekisaProvider": { "AnimekisaProvider": {
"language": "en",
"name": "Animekisa", "name": "Animekisa",
"status": 1, "status": 1,
"url": "https://animekisa.in" "url": "https://animekisa.in"
}, },
"ApiMDBProvider": { "ApiMDBProvider": {
"language": "en",
"name": "ApiMDB", "name": "ApiMDB",
"status": 1, "status": 1,
"url": "https://v2.apimdb.net" "url": "https://v2.apimdb.net"
}, },
"AsiaFlixProvider": { "AsiaFlixProvider": {
"language": "en",
"name": "AsiaFlix", "name": "AsiaFlix",
"status": 3, "status": 3,
"url": "https://asiaflix.app" "url": "https://asiaflix.app"
}, },
"AsianLoadProvider": { "AsianLoadProvider": {
"language": "en",
"name": "AsianLoad", "name": "AsianLoad",
"status": 1, "status": 1,
"url": "https://asianembed.io" "url": "https://asianembed.io"
}, },
"BflixProvider": { "BflixProvider": {
"language": "en",
"name": "Bflix", "name": "Bflix",
"status": 1, "status": 1,
"url": "https://bflix.ru" "url": "https://bflix.ru"
}, },
"CinecalidadProvider": { "CinecalidadProvider": {
"language": "es",
"name": "Cinecalidad", "name": "Cinecalidad",
"status": 1, "status": 1,
"url": "https://cinecalidad.lol" "url": "https://cinecalidad.lol"
}, },
"CrossTmdbProvider": {
"name": "MultiMovie",
"status": 1,
"url": "NONE"
},
"CuevanaProvider": { "CuevanaProvider": {
"language": "es",
"name": "Cuevana", "name": "Cuevana",
"status": 1, "status": 1,
"url": "https://cuevana3.me" "url": "https://cuevana3.me"
}, },
"DopeboxProvider": { "DopeboxProvider": {
"language": "en",
"name": "Dopebox", "name": "Dopebox",
"status": 1, "status": 1,
"url": "https://dopebox.to" "url": "https://dopebox.to"
}, },
"DoramasYTProvider": { "DoramasYTProvider": {
"language": "es",
"name": "DoramasYT", "name": "DoramasYT",
"status": 1, "status": 1,
"url": "https://doramasyt.com" "url": "https://doramasyt.com"
}, },
"DramaSeeProvider": { "DramaSeeProvider": {
"language": "en",
"name": "DramaSee", "name": "DramaSee",
"status": 1, "status": 1,
"url": "https://dramasee.net" "url": "https://dramasee.net"
}, },
"DreamSubProvider": { "DreamSubProvider": {
"language": "it",
"name": "DreamSub", "name": "DreamSub",
"status": 1, "status": 1,
"url": "https://dreamsub.me" "url": "https://dreamsub.me"
}, },
"DubbedAnimeProvider": { "DubbedAnimeProvider": {
"language": "en",
"name": "DubbedAnime", "name": "DubbedAnime",
"status": 1, "status": 1,
"url": "https://bestdubbedanime.com" "url": "https://bestdubbedanime.com"
}, },
"EgyBestProvider": { "EgyBestProvider": {
"language": "ar",
"name": "EgyBest", "name": "EgyBest",
"status": 1, "status": 1,
"url": "https://www.egy.best" "url": "https://www.egy.best"
@ -115,226 +125,253 @@
"url": "https://entrepeliculasyseries.nu" "url": "https://entrepeliculasyseries.nu"
}, },
"EntrepeliculasyseriesProvider": { "EntrepeliculasyseriesProvider": {
"language": "es",
"name": "EntrePeliculasySeries", "name": "EntrePeliculasySeries",
"status": 1, "status": 1,
"url": "https://entrepeliculasyseries.nu" "url": "https://entrepeliculasyseries.nu"
}, },
"FaselHDProvider": { "FaselHDProvider": {
"language": "ar",
"name": "FaselHD", "name": "FaselHD",
"status": 1, "status": 1,
"url": "https://faselhd.io" "url": "https://faselhd.io"
}, },
"FilmanProvider": { "FilmanProvider": {
"language": "pl",
"name": "filman.cc", "name": "filman.cc",
"status": 1, "status": 1,
"url": "https://filman.cc" "url": "https://filman.cc"
}, },
"FmoviesToProvider": { "FmoviesToProvider": {
"language": "en",
"name": "Fmovies.to", "name": "Fmovies.to",
"status": 1, "status": 1,
"url": "https://fmovies.to" "url": "https://fmovies.to"
}, },
"FrenchStreamProvider": { "FrenchStreamProvider": {
"language": "fr",
"name": "French Stream", "name": "French Stream",
"status": 1, "status": 1,
"url": "https://french-stream.re" "url": "https://french-stream.re"
}, },
"GogoanimeProvider": { "GogoanimeProvider": {
"language": "en",
"name": "GogoAnime", "name": "GogoAnime",
"status": 1, "status": 1,
"url": "https://gogoanime.film" "url": "https://gogoanime.film"
}, },
"HDMProvider": { "HDMProvider": {
"language": "en",
"name": "HD Movies", "name": "HD Movies",
"status": 0, "status": 0,
"url": "https://hdm.to" "url": "https://hdm.to"
}, },
"IHaveNoTvProvider": { "IHaveNoTvProvider": {
"language": "en",
"name": "I Have No TV", "name": "I Have No TV",
"status": 1, "status": 1,
"url": "https://ihavenotv.com" "url": "https://ihavenotv.com"
}, },
"KawaiifuProvider": { "KawaiifuProvider": {
"language": "en",
"name": "Kawaiifu", "name": "Kawaiifu",
"status": 0, "status": 0,
"url": "https://kawaiifu.com" "url": "https://kawaiifu.com"
}, },
"KdramaHoodProvider": { "KdramaHoodProvider": {
"language": "en",
"name": "KDramaHood", "name": "KDramaHood",
"status": 1, "status": 1,
"url": "https://kdramahood.com" "url": "https://kdramahood.com"
}, },
"LookMovieProvider": { "LookMovieProvider": {
"language": "en",
"name": "LookMovie", "name": "LookMovie",
"status": 0, "status": 0,
"url": "https://lookmovie.io" "url": "https://lookmovie.io"
}, },
"MeloMovieProvider": { "MeloMovieProvider": {
"language": "en",
"name": "MeloMovie", "name": "MeloMovie",
"status": 0, "status": 0,
"url": "https://melomovie.com" "url": "https://melomovie.com"
}, },
"MonoschinosProvider": { "MonoschinosProvider": {
"language": "es",
"name": "Monoschinos", "name": "Monoschinos",
"status": 1, "status": 1,
"url": "https://monoschinos2.com" "url": "https://monoschinos2.com"
}, },
"MultiAnimeProvider": {
"name": "MultiAnime",
"status": 1,
"url": ""
},
"MyCimaProvider": { "MyCimaProvider": {
"language": "ar",
"name": "MyCima", "name": "MyCima",
"status": 1, "status": 1,
"url": "https://mycima.tv" "url": "https://mycima.tv"
}, },
"NginxProvider": { "NginxProvider": {
"language": "en",
"name": "Nginx", "name": "Nginx",
"status": 1, "status": 1,
"url": "" "url": ""
}, },
"NineAnimeProvider": { "NineAnimeProvider": {
"language": "en",
"name": "9Anime", "name": "9Anime",
"status": 1, "status": 1,
"url": "https://9anime.id" "url": "https://9anime.id"
}, },
"NyaaProvider": {
"name": "Nyaa",
"status": 1,
"url": "https://nyaa.si"
},
"PeliSmartProvider": { "PeliSmartProvider": {
"language": "es",
"name": "PeliSmart", "name": "PeliSmart",
"status": 1, "status": 1,
"url": "https://pelismart.com" "url": "https://pelismart.com"
}, },
"PelisflixProvider": { "PelisflixProvider": {
"language": "es",
"name": "Pelisflix", "name": "Pelisflix",
"status": 1, "status": 1,
"url": "https://pelisflix.li" "url": "https://pelisflix.li"
}, },
"PelisplusHDProvider": { "PelisplusHDProvider": {
"language": "es",
"name": "PelisplusHD", "name": "PelisplusHD",
"status": 1, "status": 1,
"url": "https://pelisplushd.net" "url": "https://pelisplushd.net"
}, },
"PelisplusProvider": { "PelisplusProvider": {
"language": "en",
"name": "Pelisplus", "name": "Pelisplus",
"status": 1, "status": 1,
"url": "https://pelisplus.icu" "url": "https://pelisplus.icu"
}, },
"PinoyHDXyzProvider": { "PinoyHDXyzProvider": {
"language": "tl",
"name": "Pinoy-HD", "name": "Pinoy-HD",
"status": 1, "status": 1,
"url": "https://www.pinoy-hd.xyz" "url": "https://www.pinoy-hd.xyz"
}, },
"PinoyMoviePediaProvider": { "PinoyMoviePediaProvider": {
"language": "tl",
"name": "Pinoy Moviepedia", "name": "Pinoy Moviepedia",
"status": 1, "status": 1,
"url": "https://pinoymoviepedia.ru" "url": "https://pinoymoviepedia.ru"
}, },
"PinoyMoviesEsProvider": { "PinoyMoviesEsProvider": {
"language": "tl",
"name": "Pinoy Movies", "name": "Pinoy Movies",
"status": 1, "status": 1,
"url": "https://pinoymovies.es" "url": "https://pinoymovies.es"
}, },
"SeriesflixProvider": { "SeriesflixProvider": {
"language": "es",
"name": "Seriesflix", "name": "Seriesflix",
"status": 1, "status": 1,
"url": "https://seriesflix.video" "url": "https://seriesflix.video"
}, },
"SflixProProvider": { "SflixProProvider": {
"language": "en",
"name": "Sflix.pro", "name": "Sflix.pro",
"status": 1, "status": 1,
"url": "https://sflix.pro" "url": "https://sflix.pro"
}, },
"SflixProvider": { "SflixProvider": {
"language": "en",
"name": "Sflix.to", "name": "Sflix.to",
"status": 1, "status": 1,
"url": "https://sflix.to" "url": "https://sflix.to"
}, },
"SoaptwoDayProvider": { "SoaptwoDayProvider": {
"language": "en",
"name": "Soap2Day", "name": "Soap2Day",
"status": 1, "status": 1,
"url": "https://secretlink.xyz" "url": "https://secretlink.xyz"
}, },
"SolarmovieProvider": { "SolarmovieProvider": {
"language": "en",
"name": "Solarmovie", "name": "Solarmovie",
"status": 1, "status": 1,
"url": "https://solarmovie.pe" "url": "https://solarmovie.pe"
}, },
"StreamingcommunityProvider": { "StreamingcommunityProvider": {
"language": "it",
"name": "Streamingcommunity", "name": "Streamingcommunity",
"status": 1, "status": 1,
"url": "https://streamingcommunity.top" "url": "https://streamingcommunity.top"
}, },
"TantiFilmProvider": { "TantifilmProvider": {
"name": "TantiFilm", "language": "it",
"name": "Tantifilm",
"status": 1, "status": 1,
"url": "https://www.tantifilm.rodeo" "url": "https://www.tantifilm.rodeo"
}, },
"TenshiProvider": { "TenshiProvider": {
"language": "en",
"name": "Tenshi.moe", "name": "Tenshi.moe",
"status": 1, "status": 1,
"url": "https://tenshi.moe" "url": "https://tenshi.moe"
}, },
"TheFlixToProvider": { "TheFlixToProvider": {
"language": "en",
"name": "TheFlix.to", "name": "TheFlix.to",
"status": 0, "status": 0,
"url": "https://theflix.to" "url": "https://theflix.to"
}, },
"TmdbProvider": {
"name": "Tmdb",
"status": 1,
"url": ""
},
"TrailersTwoProvider": { "TrailersTwoProvider": {
"language": "en",
"name": "Trailers.to", "name": "Trailers.to",
"status": 1, "status": 1,
"url": "https://trailers.to" "url": "https://trailers.to"
}, },
"TwoEmbedProvider": { "TwoEmbedProvider": {
"language": "en",
"name": "2Embed", "name": "2Embed",
"status": 1, "status": 1,
"url": "https://www.2embed.ru" "url": "https://www.2embed.ru"
}, },
"VMoveeProvider": { "VMoveeProvider": {
"language": "en",
"name": "VMovee", "name": "VMovee",
"status": 1, "status": 1,
"url": "https://www.vmovee.watch" "url": "https://www.vmovee.watch"
}, },
"VfFilmProvider": { "VfFilmProvider": {
"language": "fr",
"name": "vf-film.me", "name": "vf-film.me",
"status": 1, "status": 1,
"url": "https://vf-film.me" "url": "https://vf-film.me"
}, },
"VfSerieProvider": { "VfSerieProvider": {
"language": "fr",
"name": "vf-serie.org", "name": "vf-serie.org",
"status": 1, "status": 1,
"url": "https://vf-serie.org" "url": "https://vf-serie.org"
}, },
"VidEmbedProvider": { "VidEmbedProvider": {
"language": "en",
"name": "VidEmbed", "name": "VidEmbed",
"status": 1, "status": 1,
"url": "https://vidembed.cc" "url": "https://vidembed.cc"
}, },
"WatchAsianProvider": { "WatchAsianProvider": {
"language": "en",
"name": "WatchAsian", "name": "WatchAsian",
"status": 1, "status": 1,
"url": "https://watchasian.sh" "url": "https://watchasian.sh"
}, },
"WatchCartoonOnlineProvider": { "WatchCartoonOnlineProvider": {
"language": "en",
"name": "WatchCartoonOnline", "name": "WatchCartoonOnline",
"status": 1, "status": 1,
"url": "https://www.wcostream.com" "url": "https://www.wcostream.com"
}, },
"WcoProvider": { "WcoProvider": {
"language": "en",
"name": "WCO Stream", "name": "WCO Stream",
"status": 1, "status": 1,
"url": "https://wcostream.cc" "url": "https://wcostream.cc"
}, },
"ZoroProvider": { "ZoroProvider": {
"language": "en",
"name": "Zoro", "name": "Zoro",
"status": 1, "status": 1,
"url": "https://zoro.to" "url": "https://zoro.to"

View file

@ -1,5 +1,6 @@
const count = document.getElementById("count") const count = document.getElementById("count")
const mainContainer = document.getElementById("siteList"); const mainContainer = document.getElementById("siteList")
const regionNamesInEnglish = new Intl.DisplayNames(['en'], { type: 'language' });
fetch("providers.json" + "?v=" + Date.now()) fetch("providers.json" + "?v=" + Date.now())
.then(r => r.json()) .then(r => r.json())
.then(function (data) { .then(function (data) {
@ -10,6 +11,7 @@ fetch("providers.json" + "?v=" + Date.now())
if (value.url == "NONE") { continue; } if (value.url == "NONE") { continue; }
var _status = value.status var _status = value.status
var _lang = value.language
var node = document.createElement("tr"); var node = document.createElement("tr");
node.classList.add("row"); node.classList.add("row");
@ -18,6 +20,17 @@ fetch("providers.json" + "?v=" + Date.now())
_a.setAttribute('href', value.url); _a.setAttribute('href', value.url);
_a.innerHTML = value.name _a.innerHTML = value.name
var _langEl = document.createElement("sup");
var _langName = "Unknown";
try {
_langName = regionNamesInEnglish.of(_lang);
} catch (langerr) {
_langName = "Unknown";
console.log("Error on parsing language code => " + langerr);
}
_langEl.innerHTML = " " + _langName
_a.appendChild(_langEl);
var _statusText = "Unknown"; var _statusText = "Unknown";
var _buttonText = "yellow"; var _buttonText = "yellow";
switch (_status) { switch (_status) {