forked from mayeaux/videodownloader
-
Notifications
You must be signed in to change notification settings - Fork 0
/
deletedCode.js
155 lines (109 loc) · 3.6 KB
/
deletedCode.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
// var url = 'https://www.youtube.com/watch?v=ZcAiayke00I';
function downloadChannel(url, channelUrl, downloadAsAudio, youtubeUrl, saveAsTitleValue){
let arguments = [];
// set the url for ytdl
arguments.push(url);
// verbose output
arguments.push('-v');
// keep video
// arguments.push('-k');
// arguments.push('-f', 'bestvideo+bestaudio/best');
// arguments.push('-f');
// select download as audio or video
if(downloadAsAudio){
arguments.push('-f');
arguments.push('bestaudio');
} else {
// arguments.push('best');
}
// // verbose output
// title is that passed or the one from youtube
const fileName = '%(title)s';
// const filePath = '/Users/anthony/Development/ytdldesktop/thinger/electron-quick-start/videos/Keemstar';
const filePath = __dirname + '/videos/';
// save to videos directory
arguments.push('-o', `${filePath}/%(uploader)s/${fileName}.%(ext)s`);
console.log(arguments);
// download as audio if needed
if(downloadAsAudio){
console.log('Download as audio');
arguments.push('-x');
}
const ls = spawn('node_modules/youtube-dl/bin/youtube-dl', arguments);
ls.stdout.on('data', (data) => {
percentage.innerText = data;
console.log(`stdout: ${data}`);
});
ls.stderr.on('data', (data) => {
percentage.innerText = data;
console.log(`stderr: ${data}`);
});
ls.on('close', (code) => {
youtubeUrl.value = '';
saveAsTitleValue.value = '';
// downloaded++;// if(downloaded == needsToDownload){
// downloading = false;
// console.log('no longer downloading');
// }
if(code == 0){
percentage.innerText = 'Download completed';
}
console.log(`child process exited with code ${code}`);
});
}
/** START CHANNEL DOWNLOAD SECTION **/
//
// var startChannelDownload = document.getElementsByClassName('startChannelDownload')[0];
//
//
// startChannelDownload.onclick = function(){
//
// var youtubeChannelUrl = document.getElementsByClassName('youtubeChannelUrl')[0];
// var downloadChannelAsAudio =document.getElementsByClassName('downloadChannelAsAudio')[0];
//
// var youtubeChannelUrlValue = youtubeChannelUrl.value;
// var downloadChannelAsAudioValue = downloadChannelAsAudio.checked;
//
// downloadChannel(youtubeChannelUrlValue, youtubeChannelUrlValue, downloadChannelAsAudioValue, youtubeChannelUrl, '');
//
// };
// frontend code
function myChannelFunction() {
navigator.clipboard.readText()
.then(text => {
document.getElementsByClassName("youtubeChannelUrl")[0].value = text;
})
.catch(err => {
console.log(err);
});
}
// <!--YOUTUBE DOWNLOADER-->
//
// <!--<br>-->
// <!--<br>-->
//
//
// <!--<br>-->
// <!--<br>-->
//
// <!--<h2>YouTube Channel Downloader</h2>-->
//
// <!--<label for="">Channel Url</label>-->
// <!--<input type="text" class="youtubeChannelUrl" value="https://www.youtube.com/user/NewDramaAlert" style="width:270px"><button onclick="myChannelFunction()">Paste</button>-->
// <!--<br>-->
// <!--<br>-->
// <!--<label for="">Download As Audio</label>-->
// <!--<input type="checkbox" class="downloadChannelAsAudio">-->
// <!--<br>-->
// <!--<br>-->
// <!--<button class="startChannelDownload btn btn-success" style="margin-bottom:73px">Start Downloading Channel</button>-->
//
// <!--<br>-->
// <!--console.log('Download started');-->
// <!--console.log('filename: ' + info._filename);-->
// <!--console.log('size: ' + info.size);-->
//
//
// <!--We are using Node.js <span id="node-version"></span>,-->
// <!--Chromium <span id="chrome-version"></span>,-->
// <!--and Electron <span id="electron-version"></span>.-->