JuanjoSalvador / NyaaPy

Unofficial Python wrapper for Nyaa anime torrent sites
MIT License
48 stars 23 forks source link

Improve cat-subcat extraction #7

Closed JuanjoSalvador closed 6 years ago

JuanjoSalvador commented 6 years ago

Each category has its own subcategories, so I group all of them into a dict with subdicts.

The key to access to category and subcategory name, is a number. I'm getting this error:

(nyaa) {00:31:54} [~/Proyectos/NyaaPy] [version-0.4 *] → python3 tests/test.py        
Traceback (most recent call last):
  File "tests/test.py", line 37, in <module>
    nyaa_news()
  File "tests/test.py", line 12, in nyaa_news
    news = Nyaa.news(5)
  File "/usr/local/lib/python3.6/site-packages/nyaapy-0.4.1-py3.6.egg/NyaaPy/__init__.py", line 88, in news
    'category': get_categories(block[0]),
  File "/usr/local/lib/python3.6/site-packages/nyaapy-0.4.1-py3.6.egg/NyaaPy/__init__.py", line 173, in get_categories
    return "{} - {}".format(categories[cat]['name'], categories[cat]['subcats'][subcat])
TypeError: string indices must be integers