refactor, bypass dns filtering using google dns, yts host resolution using qwant

This commit is contained in:
2020-05-31 15:54:24 +02:00
parent 6099b72570
commit 1fd24d0536
1164 changed files with 437 additions and 582974 deletions

52
cmd/ytsflix/main.go Normal file
View File

@ -0,0 +1,52 @@
package main
import (
"fmt"
"net/http"
"os"
"strings"
"github.com/gorilla/mux"
"github.com/sirupsen/logrus"
"git.adphi.net/adphi/ytsflix/handler"
)
func main() {
var storagePath = "/tmp"
if os.Getenv("DATA_DIR") != "" {
storagePath = os.Getenv("DATA_DIR")
}
logrus.Infof("Using directory: %s", storagePath)
setupLogging()
h, err := handler.NewHandler(storagePath)
if err != nil {
logrus.Fatal(err)
}
defer h.Close()
r := mux.NewRouter()
r.HandleFunc("/", h.Home).Methods(http.MethodGet)
r.HandleFunc("/movies/{search}", h.Search).Methods(http.MethodGet)
r.HandleFunc("/movies/category/{category}", h.Category).Methods(http.MethodGet)
r.HandleFunc("/movie/{id}", h.Movie).Methods(http.MethodGet)
r.HandleFunc("/torrent/{id}", h.Torrents).Methods(http.MethodGet)
r.HandleFunc("/watch/{movie}", h.Serve).Methods(http.MethodGet)
r.HandleFunc("/subs/{movie}/{sub}", h.Sub).Methods(http.MethodGet)
if err := http.ListenAndServe(fmt.Sprintf(":%d", 8080), r); err != nil {
logrus.Fatal(err)
}
}
func setupLogging() {
level := os.Getenv("LOG_LEVEL")
l := logrus.ErrorLevel
for _, ll := range logrus.AllLevels {
if strings.ToLower(level) == ll.String() {
l = ll
break
}
}
logrus.SetLevel(l)
logrus.Infof("Setting LOG_LEVEL: %s", l)
}