当前位置: 首页>>代码示例>>Python>>正文


Python Indexer.save方法代码示例

本文整理汇总了Python中nzbhydra.database.Indexer.save方法的典型用法代码示例。如果您正苦于以下问题:Python Indexer.save方法的具体用法?Python Indexer.save怎么用?Python Indexer.save使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在nzbhydra.database.Indexer的用法示例。


在下文中一共展示了Indexer.save方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: setUp

# 需要导入模块: from nzbhydra.database import Indexer [as 别名]
# 或者: from nzbhydra.database.Indexer import save [as 别名]
 def setUp(self):
     set_and_drop()
     womble = Indexer(module="womble", name="Womble", settings={"query_url": "http://127.0.0.1:5001/womble", "base_url": "http://127.0.0.1:5001/womble"}, search_types=["general"], search_ids=[])
     womble.save()
     self.womble = Womble(womble)
开发者ID:gh0std4ncer,项目名称:nzbhydra,代码行数:7,代码来源:testWomble.py

示例2: NewznabTests

# 需要导入模块: from nzbhydra.database import Indexer [as 别名]
# 或者: from nzbhydra.database.Indexer import save [as 别名]
class NewznabTests(UrlTestCase):
    def setUp(self):
        set_and_drop()

        self.indexercom = Indexer(name="indexer.com")
        self.indexercom.save()

        self.newznab1 = Bunch()
        self.newznab1.enabled = True
        self.newznab1.name = "indexer.com"
        self.newznab1.host = "https://indexer.com"
        self.newznab1.apikey = "apikeyindexer.com"
        self.newznab1.timeout = None
        self.newznab1.score = 0
        self.newznab1.search_ids = ["imdbid", "rid", "tvdbid"]
        self.newznab1.searchTypes = []
        self.n1 = NewzNab(self.newznab1)

    @freeze_time("2015-10-12 18:00:00", tz_offset=-4)
    def testParseSearchResult(self):
        # nzbsorg
        with open("mock/indexercom_q_testtitle_3results.xml") as f:
            entries = self.n1.process_query_result(f.read(), SearchRequest()).entries
        self.assertEqual(3, len(entries))

        self.assertEqual(entries[0].title, "testtitle1")
        assert entries[0].size == 2893890900
        assert entries[0].indexerguid == "eff551fbdb69d6777d5030c209ee5d4b"
        self.assertEqual(entries[0].age_days, 1)
        self.assertEqual(entries[0].epoch, 1444584857)
        self.assertEqual(entries[0].pubdate_utc, "2015-10-11T17:34:17+00:00")
        self.assertEqual(entries[0].poster, "[email protected]")
        self.assertEqual(entries[0].group, "alt.binaries.mom")
        self.assertEqual(entries[0].details_link, "https://indexer.com/details/eff551fbdb69d6777d5030c209ee5d4b")

        # Pull group from description
        self.assertEqual(entries[1].group, "alt.binaries.hdtv.x264")
        # Use "usenetdate" attribute if available
        self.assertEqual(entries[1].pubdate_utc, "2015-10-03T22:22:22+00:00")  # Sat, 03 Oct 2015 22:22:22 +0000
        # Use "info" attribute if available
        self.assertEqual(entries[0].details_link, "https://indexer.com/details/eff551fbdb69d6777d5030c209ee5d4b")

        # Don't use "not available" as group
        self.assertIsNone(entries[2].group)

    @freeze_time("2016-01-30 18:00:00", tz_offset=-4)
    def testParseSpotwebSearchResult(self):
        # nzbsorg
        with open("mock/spotweb_q_testtitle_3results.xml") as f:
            entries = self.n1.process_query_result(f.read(), SearchRequest()).entries
        self.assertEqual(3, len(entries))

        self.assertEqual(entries[0].title, "testtitle1")
        assert entries[0].size == 3960401206
        assert entries[0].indexerguid == "[email protected]"
        self.assertEqual(entries[0].age_days, 5)
        self.assertEqual(entries[0].epoch, 1453663845)
        self.assertEqual(entries[0].pubdate_utc, "2016-01-24T19:30:45+00:00")
        self.assertEqual(entries[0].poster, "[email protected]")
        self.assertIsNone(entries[0].group)

    @freeze_time("2016-01-11 18:00:00", tz_offset=0)
    def testPirateNzbParseSearchResult(self):
        # nzbsorg
        with open("mock/piratenzb_movies_response.xml") as f:
            entries = self.n1.process_query_result(f.read(), SearchRequest()).entries
        self.assertEqual(3, len(entries))

        self.assertEqual(entries[0].title, "title1")
        assert entries[0].size == 954926472
        assert entries[0].indexerguid == "d4776501c2b409c41f0649afc1e2d6d3f033119e"
        self.assertEqual(entries[0].age_days, 323)
        self.assertEqual(entries[0].epoch, 1424552357)
        self.assertEqual(entries[0].pubdate_utc, "2015-02-21T20:59:17+00:00")
        self.assertEqual(entries[0].details_link, "https://indexer.com/details/d4776501c2b409c41f0649afc1e2d6d3f033119e")

    def testNewznabSearchQueries(self):
        self.args = SearchRequest(query="aquery")
        queries = self.n1.get_search_urls(self.args)
        assert len(queries) == 1
        query = queries[0]
        self.assertUrlEqual("https://indexer.com/api?apikey=apikeyindexer.com&extended=1&limit=100&offset=0&q=aquery&t=search", query)

        self.args = SearchRequest(query=None)
        queries = self.n1.get_search_urls(self.args)
        assert len(queries) == 1
        query = queries[0]
        self.assertUrlEqual("https://indexer.com/api?apikey=apikeyindexer.com&extended=1&limit=100&offset=0&t=search", query)

        self.args = SearchRequest(query="")
        queries = self.n1.get_search_urls(self.args)
        assert len(queries) == 1
        query = queries[0]
        self.assertUrlEqual("https://indexer.com/api?apikey=apikeyindexer.com&extended=1&limit=100&offset=0&t=search", query)

        self.args = SearchRequest(category="Audio")
        queries = self.n1.get_search_urls(self.args)
        assert len(queries) == 1
        query = queries[0]
        self.assertUrlEqual("https://indexer.com/api?apikey=apikeyindexer.com&cat=3000&extended=1&limit=100&offset=0&t=search", query)
