-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Changes to youtube downloads to prioritize MP4 files
- Also includes a download view page
- Loading branch information
Showing
7 changed files
with
124 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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
import * as React from "react"; | ||
import {Progress, Table} from 'antd'; | ||
import {ipcRenderer} from 'electron'; | ||
const log = require('electron-log'); | ||
|
||
export class DownloadTable extends React.Component<any, any> { | ||
|
||
state = { | ||
downloadValues: [] | ||
} | ||
|
||
constructor(props) { | ||
super(props); | ||
|
||
this.parseData = this.parseData.bind(this); | ||
ipcRenderer.on('download_list_reply', this.parseData); | ||
} | ||
|
||
componentDidMount(): void { | ||
ipcRenderer.send('download_list_get', ''); | ||
this.startTimer(); | ||
} | ||
|
||
componentWillUnmount(): void { | ||
ipcRenderer.removeListener('download_list_reply', this.parseData); | ||
} | ||
|
||
private updateTimer = null; | ||
private startTimer() { | ||
//log.info(name, e.target.value); | ||
clearTimeout(this.updateTimer); | ||
this.updateTimer = setTimeout(() => { ipcRenderer.send('download_list_get', ''); this.startTimer(); }, 3000); | ||
} | ||
|
||
|
||
parseData = (event, data) => { | ||
let newValues = []; | ||
Object.entries(data).map((listThing) => { | ||
let key = listThing[0]; | ||
let value: any = listThing[1]; | ||
newValues.push({downurl: key, percent: value.percent}); | ||
}); | ||
this.setState({downloadValues: newValues}); | ||
} | ||
|
||
private columns = [ | ||
{ | ||
title: 'Download URL', | ||
dataIndex: 'downurl', | ||
key: 'downurl', | ||
width: "45%", | ||
render: text => { | ||
return text.replace(/,/g, "."); | ||
} | ||
}, | ||
{ | ||
title: 'Completion', | ||
dataIndex: 'percent', | ||
key: 'percent', | ||
width: "55%", | ||
render: text => { | ||
let percent = parseFloat(text.slice(0, -1)); | ||
let status = true; | ||
if (percent > 99.99){ | ||
status = false; | ||
} | ||
return <Progress percent={percent} status={status ? "active" : "success"} /> | ||
} | ||
} | ||
]; | ||
|
||
public render() { | ||
return ( | ||
<> | ||
<Table columns={this.columns} dataSource={this.state.downloadValues}/> | ||
</> | ||
); | ||
} | ||
|
||
} |