- refactored scraper filter function
- added ability to specify default scrapers in environment variables
This commit is contained in:
@@ -0,0 +1,115 @@
|
||||
<?php
|
||||
|
||||
const DEFAULT_SCRAPERS = [
|
||||
"web" => config::SCRAPER_WEB,
|
||||
"images" => config::SCRAPER_IMAGES,
|
||||
"news" => config::SCRAPER_NEWS,
|
||||
"videos" => config::SCRAPER_VIDEOS,
|
||||
"music" => config::SCRAPER_MUSIC,
|
||||
];
|
||||
|
||||
const AVAILABLE_SCRAPERS = [
|
||||
"web" => [
|
||||
"ddg" => "DuckDuckGo",
|
||||
//"yahoo" => "Yahoo!",
|
||||
"brave" => "Brave",
|
||||
"yandex" => "Yandex",
|
||||
"google" => "Google",
|
||||
"google_api" => "Google API",
|
||||
"google_cse" => "Google CSE",
|
||||
"yahoo_japan" => "Yahoo! JAPAN",
|
||||
"startpage" => "Startpage",
|
||||
"qwant" => "Qwant",
|
||||
"ghostery" => "Ghostery",
|
||||
"yep" => "Yep",
|
||||
"mwmbl" => "Mwmbl",
|
||||
"mojeek" => "Mojeek",
|
||||
"baidu" => "Baidu",
|
||||
"coccoc" => "Cốc Cốc",
|
||||
"solofield" => "Solofield",
|
||||
"marginalia" => "Marginalia",
|
||||
"wiby" => "wiby"
|
||||
],
|
||||
"images" => [
|
||||
"ddg" => "DuckDuckGo",
|
||||
"yandex" => "Yandex",
|
||||
"brave" => "Brave",
|
||||
"google" => "Google",
|
||||
"google_api" => "Google API",
|
||||
"google_cse" => "Google CSE",
|
||||
"yahoo_japan" => "Yahoo! JAPAN",
|
||||
"startpage" => "Startpage",
|
||||
"qwant" => "Qwant",
|
||||
"baidu" => "Baidu",
|
||||
"solofield" => "Solofield",
|
||||
"pinterest" => "Pinterest",
|
||||
"cara" => "Cara",
|
||||
"flickr" => "Flickr",
|
||||
"pexels" => "Pexels",
|
||||
"pixabay" => "Pixabay",
|
||||
"unsplash" => "Unsplash",
|
||||
"fivehpx" => "500px",
|
||||
"vsco" => "VSCO",
|
||||
"imgur" => "Imgur",
|
||||
"ftm" => "FindThatMeme"
|
||||
],
|
||||
|
||||
"videos" => [
|
||||
"yt" => "YouTube",
|
||||
//"archiveorg" => "Archive.org",
|
||||
"vimeo" => "Vimeo",
|
||||
//"odysee" => "Odysee",
|
||||
"sepiasearch" => "Sepia Search",
|
||||
//"fb" => "Facebook videos",
|
||||
"ddg" => "DuckDuckGo",
|
||||
"brave" => "Brave",
|
||||
"yandex" => "Yandex",
|
||||
"google" => "Google",
|
||||
"yahoo_japan" => "Yahoo! JAPAN",
|
||||
"startpage" => "Startpage",
|
||||
"qwant" => "Qwant",
|
||||
"baidu" => "Baidu",
|
||||
"coccoc" => "Cốc Cốc",
|
||||
"solofield" => "Solofield"
|
||||
],
|
||||
|
||||
"news" => [
|
||||
"ddg" => "DuckDuckGo",
|
||||
"brave" => "Brave",
|
||||
"google" => "Google",
|
||||
"yahoo_japan" => "Yahoo! JAPAN",
|
||||
"startpage" => "Startpage",
|
||||
"qwant" => "Qwant",
|
||||
"mojeek" => "Mojeek",
|
||||
"baidu" => "Baidu"
|
||||
],
|
||||
|
||||
"music" => [
|
||||
"sc" => "SoundCloud",
|
||||
"swisscows" => "Swisscows (SoundCloud)",
|
||||
//"spotify" => "Spotify"
|
||||
],
|
||||
|
||||
"booru" => [
|
||||
"safebooru" => "Safebooru",
|
||||
"konachan" => "Konachan",
|
||||
"tbib" => "The Big Imageboard",
|
||||
"gelbooru" => "Gelbooru",
|
||||
"yandere" => "Yande.re",
|
||||
"sankakucomplex" => "SankakuComplex",
|
||||
"soybooru" => "SoyBooru",
|
||||
],
|
||||
];
|
||||
|
||||
function get_scraper(string $page, string $selected): string
|
||||
{
|
||||
$available = AVAILABLE_SCRAPERS[$page];
|
||||
if (!$available) {
|
||||
return "__NONEXISTENT__";
|
||||
}
|
||||
if ($available[$selected]) {
|
||||
return $selected;
|
||||
}
|
||||
$default = DEFAULT_SCRAPERS[$page];
|
||||
return $available[$default] ? $default : array_key_first($available);
|
||||
}
|
||||
Reference in New Issue
Block a user