示例#1
0
def main():

    parser = argparse.ArgumentParser(
        description="download torrent files from anime feeds")
    parser.add_argument("-s", "--scan", action="append",
        help="don't download torrents already downloaded in scanned directory "
             "(can be specified multiple times)")
    parser.add_argument("-l", "--latest-version", action='store_true',
        help="download only latest version of an episode (v2, v3, etc)")
    parser.add_argument("-c", "--config", default="config.yml",
        help="YAML config file (default: config.yml)")
    parser.add_argument("torrent_dir",
        help="torrent files will be downloaded here")

    args = parser.parse_args()

    with open(args.config) as configfile:
        config = yaml.load(configfile)

    anime = feeds.fetch_episodes_from_feeds(config)

    discarded = [a for a in anime if not 'anime' in a]
    anime = [a for a in anime if a not in discarded]

    if args.latest_version:
        anime = feeds.filter_episode_versions(anime)

    if args.scan:
        anime = scan_directories(anime, args.scan)

    download.download_torrents(anime, args.torrent_dir)

    if len(discarded) > 0:
        print "the following entries could not be processed:"
        pprint(discarded)
示例#2
0
    def test_fetch_with_empty_config(self, mocked):
        config = {}
        expected = []
        mocked.return_value = []

        result = feeds.fetch_episodes_from_feeds(config)

        self.assertEquals(result, expected)
        self.assertFalse(mocked.called)
示例#3
0
    def test_fetch_one_feed(self, mocked):
        feedconfig = {"key": "value"}
        feed = {"search": "test"}
        config = {"feedtype": {"feedconfig": feedconfig, "feeds": [feed]}}

        mocked.return_value = self.nyaa_result

        result = feeds.fetch_episodes_from_feeds(config)

        mocked.assert_called_once_with("feedtype", feed, {"feedconfig": feedconfig})
        self.assertEquals(result, self.nyaa_result)