diff --git a/README.md b/README.md index 16bb248..b35bcbf 100644 --- a/README.md +++ b/README.md @@ -16,6 +16,7 @@ Alfred search suggest workflow for various popular websites. Inspired by the off * [Sina Weibo (新浪微博)](#sina-weibo) * [Taobao (淘宝)](#taobao) * [JoyBuy (京东)](#joybuy) +* [Bangumi (番组计划)](#bangumi) * [Moegirlpedia (萌娘百科)](#moegirlpedia) ## Details @@ -28,7 +29,7 @@ Support basic suggestions. Proxy settings are available in the workflow environm ### Wikipedia -Support direct term suggestions and preview, language can be specified in the first arg. Proxy settings are available in the workflow environment variables. +Support direct term suggestions and preview, language can be specified with [ISO 639-1](https://en.wikipedia.org/wiki/ISO_639-1) code in the first arg. Proxy settings are available in the workflow environment variables. ![wikipedia-en](screenshots/wikipedia-en.png) @@ -82,6 +83,16 @@ Support basic suggestions. ![joybuy](screenshots/joybuy.png) +### Bangumi + +Support direct term suggestions and preview, type can be specified in the first arg. + +注:共支持 6 种条目类型的搜索,分别为全部(all)、动画(anime)、书籍(book)、音乐(music)、游戏(game)、三次元(real);对于每一条搜索结果,副标题默认显示该条目的类型(如果当前搜索类型为全部)和中文名称(若有),按 ⌘ 可显示其简介(若有),按 ⌃ 可显示其排名与评分(若有)。 + +![bangumi-all](screenshots/bangumi-all.png) + +![bangumi-anime](screenshots/bangumi-anime.png) + ### Moegirlpedia Support direct term suggestions and preview. diff --git a/screenshots/bangumi-all.png b/screenshots/bangumi-all.png new file mode 100644 index 0000000..55efd83 Binary files /dev/null and b/screenshots/bangumi-all.png differ diff --git a/screenshots/bangumi-anime.png b/screenshots/bangumi-anime.png new file mode 100644 index 0000000..38f4504 Binary files /dev/null and b/screenshots/bangumi-anime.png differ diff --git a/src/7C5A1AA4-8766-42A7-ADC5-6B91963B3CD9.png b/src/7C5A1AA4-8766-42A7-ADC5-6B91963B3CD9.png new file mode 100644 index 0000000..d8f57a9 Binary files /dev/null and b/src/7C5A1AA4-8766-42A7-ADC5-6B91963B3CD9.png differ diff --git a/src/bangumi.php b/src/bangumi.php new file mode 100644 index 0000000..0a9f82d --- /dev/null +++ b/src/bangumi.php @@ -0,0 +1,72 @@ + 0, + 'book' => 1, + 'anime' => 2, + 'music' => 3, + 'game' => 4, + 'real' => 6 + ); + $typeId = $typeIdDict[$type]; + + $response = request('https://api.bgm.tv/search/subject/'.urlencode($query)."?responseGroup=large&type=$typeId"); + $json = json_decode($response); + $results = $json->list; + + $typeNameDict = array( + 0 => '全部', + 1 => '书籍', + 2 => '动画', + 3 => '音乐', + 4 => '游戏', + 6 => '三次元' + ); + + if ($results) { + foreach ($results as $sugg) { + $name = $sugg->name; + $nameCN = $sugg->name_cn; + $url = $sugg->url; + $rank = $sugg->rank; + $score = $sugg->rating->score; + $wf->result() + ->title($name) + ->subtitle(($type === 'all' ? '【'.$typeNameDict[$sugg->type].'】' : '').$nameCN) + ->arg($url) + ->icon(saveAndReturnFile($sugg->images->small)) + ->autocomplete($name) + ->cmd(str_replace("\r\n", '', $sugg->summary), $url) + ->ctrl(($rank === 0 ? '' : "Rank: $rank ").($score === 0 ? '' : "Score: $score"), $url) + ->copy($name) + ->quicklookurl($url); + } + } + + $wf->result() + ->title("Search 番组计划 for '$query'") + ->subtitle($typeNameDict[$typeId].'条目') + ->arg('http://bgm.tv/subject_search/'.urlencode($query)."?cat=$typeId") + ->icon(ICON) + ->copy($query); +} + +echo $wf->output(); diff --git a/src/info.plist b/src/info.plist index d20c298..ffbcc22 100644 --- a/src/info.plist +++ b/src/info.plist @@ -86,6 +86,19 @@ + 7C5A1AA4-8766-42A7-ADC5-6B91963B3CD9 + + + destinationuid + A8AA5019-512C-4773-83FC-35FEA14DD158 + modifiers + 0 + modifiersubtext + + vitoclose + + + 80FCED49-07AA-4C15-9B49-24A52B3AF5D6 @@ -707,7 +720,7 @@ require_once('sinaweibo.php'); spaces url - http://s.weibo.com/weibo/{query} + https://s.weibo.com/weibo/{query} utf8 @@ -718,6 +731,25 @@ require_once('sinaweibo.php'); version 1 + + config + + browser + + spaces + + url + https://s.taobao.com/search?q={query} + utf8 + + + type + alfred.workflow.action.openurl + uid + 89D407F2-9C8D-403B-9503-AE755F3474B2 + version + 1 + config @@ -775,17 +807,66 @@ require_once('taobao.php'); spaces url - https://s.taobao.com/search?q={query} + https://search.jd.com/Search?enc=utf-8&keyword={query} utf8 type alfred.workflow.action.openurl uid - 89D407F2-9C8D-403B-9503-AE755F3474B2 + A76FF79E-3778-4855-93AA-20969F1A152A version 1 + + config + + alfredfiltersresults + + alfredfiltersresultsmatchmode + 0 + argumenttrimmode + 0 + argumenttype + 0 + escaping + 36 + keyword + jd + queuedelaycustom + 3 + queuedelayimmediatelyinitially + + queuedelaymode + 0 + queuemode + 2 + runningsubtext + Retrieving search suggestions ... + script + $query = "{query}"; + +require_once('joybuy.php'); + scriptargtype + 0 + scriptfile + + subtext + Search 京东 with Suggestions + title + Search 京东 + type + 1 + withspace + + + type + alfred.workflow.input.scriptfilter + uid + B1C4E5F1-FE5D-4505-9AD6-3F12A4F4ACC8 + version + 2 + config @@ -794,14 +875,14 @@ require_once('taobao.php'); spaces url - https://search.jd.com/Search?enc=utf-8&keyword={query} + {query} utf8 type alfred.workflow.action.openurl uid - A76FF79E-3778-4855-93AA-20969F1A152A + A8AA5019-512C-4773-83FC-35FEA14DD158 version 1 @@ -819,7 +900,7 @@ require_once('taobao.php'); escaping 36 keyword - jd + bgm queuedelaycustom 3 queuedelayimmediatelyinitially @@ -833,15 +914,15 @@ require_once('taobao.php'); script $query = "{query}"; -require_once('joybuy.php'); +require_once('bangumi.php'); scriptargtype 0 scriptfile subtext - Search 京东 with Suggestions + Search 番组计划 with Suggestions title - Search 京东 + Search 番组计划 type 1 withspace @@ -850,7 +931,7 @@ require_once('joybuy.php'); type alfred.workflow.input.scriptfilter uid - B1C4E5F1-FE5D-4505-9AD6-3F12A4F4ACC8 + 7C5A1AA4-8766-42A7-ADC5-6B91963B3CD9 version 2 @@ -984,6 +1065,13 @@ require_once('moegirlpedia.php'); 590 7999A242-8DB6-41F9-BAD7-78C3E4CC0C41 + + xpos + 50 + ypos + 1570 + + 7C5A1AA4-8766-42A7-ADC5-6B91963B3CD9 xpos 50 @@ -1032,6 +1120,13 @@ require_once('moegirlpedia.php'); ypos 1290 + A8AA5019-512C-4773-83FC-35FEA14DD158 + + xpos + 270 + ypos + 1430 + AE15F1F6-37B0-4A47-BEE1-975354A81227 xpos @@ -1079,7 +1174,7 @@ require_once('moegirlpedia.php'); xpos 270 ypos - 1430 + 1570 variables @@ -1098,7 +1193,7 @@ require_once('moegirlpedia.php'); proxy_address version - 1.6 + 1.7 webaddress https://github.com/AkikoZ/alfred-web-search-suggest