Example #1
0
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))
}
Example #2
0
func InTorrentsMap(tmdbId string) (torrents []*bittorrent.Torrent) {
	for index, torrentMap := range TorrentsMap {
		if tmdbId == torrentMap.tmdbId {
			if xbmc.DialogConfirm("Quasar", "LOCALIZE[30260]") {
				torrents = append(torrents, torrentMap.torrent)
			} else {
				TorrentsMap = append(TorrentsMap[:index], TorrentsMap[index+1:]...)
			}
		}
	}
	return torrents
}
Example #3
0
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)
}