Alternative webOS launch

Reload torrents list
This commit is contained in:
kolsys
2021-09-14 02:50:37 +03:00
parent 2f19e81855
commit 8b245e941c
6 changed files with 25 additions and 98 deletions

View File

@@ -35,7 +35,7 @@ func main() {
filepath.WalkDir(srcGo+"template/pages/", func(path string, d fs.DirEntry, err error) error {
if !d.IsDir() {
name := strings.TrimPrefix(path, srcGo+"template/")
if !strings.HasPrefix(name, ".") {
if !strings.HasPrefix(filepath.Base(name), ".") {
files = append(files, name)
}
}

View File

@@ -16,11 +16,12 @@ import (
)
type msxMenu struct {
Logo string `json:"logo,omitempty"`
Reuse bool `json:"reuse"`
Cache bool `json:"cache"`
Restore bool `json:"restore"`
Menu []msxMenuItem `json:"menu"`
Logo string `json:"logo,omitempty"`
Reuse bool `json:"reuse"`
Cache bool `json:"cache"`
Restore bool `json:"restore"`
Reference string `json:"reference,omitempty"`
Menu []msxMenuItem `json:"menu"`
}
type msxMenuItem struct {
@@ -92,10 +93,11 @@ func msxTorrents(c *gin.Context) {
}
c.JSON(200, msxMenu{
Logo: logo,
Cache: false,
Reuse: false,
Restore: false,
Logo: logo,
Cache: false,
Reuse: false,
Restore: false,
Reference: host + "/msx/torrents",
Menu: []msxMenuItem{
// Main page
{
@@ -195,7 +197,19 @@ func msxPlaylist(c *gin.Context) {
"type": mime,
}
} else if (platform == "lg") {
item.Action = "content:request:interaction:init@" + host + "/msx/webos.html?url=" + url.QueryEscape(uri)
item.Action = "system:lg:launch:com.webos.app.videoplayer"
item.Data = gin.H{
"properties": gin.H{
"videoList": gin.H{
"result": [1]gin.H{
gin.H{
"url": uri,
"thumbnail": tor.Poster,
},
},
},
},
}
} else if (platform == "ios" || platform == "mac") {
// TODO - for iOS and Mac the application must be defined in scheme but we don't know what user has installed
// item.Action = "system:tvx:launch:vlc://"+uri

File diff suppressed because one or more lines are too long

View File

@@ -1,72 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<title>WebOS Interaction Plugin</title>
<meta charset="UTF-8" />
<meta name="author" content="kolsys" />
<meta name="copyright" content="kolsys" />
<script type="text/javascript" src="webOSTV-1.2.4.js"></script>
<script type="text/javascript" src="tvx-plugin.min.js"></script>
<script type="text/javascript">
const params = new URLSearchParams(document.location.search);
function WebOSPlay() {
try {
webOS.service.request('luna://com.webos.applicationManager', {
method: 'launch',
parameters: {
id: 'com.webos.app.videoplayer',
params: {
videoList: {
result: params.getAll('url').map(url => ({url: url})),
}
},
onSuccess: function (args) {
console.log('Success:', args);
TVXInteractionPlugin.executeAction('back');
},
onFailure: function (args) {
console.log('Failed to open Video Player', args);
TVXInteractionPlugin.executeAction('error:Failed to open Video Player');
}
},
});
} catch(e) {
console.log('ERROR', e);
TVXInteractionPlugin.executeAction('error:Failed to open Video Player ' + e.getMessage());
}
}
function WebOSHandler() {
this.ready = function() {
WebOSPlay();
};
this.handleRequest = function(dataId, data, callback) {
if (dataId == 'init') {
callback({
type: 'pages',
headline: 'WebOS Player',
pages: [{
items: [{
type: 'default',
layout: '0,0,12,6',
color: 'msx-glass',
text: 'Opening webOS Media Player...'
}]
}]
});
return true;
}
return false;
};
}
window.onload = function() {
TVXInteractionPlugin.setupHandler(new WebOSHandler());
TVXInteractionPlugin.init();
};
</script>
</head>
<body>
</body>
</html>

View File

@@ -55,12 +55,6 @@ var Msxtizenjs []byte
//go:embed pages/msx/tvx-plugin.min.js
var Msxtvxpluginminjs []byte
//go:embed pages/msx/webOSTV-1.2.4.js
var MsxwebOSTV124js []byte
//go:embed pages/msx/webos.html
var Msxweboshtml []byte
//go:embed pages/site.webmanifest
var Sitewebmanifest []byte

View File

@@ -77,14 +77,6 @@ func RouteWebPages(route *gin.RouterGroup) {
c.Data(200, "application/javascript", Msxtvxpluginminjs)
})
route.GET("/msx/webOSTV-1.2.4.js", func(c *gin.Context) {
c.Data(200, "application/javascript", MsxwebOSTV124js)
})
route.GET("/msx/webos.html", func(c *gin.Context) {
c.Data(200, "text/html; charset=utf-8", Msxweboshtml)
})
route.GET("/site.webmanifest", func(c *gin.Context) {
c.Data(200, "application/manifest+json", Sitewebmanifest)
})