コード例 #1
0
ファイル: library.go プロジェクト: razer1s/quasar
func RemoveMovie(ctx *gin.Context) {
	LibraryPath := config.Get().LibraryPath
	MoviesLibraryPath := filepath.Join(LibraryPath, "Movies")
	DBPath := filepath.Join(LibraryPath, fmt.Sprintf("%s.json", DBName))
	imdbId := ctx.Params.ByName("imdbId")
	movie := tmdb.GetMovieFromIMDB(imdbId, "en")
	MovieStrm := toFileName(fmt.Sprintf("%s (%s)", movie.OriginalTitle, strings.Split(movie.ReleaseDate, "-")[0]))
	MoviePath := filepath.Join(MoviesLibraryPath, MovieStrm)

	if err := RemoveFromJsonDB(DBPath, imdbId, LMovie); err != nil {
		libraryLog.Info("Unable to remove movie from db")
		ctx.String(404, "")
		return
	}

	if err := os.RemoveAll(MoviePath); err != nil {
		libraryLog.Info("Unable to remove movie folder")
		ctx.String(404, "")
		return
	}

	xbmc.Notify("Quasar", "LOCALIZE[30222]", config.AddonIcon())
	ctx.String(200, "")
	xbmc.VideoLibraryClean()
	libraryLog.Info("Movie removed")
}
コード例 #2
0
ファイル: library.go プロジェクト: razer1s/quasar
func Lookup(ctx *gin.Context) {
	var db DataBase

	LibraryPath := config.Get().LibraryPath
	DBPath := filepath.Join(LibraryPath, fmt.Sprintf("%s.json", DBName))

	if _, err := os.Stat(DBPath); err == nil {
		file, err := ioutil.ReadFile(DBPath)
		if err != nil {
			ctx.Writer.Header().Set("Access-Control-Allow-Origin", "*")
			ctx.JSON(200, gin.H{
				"success": false,
			})
			return
		}
		json.Unmarshal(file, &db)
	}

	Movies := make([]*Item, 0, len(db.Movies))
	Shows := make([]*Item, 0, len(db.Shows))

	for i := 0; i < len(db.Movies); i++ {
		movie := tmdb.GetMovieFromIMDB(db.Movies[i], "en")
		Movies = append(Movies, &Item{
			Id:       db.Movies[i],
			Title:    movie.OriginalTitle,
			Year:     strings.Split(movie.ReleaseDate, "-")[0],
			Overview: movie.Overview,
			Poster:   imageEndpoint + "w500" + movie.PosterPath,
		})
	}

	for i := 0; i < len(db.Shows); i++ {
		show, err := tvdb.NewShowCached(db.Shows[i], "en")
		if err != nil {
			ctx.Writer.Header().Set("Access-Control-Allow-Origin", "*")
			ctx.JSON(200, gin.H{
				"success": false,
			})
			return
		}
		Shows = append(Shows, &Item{
			Id:       db.Shows[i],
			Title:    show.SeriesName,
			Year:     strings.Split(show.FirstAired, "-")[0],
			Overview: show.Overview,
			Poster:   tvdbBanners + show.Poster,
		})
	}

	ctx.Writer.Header().Set("Access-Control-Allow-Origin", "*")
	ctx.JSON(200, gin.H{
		"success": true,
		"results": gin.H{
			"movies": Movies,
			"shows":  Shows,
		},
	})
}
コード例 #3
0
ファイル: movies.go プロジェクト: peer23peer/quasar
func movieLinks(imdbId string) []*bittorrent.Torrent {
	log.Println("Searching links for IMDB:", imdbId)

	movie := tmdb.GetMovieFromIMDB(imdbId, config.Get().Language)

	log.Printf("Resolved %s to %s\n", imdbId, movie.Title)

	searchers := providers.GetMovieSearchers()
	if len(searchers) == 0 {
		xbmc.Notify("Quasar", "LOCALIZE[30204]", config.AddonIcon())
	}

	return providers.SearchMovie(searchers, movie)
}
コード例 #4
0
ファイル: library.go プロジェクト: razer1s/quasar
func WriteMovieStrm(imdbId string, MoviesLibraryPath string) error {
	movie := tmdb.GetMovieFromIMDB(imdbId, "en")
	MovieStrm := toFileName(fmt.Sprintf("%s (%s)", movie.OriginalTitle, strings.Split(movie.ReleaseDate, "-")[0]))
	MoviePath := filepath.Join(MoviesLibraryPath, MovieStrm)

	if _, err := os.Stat(MoviePath); os.IsNotExist(err) {
		if err := os.Mkdir(MoviePath, 0755); err != nil {
			libraryLog.Info("Unable to create MoviePath")
			return err
		}
	}

	MovieStrmPath := filepath.Join(MoviePath, fmt.Sprintf("%s.strm", MovieStrm))
	if err := ioutil.WriteFile(MovieStrmPath, []byte(UrlForXBMC("/library/play/movie/%s", imdbId)), 0755); err != nil {
		libraryLog.Info("Unable to write to MovieStrmPath")
		return err
	}

	return nil
}
コード例 #5
0
ファイル: provider.go プロジェクト: peer23peer/quasar
func ProviderGetMovie(ctx *gin.Context) {
	imdbId := ctx.Params.ByName("imdbId")
	provider := ctx.Params.ByName("provider")
	log.Println("Searching links for IMDB:", imdbId)
	movie := tmdb.GetMovieFromIMDB(imdbId, "en")
	log.Printf("Resolved %s to %s\n", imdbId, movie.Title)

	searcher := providers.NewAddonSearcher(provider)
	torrents := searcher.SearchMovieLinks(movie)
	if ctx.Request.URL.Query().Get("resolve") == "true" {
		for _, torrent := range torrents {
			torrent.Resolve()
		}
	}
	data, err := json.MarshalIndent(providerDebugResponse{
		Payload: searcher.GetMovieSearchObject(movie),
		Results: torrents,
	}, "", "    ")
	if err != nil {
		ctx.Error(err)
	}
	ctx.Data(200, "application/json", data)
}