File tree 2 files changed +28
-5
lines changed
2 files changed +28
-5
lines changed Original file line number Diff line number Diff line change @@ -19,7 +19,6 @@ import (
19
19
"encoding/json"
20
20
"net/http"
21
21
"strconv"
22
- "strings"
23
22
24
23
"github.com/bisoncorps/gophie/engine"
25
24
log "github.com/sirupsen/logrus"
@@ -48,11 +47,11 @@ func Handler(w http.ResponseWriter, r *http.Request) {
48
47
} else {
49
48
site = engine .GetEngine (eng )
50
49
}
51
- log .Info ("Using Engine " , site )
50
+
51
+ log .Debug ("Using Engine " , site )
52
52
if search != "" {
53
53
log .Debug ("Searching for " , search )
54
- query := strings .ReplaceAll (search , "+" , " " )
55
- result = site .Search (query )
54
+ result = site .Search (search )
56
55
} else if list != "" {
57
56
log .Debug ("listing page " , list )
58
57
pagenum , _ := strconv .Atoi (list )
Original file line number Diff line number Diff line change 1
1
package engine
2
2
3
3
import (
4
+ "encoding/json"
4
5
"errors"
5
6
"fmt"
6
7
"net/url"
7
- // "path"
8
8
"strconv"
9
9
"strings"
10
10
@@ -44,10 +44,34 @@ type Movie struct {
44
44
Source string // The Engine From which it is gotten from
45
45
}
46
46
47
+ // MovieJSON : JSON structure of all downloadable movies
48
+ type MovieJSON struct {
49
+ Movie
50
+ DownloadLink string
51
+ SDownloadLink []string
52
+ }
53
+
47
54
func (m * Movie ) String () string {
48
55
return fmt .Sprintf ("%s (%v)" , m .Title , m .Year )
49
56
}
50
57
58
+ // MarshalJSON Json structure to return from api
59
+ func (m * Movie ) MarshalJSON () ([]byte , error ) {
60
+ var sDownloadLink []string
61
+ for _ , link := range m .SDownloadLink {
62
+ sDownloadLink = append (sDownloadLink , link .String ())
63
+ }
64
+
65
+ movie := MovieJSON {
66
+ Movie : * m ,
67
+ DownloadLink : m .DownloadLink .String (),
68
+ SDownloadLink : sDownloadLink ,
69
+ }
70
+
71
+ return json .Marshal (movie )
72
+
73
+ }
74
+
51
75
// SearchResult : the results of search from engine
52
76
type SearchResult struct {
53
77
Query string
You can’t perform that action at this time.
0 commit comments