Skip to content

Commit

Permalink
Support for Multiple Player
Browse files Browse the repository at this point in the history
  • Loading branch information
DeekshithSH committed Jul 14, 2024
1 parent 5e0e399 commit 97e4029
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 14 deletions.
5 changes: 3 additions & 2 deletions internal/commands/stream.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package commands

import (
"fmt"
"net/url"
"strings"

"EverythingSuckz/fsb/config"
Expand Down Expand Up @@ -104,11 +105,11 @@ func sendLink(ctx *ext.Context, u *ext.Update) error {
Buttons: []tg.KeyboardButtonClass{
&tg.KeyboardButtonURL{
Text: "VLC",
URL: fmt.Sprintf("%s/player/%d?hash=%s&player=%s", config.ValueOf.Host, messageID, hash, "vlc"),
URL: fmt.Sprintf("%s/player/%d?hash=%s&player=%s&name=%s", config.ValueOf.Host, messageID, hash, "vlc", url.QueryEscape(file.FileName)),
},
&tg.KeyboardButtonURL{
Text: "MX Player",
URL: fmt.Sprintf("%s/player/%d?hash=%s&player=%s", config.ValueOf.Host, messageID, hash, "mxplayer"),
URL: fmt.Sprintf("%s/player/%d?hash=%s&player=%s&name=%s", config.ValueOf.Host, messageID, hash, "mxplayer", url.QueryEscape(file.FileName)),
},
},
})
Expand Down
37 changes: 25 additions & 12 deletions internal/routes/stream.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,25 +21,38 @@ func (e *allRoutes) LoadHome(r *Route) {
log = e.log.Named("Stream")
defer log.Info("Loaded stream route")
r.Engine.GET("/stream/:messageID", getStreamRoute)
r.Engine.GET("/stream/:messageID/:name", getStreamRoute)
}

func (e *allRoutes) LoadVLC(r *Route) {
log = e.log.Named("Player")
defer log.Info("Player Route loaded")

r.Engine.GET("/player/:messageID", func(ctx *gin.Context) {
var link string
playerType := ctx.Query("player")
messageID := ctx.Param("messageID")
hash := ctx.Query("hash")
r.Engine.GET("/player/:messageID", handlePlayer)
}

if playerType == "mxplayer" {
link = fmt.Sprintf("intent:%s/stream/%s?hash=%s#Intent;package=com.mxtech.videoplayer.ad;end", config.ValueOf.Host, messageID, hash)
} else {
link = fmt.Sprintf("vlc://%s/stream/%s?hash=%s", ctx.Request.Host, messageID, hash)
}
ctx.Redirect(http.StatusMovedPermanently, link)
})
func handlePlayer(ctx *gin.Context) {
var link string
playerType := ctx.Query("player")
messageID := ctx.Param("messageID")
hash := ctx.Query("hash")
fileName := ctx.Query("name")
dl_link := fmt.Sprintf("%s/stream/%s/%s?hash=%s", config.ValueOf.Host, messageID, fileName, hash)

if playerType == "mxplayer" {
link = fmt.Sprintf("intent:%s#Intent;package=com.mxtech.videoplayer.ad;end", dl_link)
} else if playerType == "playit" {
link = fmt.Sprintf("playit://playerv2/video?url=%s", dl_link)
} else if playerType == "s" {
link = fmt.Sprintf("intent:%s#Intent;action=com.young.simple.player.playback_online;package=com.young.simple.player;end", dl_link)
} else if playerType == "km" {
link = fmt.Sprintf("intent:%s#Intent;package=com.kmplayer;end", dl_link)
} else if playerType == "hd" {
link = fmt.Sprintf("intent:%s#Intent;package=uplayer.video.player;end", dl_link)
} else {
link = fmt.Sprintf("vlc://%s", dl_link)
}
ctx.Redirect(http.StatusMovedPermanently, link)
}

func getStreamRoute(ctx *gin.Context) {
Expand Down

0 comments on commit 97e4029

Please sign in to comment.