Skip to content

Commit

Permalink
MX Player
Browse files Browse the repository at this point in the history
  • Loading branch information
DeekshithSH committed Jul 14, 2024
1 parent 1e1ac1a commit 5e0e399
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 7 deletions.
8 changes: 6 additions & 2 deletions internal/commands/stream.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,12 @@ func sendLink(ctx *ext.Context, u *ext.Update) error {
markup.Rows = append(markup.Rows, tg.KeyboardButtonRow{
Buttons: []tg.KeyboardButtonClass{
&tg.KeyboardButtonURL{
Text: "Open In VLC",
URL: fmt.Sprintf("%s/vlc/%d?hash=%s", config.ValueOf.Host, messageID, hash),
Text: "VLC",
URL: fmt.Sprintf("%s/player/%d?hash=%s&player=%s", config.ValueOf.Host, messageID, hash, "vlc"),
},
&tg.KeyboardButtonURL{
Text: "MX Player",
URL: fmt.Sprintf("%s/player/%d?hash=%s&player=%s", config.ValueOf.Host, messageID, hash, "mxplayer"),
},
},
})
Expand Down
21 changes: 16 additions & 5 deletions internal/routes/stream.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package routes

import (
"EverythingSuckz/fsb/config"
"EverythingSuckz/fsb/internal/bot"
"EverythingSuckz/fsb/internal/utils"
"fmt"
Expand All @@ -23,11 +24,21 @@ func (e *allRoutes) LoadHome(r *Route) {
}

func (e *allRoutes) LoadVLC(r *Route) {
log = e.log.Named("VLC Redirect")
defer log.Info("Redirect to VLC")
r.Engine.GET("/vlc/:messageID", func(ctx *gin.Context) {
ctx.Redirect(http.StatusMovedPermanently,
fmt.Sprintf("vlc://%s/stream/%s?hash=%s", ctx.Request.Host, ctx.Param("messageID"), ctx.Query("hash")))
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")

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

Expand Down

0 comments on commit 5e0e399

Please sign in to comment.