mirror of https://github.com/calzoneman/sync.git
Add Odysee support
This commit is contained in:
parent
517058bef3
commit
a2c4ea5036
|
@ -24,6 +24,7 @@ var order = [
|
|||
'twitchclip.coffee',
|
||||
'peertube.coffee',
|
||||
'iframechild.coffee',
|
||||
'odysee.coffee',
|
||||
'update.coffee'
|
||||
];
|
||||
|
||||
|
|
|
@ -0,0 +1,80 @@
|
|||
window.OdyseePlayer = class OdyseePlayer extends Player
|
||||
constructor: (data) ->
|
||||
if not (this instanceof OdyseePlayer)
|
||||
return new OdyseePlayer(data)
|
||||
|
||||
@load(data)
|
||||
|
||||
load: (data) ->
|
||||
@setMediaProperties(data)
|
||||
@ready = false
|
||||
|
||||
waitUntilDefined(window, 'playerjs', =>
|
||||
iframe = $('<iframe/>')
|
||||
.attr(
|
||||
src: data.meta.embed.src
|
||||
allow: 'autoplay; fullscreen'
|
||||
)
|
||||
|
||||
removeOld(iframe)
|
||||
|
||||
@player = new playerjs.Player(iframe[0])
|
||||
@player.on('ready', =>
|
||||
@player.on('error', (error) =>
|
||||
console.error('PlayerJS error', error.stack)
|
||||
)
|
||||
@player.on('ended', ->
|
||||
if CLIENT.leader
|
||||
socket.emit('playNext')
|
||||
)
|
||||
@player.on('play', ->
|
||||
@paused = false
|
||||
if CLIENT.leader
|
||||
sendVideoUpdate()
|
||||
)
|
||||
@player.on('pause', ->
|
||||
@paused = true
|
||||
if CLIENT.leader
|
||||
sendVideoUpdate()
|
||||
)
|
||||
|
||||
@player.setVolume(VOLUME * 100)
|
||||
|
||||
if not @paused
|
||||
@player.play()
|
||||
|
||||
@ready = true
|
||||
)
|
||||
)
|
||||
|
||||
play: ->
|
||||
@paused = false
|
||||
if @player and @ready
|
||||
@player.play()
|
||||
|
||||
pause: ->
|
||||
@paused = true
|
||||
if @player and @ready
|
||||
@player.pause()
|
||||
|
||||
seekTo: (time) ->
|
||||
if @player and @ready
|
||||
@player.setCurrentTime(time)
|
||||
|
||||
setVolume: (volume) ->
|
||||
if @player and @ready
|
||||
@player.setVolume(volume * 100)
|
||||
|
||||
getTime: (cb) ->
|
||||
if @player and @ready
|
||||
@player.getCurrentTime(cb)
|
||||
else
|
||||
cb(0)
|
||||
|
||||
getVolume: (cb) ->
|
||||
if @player and @ready
|
||||
@player.getVolume((volume) ->
|
||||
cb(volume / 100)
|
||||
)
|
||||
else
|
||||
cb(VOLUME)
|
|
@ -17,6 +17,7 @@ TYPE_MAP =
|
|||
pt: PeerPlayer
|
||||
bc: IframeChild
|
||||
bn: IframeChild
|
||||
od: OdyseePlayer
|
||||
|
||||
window.loadMediaPlayer = (data) ->
|
||||
try
|
||||
|
|
|
@ -6,6 +6,7 @@ const ffmpeg = require("./ffmpeg");
|
|||
const mediaquery = require("@cytube/mediaquery");
|
||||
const YouTube = require("@cytube/mediaquery/lib/provider/youtube");
|
||||
const Vimeo = require("@cytube/mediaquery/lib/provider/vimeo");
|
||||
const Odysee = require("@cytube/mediaquery/lib/provider/odysee");
|
||||
const PeerTube = require("@cytube/mediaquery/lib/provider/peertube");
|
||||
const BitChute = require("@cytube/mediaquery/lib/provider/bitchute");
|
||||
const BandCamp = require("@cytube/mediaquery/lib/provider/bandcamp");
|
||||
|
@ -397,6 +398,16 @@ var Getters = {
|
|||
});
|
||||
},
|
||||
|
||||
/* Odysee */
|
||||
od: function (id, callback) {
|
||||
Odysee.lookup(id).then(video => {
|
||||
video = new Media(video.id, video.title, video.duration, "od", video.meta);
|
||||
callback(null, video);
|
||||
}).catch(error => {
|
||||
callback(error.message || error);
|
||||
});
|
||||
},
|
||||
|
||||
/* BandCamp */
|
||||
bn: function (id, callback) {
|
||||
BandCamp.lookup(id).then(video => {
|
||||
|
|
|
@ -213,6 +213,9 @@
|
|||
case "bn":
|
||||
const [artist,track] = id.split(';');
|
||||
return `https://${artist}.bandcamp.com/track/${track}`;
|
||||
case "od":
|
||||
const [user,video] = id.split(';');
|
||||
return `https://odysee.com/@${user}/${video}`;
|
||||
default:
|
||||
return "";
|
||||
}
|
||||
|
|
|
@ -64,6 +64,9 @@ function formatURL(data) {
|
|||
case "bn":
|
||||
const [artist,track] = data.id.split(';');
|
||||
return `https://${artist}.bandcamp.com/track/${track}`;
|
||||
case "od":
|
||||
const [user,video] = data.id.split(';');
|
||||
return `https://odysee.com/@${user}/${video}`;
|
||||
default:
|
||||
return "#";
|
||||
}
|
||||
|
@ -1403,6 +1406,12 @@ function parseMediaLink(url) {
|
|||
return { type: 'bc', id: `${data.pathname.slice(7).split('/').shift()}` }
|
||||
}
|
||||
|
||||
case 'odysee.com':
|
||||
const format = new RegExp('/@(?<user>[^:]+)(?::\\w)?/(?<video>[^:]+)');
|
||||
if(format.test(data.pathname)){
|
||||
const {user,video} = (data.pathname.match(format)['groups']);
|
||||
return { type: 'od', id: `${user};${video}` }
|
||||
}
|
||||
}
|
||||
|
||||
if(data.hostname.endsWith('.bandcamp.com') && data.pathname.startsWith('/track/')){
|
||||
|
|
Loading…
Reference in New Issue