Skip to content

Commit

Permalink
fix:bug fix
Browse files Browse the repository at this point in the history
  • Loading branch information
fhyoga committed Oct 13, 2019
1 parent 038af2d commit 800b442
Show file tree
Hide file tree
Showing 8 changed files with 46 additions and 53 deletions.
34 changes: 17 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 串联起来

### 最后
Expand Down
11 changes: 8 additions & 3 deletions app/containers/Home/HeaderContent/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -22,6 +22,10 @@ const { dialog } = require('electron').remote;

type Props = ReturnType<typeof mapStateToProps> & { 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,
Expand Down Expand Up @@ -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('当前场景未找到信息源');
}
Expand All @@ -78,7 +83,7 @@ const HeaderContent = ({

_tasks = [
{
queryString: selectedFilename,
queryString: matchStr(selectedFilename, regular),
file
}
];
Expand All @@ -87,7 +92,7 @@ const HeaderContent = ({
.map(key => {
const file = flatTree[key];
return {
queryString: file.title,
queryString: matchStr(file.title, regular),
file
};
})
Expand Down
1 change: 1 addition & 0 deletions app/containers/Home/MainContent/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ const MainContent = ({ selectedKey, flatTree }) => {
setMediaInfo(readMediaInfoFromNFOSync(nfoPath));
} catch (error) {
console.info('no nfo file');
setMediaInfo(null);
}
}
}, [selectedKey]);
Expand Down
24 changes: 4 additions & 20 deletions app/containers/Home/ScrapeInfoModal/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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();
}
});
Expand Down Expand Up @@ -138,7 +122,7 @@ const ScrapeModal = ({ visible, taskQueue, onCancel, handleTaskEnd }) => {
</Timeline>
</Col>
<Col span={18} style={{ position: 'sticky', top: 100 }}>
{currentMediaInfo.title === 'def' ? (
{!currentMediaInfo ? (
''
) : (
<MediaInfo currentMediaInfo={currentMediaInfo} />
Expand Down
2 changes: 1 addition & 1 deletion app/scraper/core/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
7 changes: 5 additions & 2 deletions app/scraper/index.ts
Original file line number Diff line number Diff line change
@@ -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 };
13 changes: 10 additions & 3 deletions app/scraper/mediaType.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ const mediaType: MediaTypeNode[] = [
label: '普通'
}
]
},
{ value: MediaKeys.Music, label: '音乐' }
}
];
export default mediaType;

Expand All @@ -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];
};
7 changes: 0 additions & 7 deletions app/scraper/regular.ts

This file was deleted.

0 comments on commit 800b442

Please sign in to comment.