Skip to content

Commit

Permalink
Merge pull request myazarc#1 from myazarc/v2.0.0
Browse files Browse the repository at this point in the history
V2.0.0
  • Loading branch information
myazarc authored May 3, 2020
2 parents 21aa717 + 1a26bb7 commit 6f663ec
Show file tree
Hide file tree
Showing 8 changed files with 184 additions and 11 deletions.
1 change: 1 addition & 0 deletions .electron-vue/webpack.renderer.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ let rendererConfig = {
resolve: {
alias: {
'@': path.join(__dirname, '../src/renderer'),
'~': path.join(__dirname, '../'),
'vue$': 'vue/dist/vue.esm.js'
},
extensions: ['.js', '.vue', '.json', '.css', '.node']
Expand Down
Binary file modified build/icons/icon.ico
Binary file not shown.
25 changes: 23 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 8 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
{
"name": "YT.Downloader",
"version": "1.0.0",
"name": "ytdownloader",
"version": "2.0.0-alpha",
"author": "Mustafa Yazar <[email protected]>",
"description": "Youtube Video Downloader&Converter and Play Music",
"license": "MIT",
"main": "./dist/electron/main.js",
"scripts": {
"build": "node .electron-vue/build.js && electron-builder",
"build:win": "node .electron-vue/build.js && electron-builder -w",
"build:dir": "node .electron-vue/build.js && electron-builder --dir",
"build:clean": "cross-env BUILD_TARGET=clean node .electron-vue/build.js",
"build:web": "cross-env BUILD_TARGET=web node .electron-vue/build.js",
Expand Down Expand Up @@ -46,17 +47,20 @@
"icon": "build/icons/icon.icns"
},
"win": {
"icon": "build/icons/icon.ico"
"icon": "build/icons/icon.ico",
"target":["nsis"]
},
"linux": {
"icon": "build/icons"
"icon": "build/icons",
"target": ["deb", "AppImage"]
}
},
"dependencies": {
"@fortawesome/fontawesome-svg-core": "^1.2.4",
"@fortawesome/free-solid-svg-icons": "^5.3.1",
"@fortawesome/vue-fontawesome": "^0.1.1",
"dataurl": "^0.1.0",
"electron-notify": "^0.1.0",
"ffmpeg-binaries": "^4.0.0",
"fluent-ffmpeg": "^2.1.2",
"i": "^0.3.6",
Expand Down
27 changes: 26 additions & 1 deletion src/main/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { app, BrowserWindow } from 'electron' // eslint-disable-line
import { app, BrowserWindow, globalShortcut } from 'electron' // eslint-disable-line

/**
* Set `__static` path to static files in production
Expand Down Expand Up @@ -28,6 +28,31 @@ function createWindow () {
mainWindow.on('closed', () => {
mainWindow = null
})


globalShortcut.register('VolumeUp', () => {
mainWindow.webContents.send('mp-volume-up');
})

globalShortcut.register('VolumeDown', () => {
mainWindow.webContents.send('mp-volume-down');
})

globalShortcut.register('VolumeMute', () => {
mainWindow.webContents.send('mp-volume-mute');
})

globalShortcut.register('MediaNextTrack', () => {
mainWindow.webContents.send('mp-media-next');
})

globalShortcut.register('MediaPreviousTrack', () => {
mainWindow.webContents.send('mp-media-prev');
})

globalShortcut.register('MediaPlayPause', () => {
mainWindow.webContents.send('mp-play-pause');
})
}

app.on('ready', createWindow)
Expand Down
16 changes: 13 additions & 3 deletions src/renderer/components/MainPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@ import audioHelper from '../../main/libs/audioHelper.js';
openSettings(){
this.$electron.remote.getCurrentWindow().toggleDevTools();
},
pasteData(){
document.execCommand('paste');
},
download(){
ytHelper.getInfo(this.url).then((info) => {
Expand All @@ -102,6 +105,7 @@ import audioHelper from '../../main/libs/audioHelper.js';
let itemIndex=this.list.length - 1;
ytHelper.download(this.url,output).then((res) =>{
this.$eNotify.notify({ title: this.$eNotify.messages.getLocale('START_DOWNLOAD'), text: info.title });
this.list[itemIndex].progressShow=true;
let totalSize = res.headers['content-length'];
let dataRead = 0;
Expand All @@ -113,7 +117,7 @@ import audioHelper from '../../main/libs/audioHelper.js';
});
res.on('end', function() {
self.list[itemIndex].progressShow = false;
self.$eNotify.notify({ title: self.$eNotify.messages.getLocale('START_CONVERT'), text: info.title });
self.list[itemIndex].progressShow=true;
let proc = new ffmpeg({source:output});
Expand All @@ -129,6 +133,7 @@ import audioHelper from '../../main/libs/audioHelper.js';
self.list[itemIndex].progressPercent = progress.percent.toFixed(2);
})
.on('end', () => {
self.$eNotify.notify({ title: self.$eNotify.messages.getLocale('COMPLETE_CONVERT'), text: info.title });
self.list[itemIndex].progressShow=false;
fs.unlinkSync(output);
});
Expand All @@ -148,7 +153,8 @@ import audioHelper from '../../main/libs/audioHelper.js';
<div class="title noselect">YT.Downloader</div>
</header>
<div class="form-area">
<input type="text" name="" v-model="url" class="url" placeholder="Paste Link">
<input type="text" name="" v-model="url" class="url" placeholder="Paste Link"
@contextmenu.prevent="$refs.ctxMenuPaste.open($event)"/>
<div class="button-area">
<a class="btn fast-download" @click="download" title="Fast Download & Convert"><font-awesome-icon icon="angle-double-down" /></a>
<a class="btn download" title="Download"><font-awesome-icon icon="download" /></a>
Expand Down Expand Up @@ -200,6 +206,10 @@ import audioHelper from '../../main/libs/audioHelper.js';
<li @click="removeDisk(menuData)">Remove From Disk</li>
</context-menu>

<context-menu id="context-menu-paste" class="noselect" ref="ctxMenuPaste">
<li @click="pasteData">Paste <small>(CTRL + V)</small></li>
</context-menu>

</section>
<music-player :info="mPlayerInfo"/>
</div>
Expand All @@ -208,7 +218,7 @@ import audioHelper from '../../main/libs/audioHelper.js';
<style lang="scss">
#wrapper{position: relative;height: 100%;}
#context-menu{
#context-menu, #context-menu-paste{
li{
cursor: pointer;
height: 20px;
Expand Down
73 changes: 73 additions & 0 deletions src/renderer/components/MusicPlayer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ export default {
this.sliderMaxTime=this.totalTime;
};
audioHelper.audio.onplay=() => {
this.$eNotify.notify({ title: this.$eNotify.messages.getLocale('PLAY_MUSIC'), text: this.getTitle() });
this.playIcon='pause';
this.playStatus = 1;
};
Expand All @@ -69,6 +70,30 @@ export default {
const lastVol=localStorage.getItem('mplayer-vol') || audioHelper.audio.volume;
audioHelper.audio.volume=lastVol;
this.sliderAudioVal=lastVol * 100;
this.$electron.ipcRenderer.on('mp-volume-up', () => {
this.setVolumeUp();
});
this.$electron.ipcRenderer.on('mp-volume-down', () => {
this.setVolumeDown();
});
this.$electron.ipcRenderer.on('mp-volume-mute', () => {
this.setMute();
});
this.$electron.ipcRenderer.on('mp-media-next', () => {
this.setNextMusic();
});
this.$electron.ipcRenderer.on('mp-media-prev', () => {
this.setPrevMusic();
});
this.$electron.ipcRenderer.on('mp-play-pause', () => {
this.setPlayPause();
});
},
watch:{
info() {
Expand All @@ -83,6 +108,48 @@ export default {
audioHelper.audio.volume=vol/100;
localStorage.setItem('mplayer-vol',vol/100);
},
setVolumeDown(){
if(0>audioHelper.audio.volume && audioHelper.audio.volume<=0.2){
audioHelper.audio.volume=0;
localStorage.setItem('mplayer-vol',0);
}else if(audioHelper.audio.volume>0.2){
audioHelper.audio.volume-=0.2;
localStorage.setItem('mplayer-vol',audioHelper.audio.volume);
}
this.sliderAudioVal=audioHelper.audio.volume * 100;
},
setVolumeUp(){
if(audioHelper.audio.volume>=0.8 && audioHelper.audio.volume<1){
audioHelper.audio.volume=1;
localStorage.setItem('mplayer-vol',1);
}else if(audioHelper.audio.volume<0.8){
audioHelper.audio.volume+=0.2;
localStorage.setItem('mplayer-vol',audioHelper.audio.volume);
}
this.sliderAudioVal=audioHelper.audio.volume * 100;
},
setNextMusic(){
if(!this.playList.length) return;
if(this.playListIndex < this.playList.length && this.playListIndex != this.playList.length-1){
this.playListIndex++;
}else {
this.playListIndex = 0;
}
audioHelper.playOne(this.playList[this.playListIndex].fullPath);
},
setPrevMusic(){
if(!this.playList.length) return;
if(this.playListIndex > 0 && this.playListIndex != this.playList.length-1){
this.playListIndex--;
}else if(this.playListIndex == this.playList.length-1){
this.playListIndex--;
}else if(this.playListIndex == 0){
this.playListIndex = this.playList.length - 1;
}
audioHelper.playOne(this.playList[this.playListIndex].fullPath);
},
setPlayPause(){
if(this.playStatus == 0) {
if(!audioHelper.isStart){
Expand All @@ -93,6 +160,7 @@ export default {
} else {
audioHelper.audio.pause();
this.$eNotify.notify({ title: this.$eNotify.messages.getLocale('PAUSE_MUSIC'), text: this.getTitle() });
}
},
setMute(){
Expand All @@ -101,9 +169,11 @@ export default {
if(this.muteStatus) {
this.muteIcon = 'volume-off';
audioHelper.audio.muted=true;
this.$eNotify.notify({ title: this.$eNotify.messages.getLocale('MUTE_MUSIC'), text: this.getTitle() });
} else {
this.muteIcon = 'volume-up';
audioHelper.audio.muted=false;
this.$eNotify.notify({ title: this.$eNotify.messages.getLocale('UNMUTE_MUSIC'), text: this.getTitle() });
}
},
setPlayerListAndPlay(){
Expand Down Expand Up @@ -318,6 +388,9 @@ export default {
float: left;
line-height: $item-height;
padding-left: 10px;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
#itemTime{
Expand Down
41 changes: 40 additions & 1 deletion src/renderer/main.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
import Vue from 'vue'
import Vue from 'vue';
import eNotify from 'electron-notify';

import App from './App'
import router from './router'
import store from './store'

import AppIcon from '~/build/icons/256x256.png';

import { library } from '@fortawesome/fontawesome-svg-core'
import { faDownload, faAngleDoubleDown,faWrench,faPlay,faPause,faVolumeUp,faVolumeOff,faBars } from '@fortawesome/free-solid-svg-icons'
import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome'
Expand All @@ -13,6 +16,42 @@ Vue.component('font-awesome-icon', FontAwesomeIcon)
if (!process.env.IS_WEB) Vue.use(require('vue-electron'))
Vue.config.productionTip = false;

eNotify.setConfig({
appIcon: AppIcon,
displayTime: 6000
});

// First, checks if it isn't implemented yet.
if (!String.prototype.format) {
String.prototype.format = function() {
var args = arguments;
return this.replace(/{(\d+)}/g, function(match, number) {
return typeof args[number] != 'undefined'
? args[number]
: match
;
});
};
}

eNotify.messages= {
getLocale(name){
return this.en[name];
},
en: {
START_DOWNLOAD : 'Start Download',
START_CONVERT : 'Start Convert',
COMPLETE_CONVERT : 'Complete Convert',

PLAY_MUSIC : 'Playing',
PAUSE_MUSIC : 'Paused',
MUTE_MUSIC : 'Muted',
UNMUTE_MUSIC : 'Unmuted',
}
};

Vue.prototype.$eNotify = eNotify;

Vue.mixin({
methods: {
fancyTimeFormat(time) {
Expand Down

0 comments on commit 6f663ec

Please sign in to comment.