Add Odysee support

This commit is contained in:
Xaekai 2022-01-28 05:34:22 -08:00
parent 89d79fe422
commit 6b39d754d3
6 changed files with 105 additions and 0 deletions

View file

@ -24,6 +24,7 @@ var order = [
'twitchclip.coffee', 'twitchclip.coffee',
'peertube.coffee', 'peertube.coffee',
'iframechild.coffee', 'iframechild.coffee',
'odysee.coffee',
'update.coffee' 'update.coffee'
]; ];

80
player/odysee.coffee Normal file
View file

@ -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)

View file

@ -17,6 +17,7 @@ TYPE_MAP =
pt: PeerPlayer pt: PeerPlayer
bc: IframeChild bc: IframeChild
bn: IframeChild bn: IframeChild
od: OdyseePlayer
window.loadMediaPlayer = (data) -> window.loadMediaPlayer = (data) ->
try try

View file

@ -6,6 +6,7 @@ const ffmpeg = require("./ffmpeg");
const mediaquery = require("@cytube/mediaquery"); const mediaquery = require("@cytube/mediaquery");
const YouTube = require("@cytube/mediaquery/lib/provider/youtube"); const YouTube = require("@cytube/mediaquery/lib/provider/youtube");
const Vimeo = require("@cytube/mediaquery/lib/provider/vimeo"); 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 PeerTube = require("@cytube/mediaquery/lib/provider/peertube");
const BitChute = require("@cytube/mediaquery/lib/provider/bitchute"); const BitChute = require("@cytube/mediaquery/lib/provider/bitchute");
const BandCamp = require("@cytube/mediaquery/lib/provider/bandcamp"); 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 */ /* BandCamp */
bn: function (id, callback) { bn: function (id, callback) {
BandCamp.lookup(id).then(video => { BandCamp.lookup(id).then(video => {

View file

@ -213,6 +213,9 @@
case "bn": case "bn":
const [artist,track] = id.split(';'); const [artist,track] = id.split(';');
return `https://${artist}.bandcamp.com/track/${track}`; return `https://${artist}.bandcamp.com/track/${track}`;
case "od":
const [user,video] = id.split(';');
return `https://odysee.com/@${user}/${video}`;
default: default:
return ""; return "";
} }

View file

@ -64,6 +64,9 @@ function formatURL(data) {
case "bn": case "bn":
const [artist,track] = data.id.split(';'); const [artist,track] = data.id.split(';');
return `https://${artist}.bandcamp.com/track/${track}`; return `https://${artist}.bandcamp.com/track/${track}`;
case "od":
const [user,video] = data.id.split(';');
return `https://odysee.com/@${user}/${video}`;
default: default:
return "#"; return "#";
} }
@ -1403,6 +1406,12 @@ function parseMediaLink(url) {
return { type: 'bc', id: `${data.pathname.slice(7).split('/').shift()}` } 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/')){ if(data.hostname.endsWith('.bandcamp.com') && data.pathname.startsWith('/track/')){