// SearchTorrents provides some feedback to the user and searches for torrents // for the pending items. func SearchTorrents(show *store.Show) ([]torrents.Torrent, error) { fmt.Printf( "Searching for %d torrents", len(show.PendingSeasons())+len(show.PendingEpisodes()), ) c := startProgressBar() defer stopProgressBar(c) return torrents.Search(show) }
func Test404(t *testing.T) { mux, ts := Setup(t) defer ts.Close() mux.HandleFunc("/usearch/", func(w http.ResponseWriter, r *http.Request) { w.WriteHeader(404) }) torrents.SearchEngines["kickass"] = torrents.Kickass{URL: ts.URL} delete(torrents.SearchEngines, "torrentcd") delete(torrents.SearchEngines, "extratorrent") season := store.Season{1, []*store.Episode{{Pending: true, Episode: 1}}} show := store.Show{Title: "Title", URL: "url", Seasons: []*store.Season{&season}} matches, err := torrents.Search(&show) require.NoError(t, err, "Not finding a torrent is not a big deal. Just continue.") assert.Equal(t, 0, len(matches)) }
func TestSearchForTorrents(t *testing.T) { mux, ts := Setup(t) defer ts.Close() mux.HandleFunc("/usearch/", func(w http.ResponseWriter, r *http.Request) { w.Header().Set("Content-Type", "application/xml") fmt.Fprintln(w, ReadFixture("testdata/kickass.xml")) }) torrents.SearchEngines["kickass"] = torrents.Kickass{ URL: ts.URL, } delete(torrents.SearchEngines, "torrentcd") delete(torrents.SearchEngines, "extratorrent") season := store.Season{1, []*store.Episode{{Pending: true, Episode: 1}}} show := store.Show{Title: "Title", URL: "url", Seasons: []*store.Season{&season}} matches, err := torrents.Search(&show) require.NoError(t, err) assert.Equal(t, 1, len(matches)) }