Skip to content

Commit

Permalink
bugs fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
damiva authored Jan 14, 2022
1 parent 81b7b15 commit 80a3096
Show file tree
Hide file tree
Showing 15 changed files with 392 additions and 244 deletions.
14 changes: 9 additions & 5 deletions assets/Russian.json
Original file line number Diff line number Diff line change
Expand Up @@ -294,19 +294,23 @@

"Remove": "Удалить",
"Drop": "Сбросить",
"Recent": "Продолжить",
"Video": "Моё видео",
"Music": "Моя музыка",
"video": "Моё видео",
"music": "Моя музыка",
"photo": "Мои фотографии",
"Torrents":"Мои торренты",
"Torrent0":"Торрент добавлен",
"Torrent1":"Торрент получает информацию",
"Torrent2":"Торрент подгружается",
"Torrent3":"Торрент работает",
"Torrent4":"Торрент закрыт",
"torrent5":"Торрент в базе данных",
"Update": "Обновить",
"Torrent5":"Торрент в базе данных",
"AddTorr": "Добавить в Мои торренты",
"CheckUp": "Проверить обновления",
"Update": "Желаете обновить (приложение будет перезапущено)?",
"Language":"Язык",
"Address": "Адрес",
"NoUpdate":"Обновлений нет",
"HasUpdate":"Есть обновления",
"About":"- ПО для просмотра контента пользователя и разработки пользовательских плагинов.{br}Данное ПО не предоставляет никакого видео/аудио контента само по себе!"
}
}
Binary file modified assets/logotype.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 8 additions & 6 deletions dialogs.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func init() {
if json.Unmarshal(b, &key) == nil {
inputKey(w, id, key.Data)
} else if json.Unmarshal(b, &stg) == nil {
if k, e := getDicKeyboard(); e == nil {
if _, k, e := getDic(); e == nil {
keyboards[true] = k
} else {
log.Println(e)
Expand All @@ -58,15 +58,15 @@ func init() {
panic("Parsing dialog data error: " + e.Error())
}
svcAnswer(w, "panel:data", &plist{Head: dat.Data.Headline, Ext: dat.Data.Extension, Pages: []map[string][]plistObj{{"items": {
{"type": "space", "text": dat.Data.Value, "layout": "0,0,8,6"},
{"type": "space", "headline": dat.Data.Value, "layout": "0,0,8,6", "alignment": "center"},
{"type": "button", "icon": "done", "layout": "4,5,2,1", "action": dat.Data.Action, "display": dat.Data.Action != ""},
{"type": "button", "icon": "close", "layout": "6,5,2,1", "action": "back"},
}}}})
})
}
func inputKbd(w http.ResponseWriter, r *http.Request, id string, ka bool) {
bx, at := boxText[id], "execute:service:http://"+r.Host+r.URL.Path+"?id="+id
ks := []plistObj{{"id": "txt", "type": "space", "label": bx.Value, "color": "msx-black-soft", "layout": "0,0,10,1"}}
ks := []plistObj{{"id": "txt", "type": "space", "label": bx.Value, "color": "msx-black-soft", "layout": "0,0,10,1", "offset": "0,0.3,0,0.3", "compress": false}}
i := 0
for _, k := range keyboards[boxLang[id] && !ka] {
y := i / 10
Expand All @@ -83,7 +83,7 @@ func inputKbd(w http.ResponseWriter, r *http.Request, id string, ka bool) {
for i, k := range [][4]string{
{"backspace", "red|delete", "<del>", "fast-rewind"},
{"clear", "home", "<clr>", "skip-previous"},
{"space-bar", "space|yellow|insert", " ", "fast-forward"},
{"space-bar", "yellow|space|insert", " ", "fast-forward"},
{"language", "end|tab|caps_lock", "<lng>", "skip-next"},
{"done", "green", "\n", ""},
} {
Expand Down Expand Up @@ -117,8 +117,10 @@ func inputKey(w http.ResponseWriter, id, key string) {
fallthrough
case "<del>":
key = ""
if l := len(b.Value); l > 0 {
b.Value = b.Value[:l-1]
rs := []rune(b.Value)
if l := len(rs); l > 0 {
rs = rs[:len(rs)-1]
b.Value = string(rs)
}
fallthrough
default:
Expand Down
6 changes: 3 additions & 3 deletions dic.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,14 @@ func init() {
}
})
}
func getDicKeyboard() (k string, e error) {
func getDic() (n, k string, e error) {
var (
d struct{ Keyboard string }
d struct{ Name, Keyboard string }
f *os.File
)
if f, e = os.Open(pthDic); e == nil {
if e = json.NewDecoder(f).Decode(&d); e == nil {
k = d.Keyboard
n, k = d.Name, d.Keyboard
} else {
e = errors.New("Decoding " + pthDic + " error: " + e.Error())
}
Expand Down
51 changes: 30 additions & 21 deletions files.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,19 @@ import (
"strings"
)

const pthVideo, pthMusic, extVid, extAud = "video", "music", ".avi.mp4.mkv.mpeg.mpg.m4v.mp2.webm.ts.mts.m2ts.mov.wmv.flv", ".mp3.m4a.flac.wav.wma.aac"
const (
pthVideo, pthMusic, pthPhoto = "video", "music", "photo"
extVid, extAud, extPic = ".avi.mp4.mkv.mpeg.mpg.m4v.mp2.webm.ts.mts.m2ts.mov.wmv.flv", ".mp3.m4a.flac.wav.wma.aac", ".jpg.png"
)

func init() {
http.HandleFunc("/msx/video/", files)
http.HandleFunc("/msx/music/", files)
for _, f := range [3]string{pthVideo, pthMusic, pthPhoto} {
http.HandleFunc("/msx/"+f+"/", files)
}
}

func files(w http.ResponseWriter, r *http.Request) {
p := filepath.Clean(strings.TrimPrefix(r.URL.Path, "/msx/"))
v := p[0] == 'v'
if f, e := os.Stat(p); os.IsNotExist(e) {
panic(404)
} else if e != nil {
Expand All @@ -30,33 +33,39 @@ func files(w http.ResponseWriter, r *http.Request) {
fs, e := ioutil.ReadDir(p)
check(e)
var (
l *plist
ext string
ts, ms []plistObj
id, pre = r.FormValue("id"), f.Name()
l *plist
ext string
z = "label"
ts, ms []plistObj
t byte
)
if v {
l, ext = plistMedia(r, filepath.Base(p), "msx-white-soft:movie"), extVid
} else {
l, ext = plistMedia(r, filepath.Base(p), "msx-white-soft:audiotrack"), extAud
}
if pre == pthMusic || pre == pthVideo {
pre = ""
} else {
pre = "{col:msx-white-soft}" + pre + ": {col:msx-white}"
id := r.FormValue("id")
switch t = p[0]; t {
case 'p':
ext, l, z = extPic, &plist{Type: "list", Head: f.Name(), Ext: "{ico:photo-library}", Template: plistObj{"imageFiller": "smart", "layout": "0,0,3,2"}}, "headline"
case 'm':
l, ext = mediaList(r, f.Name(), "{ico:library-music}", false), extAud
default:
l, ext = mediaList(r, f.Name(), "{ico:video-library}", true), extVid
}
for _, f := range fs {
n := f.Name()
x, u := strings.ToLower(filepath.Ext(n)), "http://"+r.Host+r.URL.EscapedPath()+url.PathEscape(n)
switch {
case f.IsDir():
l.Items = append(l.Items, plistObj{"icon": "msx-yellow:folder", "label": n, "action": "content:" + u + "/"})
l.Items = append(l.Items, plistObj{"icon": "msx-yellow:folder", z: n, "action": "content:" + u + "/"})
case x == ".torrent":
if stg.TorrServer != "" {
ts = append(ts, plistObj{"icon": "msx-yellow:offline-bolt", "label": n, "action": "content:http://" + r.Host + "/msx/torr?id={ID}&link=" + url.QueryEscape(u)})
if t != 'p' && stg.TorrServer != "" {
ts = append(ts, plistObj{"icon": "msx-yellow:offline-bolt", z: n, "action": "content:http://" + r.Host + "/msx/torr?id={ID}&link=" + url.QueryEscape(u)})
}
case strings.Contains(ext, x):
ms = append(ms, plistObj{"label": n, "extensionLabel": sizeFormat(f.Size()), "playerLabel": pre + n, "action": playerURL(id, u, v)})
i := plistObj{z: n, "playerLabel": n, "extensionLabel": sizeFormat(f.Size())}
if t == 'p' {
i["image"], i["action"] = u, "image:"+u
} else {
i["action"] = playerURL(id, u, t == 'v')
}
ms = append(ms, i)
}
}
l.Items = append(l.Items, append(ts, ms...)...)
Expand Down
28 changes: 21 additions & 7 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,20 +29,20 @@ import (
"log"
"net/http"
"os"
"os/signal"
"path/filepath"
"sync"
"syscall"
"time"
)

var (
out = log.New(os.Stdout, "(i) ", log.Flags())
mutex = new(sync.Mutex)
mypath string
started = time.Now()
signals = make(chan os.Signal, 1)
//signals = make(chan os.Signal, 1)
)

/*
func init() {
signal.Notify(signals, os.Interrupt, syscall.SIGTERM, syscall.SIGABRT)
go func() {
Expand All @@ -63,14 +63,23 @@ func init() {
}
}()
}
*/
func restart() {
mutex.Lock()
log.Println("Restarting...")
os.Exit(0)
}
func check(e error) {
if e != nil {
panic(e)
}
}
func main() {
var e error
defer log.Fatalln(recover())
log.SetPrefix("<!> ")
mypath, e = os.Executable()
check(e)
for _, a := range os.Args[1:] {
switch a {
case "-t":
Expand All @@ -82,14 +91,19 @@ func main() {
case "-s":
http.DefaultTransport.(*http.Transport).TLSClientConfig = &tls.Config{InsecureSkipVerify: true}
case "-d":
p, e := os.Executable()
check(e)
check(os.Chdir(filepath.Dir(p)))
check(os.Chdir(filepath.Dir(mypath)))
default:
server.Addr = a
if a[0] != '-' {
server.Addr = a
}
}
}
check(stg.load())
if e = os.Remove(mypath + ".old"); e == nil {
out.Println(Name, "has been updated!")
} else if !os.IsNotExist(e) {
log.Println(e)
}
out.Println(Name, "v.", Vers, "listening at", server.Addr)
check(server.ListenAndServe())
}
Loading

0 comments on commit 80a3096

Please sign in to comment.