コード例 #1
0
ファイル: openguessit.go プロジェクト: odwrtw/polochon
// UpdateFromGuessit updates the guess with the guessit informations
func (g *Guesser) UpdateFromGuessit() error {
	// Guesss the file infos from the name
	guess, err := guessit.Guess(filepath.Base(g.FilePath))
	if err != nil {
		return err
	}

	switch guess.Type {
	case guessit.Episode:
		g.Guessit = &Guessit{
			Type:         ShowType,
			ShowName:     guess.ShowName,
			Season:       fmt.Sprintf("%d", guess.Season),
			Episode:      fmt.Sprintf("%d", guess.Episode),
			Year:         fmt.Sprintf("%d", guess.Year),
			ReleaseGroup: guess.ReleaseGroup,
		}
	case guessit.Movie:
		g.Guessit = &Guessit{
			Type:         MovieType,
			MovieName:    guess.Title,
			Year:         fmt.Sprintf("%d", guess.Year),
			ReleaseGroup: guess.ReleaseGroup,
		}
	}

	return nil
}
コード例 #2
0
ファイル: explorer.go プロジェクト: odwrtw/polochon
func (k *Kickass) listMoviesByUser(movies map[string]*polochon.Movie, user string, log *logrus.Entry) error {
	query := &kickass.Query{
		User:     user,
		OrderBy:  "seeders",
		Order:    "desc",
		Category: string(MoviesCategory),
	}
	log = log.WithField("explore_user", user)

	torrents, err := k.client.ListByUser(query)
	if err != nil {
		return err
	}

	for _, t := range torrents {
		torrentStr := torrentGuessitStr(t)
		guess, err := guessit.Guess(torrentStr)
		if err != nil {
			continue
		}

		// Get the torrent quality
		torrentQuality := polochon.Quality(guess.Quality)
		if !torrentQuality.IsAllowed() {
			log.Infof("kickass: unhandled quality: %q", torrentQuality)
			continue
		}

		// Get the movie if its already in the map
		m, ok := movies[guess.Title]
		if !ok {
			// Create a new movie
			m = polochon.NewMovie(polochon.MovieConfig{})
			m.Title = guess.Title
			if guess.Year != 0 {
				m.Year = guess.Year
			}
		}

		log.WithFields(logrus.Fields{
			"torrent_quality": guess.Quality,
			"movie_title":     guess.Title,
		}).Debug("Adding torrent to the list")

		m.Torrents = append(m.Torrents, polochon.Torrent{
			Quality:    torrentQuality,
			URL:        t.MagnetURL,
			Seeders:    t.Seed,
			Leechers:   t.Leech,
			Source:     moduleName,
			UploadUser: user,
		})

		movies[m.Title] = m
	}

	return nil
}
コード例 #3
0
ファイル: torrenter.go プロジェクト: odwrtw/polochon
func (k *Kickass) searchUser(s Searcher, log *logrus.Entry, user string) ([]polochon.Torrent, error) {
	query := &kickass.Query{
		User:     user,
		OrderBy:  "seeders",
		Order:    "desc",
		Category: string(s.category()),
		Search:   s.searchStr(),
	}
	log = log.WithField("search_user", user)

	torrents, err := k.client.Search(query)
	if err != nil {
		return nil, err
	}

	result := []polochon.Torrent{}
	for _, t := range torrents {
		torrentStr := torrentGuessitStr(t)
		guess, err := guessit.Guess(torrentStr)
		if err != nil {
			continue
		}

		if !s.isValidGuess(guess, log) {
			continue
		}

		// Default quality
		if s.category() == ShowsCategory && guess.Quality == "" {
			guess.Quality = string(polochon.Quality480p)
		}

		// Get the torrent quality
		torrentQuality := polochon.Quality(guess.Quality)
		if !torrentQuality.IsAllowed() {
			log.Infof("kickass: unhandled quality: %q", torrentQuality)
			continue
		}

		log.WithFields(logrus.Fields{
			"torrent_quality": guess.Quality,
			"torrent_name":    torrentStr,
		}).Debug("Adding torrent to the list")

		// Add the torrent
		result = append(result, polochon.Torrent{
			Quality:    torrentQuality,
			URL:        t.MagnetURL,
			Seeders:    t.Seed,
			Leechers:   t.Leech,
			Source:     moduleName,
			UploadUser: user,
		})
	}

	return result, nil
}