Skip to content

Commit

Permalink
disabled discord rich presence for now, wrote new readme
Browse files Browse the repository at this point in the history
  • Loading branch information
arrudagates committed Sep 22, 2020
1 parent 2da6b11 commit cacc2a0
Show file tree
Hide file tree
Showing 2 changed files with 81 additions and 38 deletions.
35 changes: 33 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,33 @@
# neoplayer
Terminal/MPV based youtube player
# Neoplayer

TUI Youtube audio player using MPV on the backend

## Installation

You need to have [MPV](https://mpv.io/) and [youtube-dl](https://youtube-dl.org/) installed.

Then install the libraries with:
```bash
npm install
```

## Usage

Run Neoplayer with:
```bash
node neoplayer.js
```

Commands currently available are (press 'h' to type commands):
```javascript
search <query> //searches youtube for the query and returns a list of results with indexes
play <index> //plays the index from the search list or adds it to the currently playing queue
pause //pauses the playback
skip //skips to the next track
q //quits Neoplayer
```
## Contributing
Feel free to open issues and make pull requests, I'll do my best to work on them.

## License
[GNU General Public License v2.0](LICENSE)
84 changes: 48 additions & 36 deletions index.js → neoplayer.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
var blessed = require('blessed')
const yts = require('yt-search')
const mpvAPI = require('node-mpv');
const client = require('discord-rich-presence')('704314970522910730');
//const client = require('discord-rich-presence')('704314970522910730')

const mpv = new mpvAPI({
"audio_only": true
});

async function start(){
try{
await mpv.start().then(screen.render())
Expand All @@ -14,9 +15,8 @@ async function start(){
}
catch (error) {
console.log(error);
}}


}
}

var screen = blessed.screen({
smartCSR: true,
Expand Down Expand Up @@ -114,57 +114,69 @@ mpv.on("started", async () => {
top.setContent(np)
screen.render()

client.updatePresence({
state: np,
details: 'Playing:',
startTimestamp: Date.now(),
endTimestamp: Date.now() + (remaining * 1000),
largeImageKey: 'neoplayer',
smallImageKey: 'play-circle',
instance: true,
});
// try{
// client.updatePresence({
// state: np,
// details: 'Playing:',
// startTimestamp: Date.now(),
// endTimestamp: Date.now() + (remaining * 1000),
// largeImageKey: 'neoplayer',
// smallImageKey: 'play-circle',
// instance: true,
// });
// }
// catch{}
})
mpv.on("paused", async () => {
let np = await mpv.getTitle()
top.setLabel(' Paused ')
screen.render()

client.updatePresence({
state: np,
details: 'Paused',
largeImageKey: 'neoplayer',
smallImageKey: 'pause-circle',
instance: true,
});
// try{
// client.updatePresence({
// state: np,
// details: 'Paused',
// largeImageKey: 'neoplayer',
// smallImageKey: 'pause-circle',
// instance: true,
// });
// }
// catch{}
})
mpv.on("resumed", async () => {
let np = await mpv.getTitle()
let remaining = await mpv.getTimeRemaining()
top.setLabel(' Now Playing ')
screen.render()

client.updatePresence({
state: np,
details: 'Playing:',
startTimestamp: Date.now(),
endTimestamp: Date.now() + (remaining * 1000),
largeImageKey: 'neoplayer',
smallImageKey: 'play-circle',
instance: true,
});
// try{
// client.updatePresence({
// state: np,
// details: 'Playing:',
// startTimestamp: Date.now(),
// endTimestamp: Date.now() + (remaining * 1000),
// largeImageKey: 'neoplayer',
// smallImageKey: 'play-circle',
// instance: true,
// });
// }
// catch{}
});

mpv.on("stopped", async () => {
top.setContent(' Nothing ')
screen.render()

client.updatePresence({
state: 'Nothing',
details: 'Playing:',
largeImageKey: 'neoplayer',
smallImageKey: 'stop-circle',
instance: true,
});
// try{
// client.updatePresence({
// state: 'Nothing',
// details: 'Playing:',
// largeImageKey: 'neoplayer',
// smallImageKey: 'stop-circle',
// instance: true,
// });
// }
// catch{}
});


Expand Down

0 comments on commit cacc2a0

Please sign in to comment.