-
Notifications
You must be signed in to change notification settings - Fork 881
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
142 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
"name": "TMDB", | ||
"ver": "0.0.1", | ||
"plugins": [ | ||
{ | ||
"name": "影视详情页", | ||
"pages": [ | ||
"\/movie\/\\d+(-.+)?", | ||
"\/tv\/\\d+(-.+)?" | ||
], | ||
"scripts": [ | ||
"media.js" | ||
] | ||
} | ||
], | ||
"schema": "publicSite", | ||
"host": "www.themoviedb.org", | ||
"path": "themoviedb.org" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
(function ($, window) { | ||
console.log("themoviedb.org media.js is loaded."); | ||
class App { | ||
async init() { | ||
this.initButtons(); | ||
// 设置当前页面 | ||
PTService.pageApp = this; | ||
} | ||
|
||
/** | ||
* 初始化按钮列表 | ||
*/ | ||
async initButtons() { | ||
let IMDbId = await this.getIMDbId(); | ||
if (IMDbId) { | ||
// 搜索 | ||
PTService.addButton({ | ||
title: "搜索当前电影", | ||
icon: "search", | ||
label: "搜索", | ||
click: (success, error) => { | ||
PTService.call( | ||
PTService.action.openOptions, | ||
`search-torrent/${IMDbId}` | ||
); | ||
success(); | ||
} | ||
}); | ||
} | ||
} | ||
|
||
/** | ||
* 获取 IMDb 编号 | ||
*/ | ||
async getIMDbId() { | ||
const paths = location.pathname.split("/"); | ||
try { | ||
const type = paths[1]; | ||
const id = parseInt(paths[2]); | ||
// 获取IMDb ID | ||
const result = await PTService.call( | ||
PTService.action.getIMDbIdFromTMDB, | ||
{ | ||
id, | ||
type | ||
} | ||
); | ||
|
||
console.log("getIMDbId", result); | ||
|
||
return result; | ||
} catch (error) {} | ||
|
||
return ""; | ||
} | ||
} | ||
new App().init(); | ||
})(jQuery, window); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters