Skip to content

Commit

Permalink
refractor: clean code
Browse files Browse the repository at this point in the history
  • Loading branch information
Xavier Chopin committed Mar 24, 2019
1 parent a17cb21 commit acffdfa
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 48 deletions.
42 changes: 0 additions & 42 deletions src/renderer/components/LandingPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
</div>
</div>
</div>

<div class="player" v-if="info">
<div class="ui one column grid videoInfo">
<div class="row">
Expand Down Expand Up @@ -76,47 +75,6 @@
<div v-show="isFinished">
<i class="action-btn green check icon"></i>
</div>
<div @click="panelMenu()" id="panel-btn">
<i v-show="isPanelEnabled" class="close icon"></i>
<i v-show="!isPanelEnabled" class="bars icon"></i>
</div>
</div>
<div class="row panel panel" v-show="isPanelEnabled">
<span class="panel-section" id="crop">CROPPING SECTION</span>
<span class="panel-section" id="from">FROM</span>
<div id="firstCut" class="ui input">
<input
class="panel-input"
type="text"
v-model="firstTime"
placeholder="00:00"
@change="validateFirstTime"
>
</div>

<span class="panel-section" id="to">TO</span>

<div id="lastCut" class="ui input">
<input
class="panel-input"
type="text"
v-model="endTime"
placeholder="00:00"
@change="validateFirstTime"
>

<button class="ui green labeled icon button">
Validate &nbsp;
<i class="check icon"></i>
</button>
</div>

<span class="panel-section" id="quality">AUDIO QUALITY</span>
<select id="selectQuality" class="ui search dropdown panel-input" name="quality">
<option class="panel-input" value="128">128kb/s (Medium)</option>
<option class="panel-input" selected value="256">256kb/s (High)</option>
<option class="panel-input" value="320">320kb/s (Very High)</option>
</select>
</div>
<div class="download-progress row">
<sui-progress state="active" color="green" :percent="percent" :label="label"/>
Expand Down
12 changes: 6 additions & 6 deletions src/renderer/services/YoutubeService.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import bus from '../bus';

const ytdl = require('ytdl-core');
const fs = require('fs');
const binaries = require('ffmpeg-binaries');
const ffmpeg = require('fluent-ffmpeg');
const binaries = require('ffmpeg-binaries');
const readline = require('readline');

let INTERVAL_ID = 0;
Expand Down Expand Up @@ -36,12 +36,12 @@ export default class YoutubeService {
this.sleep(SLEEP_TIME);
});
});
const path = localStorage.getItem('chosenPath');
const savedPath = localStorage.getItem('chosenPath');
ffmpeg(stream)
.setFfmpegPath(binaries.ffmpegPath())
.format('mp3')
.audioBitrate(256)
.save(`${path}.mp3`)
.save(`${savedPath}.mp3`)
.on('progress', () => {
readline.cursorTo(process.stdout, 0);
bus.$on('cancelDownload', () => {
Expand All @@ -50,10 +50,10 @@ export default class YoutubeService {
});
})
.on('end', () => {
const source = fs.createReadStream(`${path}.mp3`);
const dest = fs.createWriteStream(`${path}`);
const source = fs.createReadStream(`${savedPath}.mp3`);
const dest = fs.createWriteStream(`${savedPath}`);
source.on('close', () => {
fs.unlinkSync(`${path}.mp3`);
fs.unlinkSync(`${savedPath}.mp3`);
bus.$emit('percentProgress', 100);
});
source.pipe(dest);
Expand Down

0 comments on commit acffdfa

Please sign in to comment.