Skip to content

Commit

Permalink
✨ mixer initial api support 🎉 ✨
Browse files Browse the repository at this point in the history
🔖 Issue: #7
  • Loading branch information
crippin committed Aug 9, 2019
1 parent 232fd2a commit cda6c29
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 1 deletion.
3 changes: 3 additions & 0 deletions src/AddTwitchUser.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export default class AddTwitchUser extends React.Component {
this.setState({code: doc.data().ActivateME})
showOnConsole(this.state.code)
} else if (doc.data().OAUTH != undefined) {
// TODO:token working?
setOAuth(doc.data().OAUTH);
} else {
this.setState({code: generateCode()})
Expand All @@ -31,6 +32,7 @@ export default class AddTwitchUser extends React.Component {
}
render(){
if(OAUTH){
// TODO:token working?
return (
<div>
READYTOGOOGOGOGOGO
Expand Down Expand Up @@ -61,6 +63,7 @@ function generateCode() {
}

function showOnConsole(code) {
console.log('Visit: https://twitch-link.firebaseapp.com');
console.log(' --------------------------- ');
console.log(' | | ');
console.log(' | PLEASE ACTIVATE YOUR TV | ');
Expand Down
3 changes: 2 additions & 1 deletion src/Stream.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';
import { GetStreamFromChannel, GetStreamDataFromChannel, SearchGame } from './TwitchAPI'
import { GetStreamFromChannel, GetStreamDataFromChannel, GetStreamFromChannelMixer, SearchGame } from './TwitchAPI'
import { withFocusable, withNavigation } from 'react-tv-navigation'
import FButton from './component/FButton'
const Hls = require('hls.js');
Expand Down Expand Up @@ -51,6 +51,7 @@ export default class Stream extends React.Component {
const { id } = this.props.match.params;
GetStreamDataFromChannel(id, this.setState)
GetStreamFromChannel(id, this.setState);
//GetStreamFromChannelMixer('LevelUpCast', this.setState);
}

render(){
Expand Down
37 changes: 37 additions & 0 deletions src/TwitchAPI.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,25 @@ exports.GetFollowed = function (callback){
callback({streams: json.streams})
}});
}
// TODO
exports.CheckTOKEN = function (callback){
console.log(OAUTH);
$.ajax({
type: 'GET',
url: 'https://api.twitch.tv/kraken/streams/followed',
headers: {
'Client-ID': Client_ID,
'Authorization': 'OAuth ' + OAUTH
},
success: function(json) {
console.log(json);
callback({streams: json.streams})
},
error: function(err) {
console.log(err);
}
});
}

exports.GetStreamDataFromChannel = function (id, callback){
$.ajax({
Expand Down Expand Up @@ -82,6 +101,24 @@ exports.GetStreamsFromGame = function (id, callback){
}});
}

exports.GetStreamFromChannelMixer = function (stream, callback) {
$.ajax({
type: 'GET',
url: `https://mixer.com/api/v1/channels/${stream}`,
success: function(json) {
$.ajax({
type: 'GET',
url: `https://mixer.com/api/v1/channels/${json.id}/manifest.m3u8`,
success: function(res) {
// m3u8 to json... OR just parse it manual
let src = { url: res.split('\n')[4] }; // source quality
callback({src: [src]})
}
});
}
});
}

exports.GetStreamFromChannel = function (stream, callback) {
twitchStreams.get(stream)
.then((data) => {
Expand Down

0 comments on commit cda6c29

Please sign in to comment.