#.........这里部分代码省略.........
开发者ID:junkman690,项目名称:nzbhydra,代码行数:103,代码来源:test_Newznab.py

示例3: MyTestCase

# 需要导入模块: from nzbhydra.database import Indexer [as 别名]
# 或者: from nzbhydra.database.Indexer import save [as 别名]
class MyTestCase(IndexerTestcase):

    def setUp(self):    
        set_and_drop()
        config.load("testsettings.cfg")
        self.nzbsorgdb = Indexer(name="NZBs.org")
        self.nzbsorgdb.save()
        self.dognzbdb = Indexer(name="DOGNzb")
        self.dognzbdb.save()
        
        
        config.indexerSettings.newznab1.enabled = True
        config.indexerSettings.newznab1.host.set("http://127.0.0.1:5001/nzbsorg")
        config.indexerSettings.newznab1.apikey.set("apikeynzbsorg")
        self.n1 = NewzNab(config.indexerSettings.newznab1)
        self.n2 = NewzNab(config.indexerSettings.newznab2)
        
    
    @freeze_time("2015-10-12 20:00:00", tz_offset=-4)
    def testParseSearchResult(self):
        
        #nzbsorg
        with open("mock/nzbsorg_q_avengers_3results.xml") as f:
            entries = self.n1.process_query_result(f.read(), "aquery").entries
        self.assertEqual(3, len(entries))
        
        self.assertEqual(entries[0].title, "AVENGERS AGE OF ULTRON (2015)")
        assert entries[0].size == 2893890900
        assert entries[0].guid == "eff551fbdb69d6777d5030c209ee5d4b"
        self.assertEqual(entries[0].age_days, 1)
        self.assertEqual(entries[0].epoch, 1444584857)
        self.assertEqual(entries[0].pubdate_utc, "2015-10-11T17:34:17+00:00")
        self.assertEqual(entries[0].poster, "[email protected]")
        self.assertEqual(entries[0].group, "alt.binaries.mom")
        
        self.assertEqual(entries[1].group, "alt.binaries.hdtv.x264")
        
        
        
    
    def testNewznabSearchQueries(self):
        
        self.args = SearchRequest(query="aquery")
        queries = self.n1.get_search_urls(self.args)
        assert len(queries) == 1
        query = queries[0]
        assert "http://127.0.0.1:5001/nzbsorg" in query
        assert "apikey=apikeynzbsorg" in query
        assert "t=search" in query
        assert "q=aquery" in query
        
        self.args = SearchRequest(query=None)
        queries = self.n1.get_showsearch_urls(self.args)
        assert len(queries) == 1
        query = queries[0]
        assert "http://127.0.0.1:5001/nzbsorg" in query
        assert "apikey=apikeynzbsorg" in query
        assert "t=tvsearch" in query
        
        self.args = SearchRequest(category="All")
        queries = self.n1.get_showsearch_urls(self.args)
        assert len(queries) == 1
        query = queries[0]
        assert "http://127.0.0.1:5001/nzbsorg" in query
        assert "apikey=apikeynzbsorg" in query
        assert "t=tvsearch" in query
        
        self.args = SearchRequest(identifier_value="8511", identifier_key="rid")
        queries = self.n1.get_showsearch_urls(self.args)
        assert len(queries) == 1
        query = queries[0]
        assert "http://127.0.0.1:5001/nzbsorg" in query
        assert "apikey=apikeynzbsorg" in query
        assert "t=tvsearch" in query
        assert "rid=8511" in query
        
        self.args = SearchRequest(identifier_value="8511", identifier_key="rid", season=1)
        queries = self.n1.get_showsearch_urls(self.args)
        assert len(queries) == 1
        query = queries[0]
        assert "http://127.0.0.1:5001/nzbsorg" in query
        assert "apikey=apikeynzbsorg" in query
        assert "t=tvsearch" in query
        assert "rid=8511" in query
        assert "season=1" in query
        
        self.args = SearchRequest(identifier_value="8511", identifier_key="rid", season=1, episode=2)
        queries = self.n1.get_showsearch_urls(self.args)
        assert len(queries) == 1
        query = queries[0]
        assert "http://127.0.0.1:5001/nzbsorg" in query
        assert "apikey=apikeynzbsorg" in query
        assert "t=tvsearch" in query
        assert "rid=8511" in query
        assert "season=1" in query
        assert "ep=2" in query
        
        self.args = SearchRequest(identifier_value="12345678", identifier_key="imdbid")
        queries = self.n1.get_moviesearch_urls(self.args)
        assert len(queries) == 1
#.........这里部分代码省略.........
开发者ID:gh0std4ncer,项目名称:nzbhydra,代码行数:103,代码来源:testNewznab.py


注:本文中的nzbhydra.database.Indexer.save方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。