Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add tuna plugin for obs #397

Merged
merged 1 commit into from
Sep 12, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions plugins/tuna-obs/back.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@

const { ipcRenderer } = require("electron");
const registerCallback = require("../../providers/song-info");

const fetch = require('node-fetch');

const post = (data) => {
const port = 1608;
headers = {'Content-Type': 'application/json',
'Accept': 'application/json',
'Access-Control-Allow-Headers': '*',
'Access-Control-Allow-Origin': '*'}
const url = `http://localhost:${port}/`;
fetch(url, {method: 'POST', headers, body:JSON.stringify({data})});
}



module.exports = async (win) => {

registerCallback((songInfo) => {

// Register the calilback
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit

Suggested change
// Register the calilback
// Register the callback

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry about the typo, it's a "i" from vim that missed

if (songInfo.title.length === 0 && songInfo.artist.length === 0) {
return;
}

const duration = Number(songInfo.songDuration)*1000
const progress = Number(songInfo.elapsedSeconds)*1000
const cover_url = songInfo.imageSrc
const album_url = songInfo.imageSrc
const title = songInfo.title
const artists = [songInfo.artist]
const status = !songInfo.isPaused ? 'Playing': 'Paused'
post({ cover_url, title, artists, status, progress, duration, album_url});

})

}