diff --git a/README.md b/README.md index 21b84af..c0f176b 100644 --- a/README.md +++ b/README.md @@ -2,24 +2,31 @@ ![GitHub package.json version (branch)](https://img.shields.io/github/package-json/v/videomanagertools/scraper/master) ![GitHub Release Date](https://img.shields.io/github/release-date/videomanagertools/scraper) -操作动图 -![gifhome_640x363_30s (1)](https://user-images.githubusercontent.com/20250430/65373590-3dc32780-dcb2-11e9-87a1-b946beb26996.gif) +### 食用指南 -检索信息截图 -![3](https://upload-images.jianshu.io/upload_images/19638980-6899616ee80e89fd.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240) +下载对应平台的安装包,安装,打开。 -在多媒体服务中显示的截图 -![1](https://upload-images.jianshu.io/upload_images/19638980-0272cb35f1bad544.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240) +#### 设置 -### 绅士版食用指南 +1. 预设标签 -下载对应平台的安装包,安装,打开。 +可以预设标签用于编辑电影自定义标签 + +2. 场景 + +目前有普通和绅士(滑稽),对应了不懂的信息源。 + +设置场景后,会在【检索信息】按钮后显示可用的数据源,可根据需要切换 + +3. 代理 + +部分源可能需要使用代理访问,GTW 没屏蔽,但是不同运营商可能会屏蔽。没有代理的绅士们请自行解决。。 #### 建议 第一次使用请先拉出来一个测试用的文件夹,熟悉各个操作的效果后,再大批量操作。数据无价,谨慎操作 -### 开发贡献 +### 开发 ```bash git clone https://github.com/videomanagertools/scraper.git @@ -38,17 +45,10 @@ npm run dev 因为电影和剧集已经有很多成熟好用的工具,如果没特殊需求,没计划做这两个 -其他的: - -1. 目前只支持步兵 -2. 信息源目前只支持 javbus,不支持切换 - -(后面有时间和需求就加骑兵和数据源) - 已知计划是 1. 增加音乐信息爬取 -2. 抽出来一个没有 GUI 的工具,可以在 NAS 的 docker 中定时跑 +2. 抽出来一个没有 GUI 的 CLI,可以在 NAS 的 docker 中定时跑 3. 可能会有一个整合的工具,把 Download,Scrape,Move Files 串联起来 ### 最后 diff --git a/app/containers/Home/HeaderContent/index.tsx b/app/containers/Home/HeaderContent/index.tsx index 98aebbb..06344db 100644 --- a/app/containers/Home/HeaderContent/index.tsx +++ b/app/containers/Home/HeaderContent/index.tsx @@ -12,7 +12,7 @@ import { changeSelected, changeFailureKeys } from '../../../actions/file'; -import scrape, { getHeadsByMediaType } from '@scraper'; +import scrape, { getHeadsByMediaType, getRegularByMediaType } from '@scraper'; import config from '@config'; import ScrapeInfoModal from '../ScrapeInfoModal'; @@ -22,6 +22,10 @@ const { dialog } = require('electron').remote; type Props = ReturnType & { dispatch }; +const matchStr: (str: string, reg: RegExp) => string = (str, reg) => { + const r = str.match(reg); + return r ? (r[0] ? r[0] : str) : str; +}; const HeaderContent = ({ checkedKeys, selectedFilename, @@ -61,6 +65,7 @@ const HeaderContent = ({ }; const handleScrape = (headName?: string) => { const defaultHead = getHeadsByMediaType(config.get('scene'))[0]; + const regular = getRegularByMediaType(config.get('scene')) || /./; if (!defaultHead) { return message.error('当前场景未找到信息源'); } @@ -78,7 +83,7 @@ const HeaderContent = ({ _tasks = [ { - queryString: selectedFilename, + queryString: matchStr(selectedFilename, regular), file } ]; @@ -87,7 +92,7 @@ const HeaderContent = ({ .map(key => { const file = flatTree[key]; return { - queryString: file.title, + queryString: matchStr(file.title, regular), file }; }) diff --git a/app/containers/Home/MainContent/index.tsx b/app/containers/Home/MainContent/index.tsx index a2d4702..f62c047 100644 --- a/app/containers/Home/MainContent/index.tsx +++ b/app/containers/Home/MainContent/index.tsx @@ -27,6 +27,7 @@ const MainContent = ({ selectedKey, flatTree }) => { setMediaInfo(readMediaInfoFromNFOSync(nfoPath)); } catch (error) { console.info('no nfo file'); + setMediaInfo(null); } } }, [selectedKey]); diff --git a/app/containers/Home/ScrapeInfoModal/index.tsx b/app/containers/Home/ScrapeInfoModal/index.tsx index d2d6d43..90ecb5d 100644 --- a/app/containers/Home/ScrapeInfoModal/index.tsx +++ b/app/containers/Home/ScrapeInfoModal/index.tsx @@ -9,25 +9,7 @@ import * as styles from './index.less'; import { changeFailureKeys } from '../../../actions/file'; const ScrapeModal = ({ visible, taskQueue, onCancel, handleTaskEnd }) => { - const [currentMediaInfo, setCurrentMediaInfo] = useState({ - poster: 'https://image.tmdb.org/t/p/w500/uXTtUYleKiaF0KuBwupIeuSjyLA.jpg', - title: 'def', - premiered: '2019-04-24', - actor: [ - { - name: 'Yanting Lvasdsdda asdas', - thumb: - 'https://image.tmdb.org/t/p/w138_and_h175_face/vKpOzPutTaPf03rWXiLuK8R2K3B.jpg' - }, - { - name: 'asdasd', - thumb: - 'https://image.tmdb.org/t/p/w138_and_h175_face/58Ytg6PBGpqB2s7DkHB82dRvdFO.jpg' - } - ], - genre: [], - uniqueid: [] - }); + const [currentMediaInfo, setCurrentMediaInfo] = useState(null); const [taskQ, setTaskQ] = useState([]); const [taskIsEnd, setTaskIsEnd] = useState(false); const lastTaskQ = useRef(taskQ); @@ -79,12 +61,14 @@ const ScrapeModal = ({ visible, taskQueue, onCancel, handleTaskEnd }) => { }, []); const handleModalCancel = e => { if (taskIsEnd) { + setCurrentMediaInfo(null); return onCancel(); } Modal.confirm({ title: '确认关闭吗', onOk: () => { scraper.stop(); + setCurrentMediaInfo(null); onCancel(); } }); @@ -138,7 +122,7 @@ const ScrapeModal = ({ visible, taskQueue, onCancel, handleTaskEnd }) => { - {currentMediaInfo.title === 'def' ? ( + {!currentMediaInfo ? ( '' ) : ( diff --git a/app/scraper/core/index.ts b/app/scraper/core/index.ts index d99678f..88e0f10 100644 --- a/app/scraper/core/index.ts +++ b/app/scraper/core/index.ts @@ -62,7 +62,7 @@ class Scraper { if (this.stopFlag) return; const str = queryOpts[i].queryString; const { file } = queryOpts[i]; - emitter.emit(EventType.SCRAPE_PENDING, file); + emitter.emit(EventType.SCRAPE_PENDING, file, str); await head(str) .then(res => { console.log(res.getModel(), file); diff --git a/app/scraper/index.ts b/app/scraper/index.ts index d997a04..dc45286 100644 --- a/app/scraper/index.ts +++ b/app/scraper/index.ts @@ -1,8 +1,11 @@ import Scraper from './core/index'; import heads from './heads'; -import mediaType, { getHeadsByMediaType } from './mediaType'; +import mediaType, { + getHeadsByMediaType, + getRegularByMediaType +} from './mediaType'; const scraper = new Scraper(); scraper.loadHead(heads); export default scraper; -export { heads, mediaType, getHeadsByMediaType }; +export { heads, mediaType, getHeadsByMediaType, getRegularByMediaType }; diff --git a/app/scraper/mediaType.ts b/app/scraper/mediaType.ts index 3e6e811..0a91ea0 100644 --- a/app/scraper/mediaType.ts +++ b/app/scraper/mediaType.ts @@ -15,8 +15,7 @@ const mediaType: MediaTypeNode[] = [ label: '普通' } ] - }, - { value: MediaKeys.Music, label: '音乐' } + } ]; export default mediaType; @@ -29,8 +28,16 @@ const mediaSource = heads.reduce((acc, head) => { } return acc; }, {}); - +const regular = { + [`${MediaKeys.Movie}$$${MediaKeys.Normal}`]: /[a-zA-Z0-9:\u4e00-\u9fa5]+/, + [`${MediaKeys.Movie}$$${MediaKeys.Gentleman}`]: /\d{3,10}(_|-)\d{3,10}|[a-z]{3,10}(_|-)(\d|[a-z]){3,10}/i, + [MediaKeys.Music]: /[a-z]/ +}; export const getHeadsByMediaType: (type: string[]) => ToolHead[] = type => { const sourceId = type.join('$$'); return mediaSource[sourceId] || []; }; +export const getRegularByMediaType: (type: string[]) => RegExp = type => { + const sourceId = type.join('$$'); + return regular[sourceId]; +}; diff --git a/app/scraper/regular.ts b/app/scraper/regular.ts deleted file mode 100644 index e81d3f7..0000000 --- a/app/scraper/regular.ts +++ /dev/null @@ -1,7 +0,0 @@ -import { MediaKeys } from '@types'; - -export default { - [MediaKeys.Movie]: /[a-zA-Z0-9:\u4e00-\u9fa5]+/, - [MediaKeys.Jav]: /\d{3,10}(_|-)\d{3,10}|[a-z]{3,10}(_|-)(\d|[a-z]){3,10}/i, - [MediaKeys.Music]: /[a-z]/ -};