コード例 #1
0
ファイル: shows.go プロジェクト: peer23peer/quasar
func ShowEpisodeLinks(ctx *gin.Context) {
	seasonNumber, _ := strconv.Atoi(ctx.Params.ByName("season"))
	episodeNumber, _ := strconv.Atoi(ctx.Params.ByName("episode"))
	torrents, err := showEpisodeLinks(ctx.Params.ByName("showId"), seasonNumber, episodeNumber)
	if err != nil {
		ctx.Error(err)
		return
	}

	if len(torrents) == 0 {
		xbmc.Notify("Quasar", "LOCALIZE[30205]", config.AddonIcon())
		return
	}

	choices := make([]string, 0, len(torrents))
	for _, torrent := range torrents {
		label := fmt.Sprintf("S:%d P:%d - %s",
			torrent.Seeds,
			torrent.Peers,
			torrent.Name,
		)
		choices = append(choices, label)
	}

	choice := xbmc.ListDialog("LOCALIZE[30202]", choices...)
	if choice >= 0 {
		rUrl := UrlQuery(UrlForXBMC("/play"), "uri", torrents[choice].Magnet())
		ctx.Redirect(302, rUrl)
	}
}
コード例 #2
0
ファイル: search.go プロジェクト: i96751414/quasar
func Search(ctx *gin.Context) {
	query := ctx.Request.URL.Query().Get("q")
	if len(searchHistory) > 0 && xbmc.DialogConfirm("Quasar", "LOCALIZE[30262]") {
		choice := xbmc.ListDialog("LOCALIZE[30261]", searchHistory...)
		query = searchHistory[choice]
	} else {
		query = xbmc.Keyboard("", "LOCALIZE[30209]")
		if query == "" {
			return
		}
		searchHistory = append(searchHistory, query)
	}

	log.Println("Searching providers for:", query)

	searchers := providers.GetSearchers()
	torrents := providers.Search(searchers, query)

	items := make(xbmc.ListItems, 0, len(torrents))
	for _, torrent := range torrents {
		item := &xbmc.ListItem{
			Label:      fmt.Sprintf("S:%d P:%d - %s", torrent.Seeds, torrent.Peers, torrent.Name),
			Path:       UrlQuery(UrlForXBMC("/play"), "uri", torrent.URI),
			IsPlayable: true,
		}
		items = append(items, item)
	}

	ctx.JSON(200, xbmc.NewView("", items))
}
コード例 #3
0
ファイル: movies.go プロジェクト: scakemyer/quasar
func SearchMovies(ctx *gin.Context) {
	query := ctx.Request.URL.Query().Get("q")
	if query == "" {
		if len(searchHistory) > 0 && xbmc.DialogConfirm("Quasar", "LOCALIZE[30262]") {
			choice := xbmc.ListDialog("LOCALIZE[30261]", searchHistory...)
			query = searchHistory[choice]
		} else {
			query = xbmc.Keyboard("", "LOCALIZE[30206]")
			if query == "" {
				return
			}
			searchHistory = append(searchHistory, query)
		}
	}
	page, _ := strconv.Atoi(ctx.DefaultQuery("page", "0"))
	renderMovies(tmdb.SearchMovies(query, config.Get().Language, page), ctx, page, query)
}
コード例 #4
0
ファイル: movies.go プロジェクト: peer23peer/quasar
func MovieLinks(ctx *gin.Context) {
	torrents := movieLinks(ctx.Params.ByName("imdbId"))

	if len(torrents) == 0 {
		xbmc.Notify("Quasar", "LOCALIZE[30205]", config.AddonIcon())
		return
	}

	choices := make([]string, 0, len(torrents))
	for _, torrent := range torrents {
		info := make([]string, 0)
		if torrent.RipType > 0 {
			info = append(info, bittorrent.Rips[torrent.RipType])
		}
		if torrent.Resolution > 0 {
			info = append(info, bittorrent.Resolutions[torrent.Resolution])
		}
		if torrent.VideoCodec > 0 {
			info = append(info, bittorrent.Codecs[torrent.VideoCodec])
		}
		if torrent.AudioCodec > 0 {
			info = append(info, bittorrent.Codecs[torrent.AudioCodec])
		}

		label := fmt.Sprintf("S:%d P:%d - %s - %s",
			torrent.Seeds,
			torrent.Peers,
			strings.Join(info, " "),
			torrent.Name,
		)
		choices = append(choices, label)
	}

	choice := xbmc.ListDialog("LOCALIZE[30202]", choices...)
	if choice >= 0 {
		rUrl := UrlQuery(UrlForXBMC("/play"), "uri", torrents[choice].Magnet())
		ctx.Redirect(302, rUrl)
	}
}
コード例 #5
0
ファイル: player.go プロジェクト: i96751414/quasar
func (btp *BTPlayer) chooseFile() (libtorrent.FileEntry, error) {
	var biggestFile libtorrent.FileEntry
	maxSize := int64(0)
	numFiles := btp.torrentInfo.NumFiles()
	var candidateFiles []int

	for i := 0; i < numFiles; i++ {
		fe := btp.torrentInfo.FileAt(i)
		size := fe.GetSize()
		if size > maxSize {
			maxSize = size
			biggestFile = fe
		}
		if size > minCandidateSize {
			candidateFiles = append(candidateFiles, i)
		}
	}

	if len(candidateFiles) > 1 {
		btp.log.Info(fmt.Sprintf("There are %d candidate files", len(candidateFiles)))
		if btp.fileIndex >= 0 && btp.fileIndex < len(candidateFiles) {
			return btp.torrentInfo.FileAt(candidateFiles[btp.fileIndex]), nil
		}
		choices := make([]string, 0, len(candidateFiles))
		for _, index := range candidateFiles {
			fileName := filepath.Base(btp.torrentInfo.FileAt(index).GetPath())
			choices = append(choices, fileName)
		}
		choice := xbmc.ListDialog("LOCALIZE[30223]", choices...)
		if choice >= 0 {
			return btp.torrentInfo.FileAt(candidateFiles[choice]), nil
		} else {
			return biggestFile, fmt.Errorf("User cancelled")
		}
	}

	return biggestFile, nil
}