コード例 #1
0
ファイル: provider.go プロジェクト: xfanity/pulsar
func ProviderGetEpisode(ctx *gin.Context) {
	provider := ctx.Params.ByName("provider")
	showId := ctx.Params.ByName("showId")
	seasonNumber, _ := strconv.Atoi(ctx.Params.ByName("season"))
	episodeNumber, _ := strconv.Atoi(ctx.Params.ByName("episode"))

	log.Println("Searching links for TVDB Id:", showId)

	show, err := tvdb.NewShowCached(showId, "en")
	if err != nil {
		ctx.Error(err)
		return
	}
	episode := show.Seasons[seasonNumber].Episodes[episodeNumber-1]

	log.Printf("Resolved %s to %s\n", showId, show.SeriesName)

	searcher := providers.NewAddonSearcher(provider)
	torrents := searcher.SearchEpisodeLinks(show, episode)
	if ctx.Request.URL.Query().Get("resolve") == "true" {
		for _, torrent := range torrents {
			torrent.Resolve()
		}
	}
	data, err := json.MarshalIndent(providerDebugResponse{
		Payload: searcher.GetEpisodeSearchObject(show, episode),
		Results: torrents,
	}, "", "    ")
	if err != nil {
		ctx.Error(err)
	}
	ctx.Data(200, "application/json", data)
}
コード例 #2
0
ファイル: provider.go プロジェクト: xfanity/pulsar
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)
}