aboutsummaryrefslogtreecommitdiffstats
path: root/cli.py
diff options
context:
space:
mode:
Diffstat (limited to 'cli.py')
-rwxr-xr-xcli.py40
1 files changed, 40 insertions, 0 deletions
diff --git a/cli.py b/cli.py
new file mode 100755
index 0000000..9bc6c39
--- /dev/null
+++ b/cli.py
@@ -0,0 +1,40 @@
+#!/usr/bin/env python3
+
+import sys
+import collections
+
+import anidb
+import yaml
+
+def setup_yaml():
+ """ https://stackoverflow.com/a/8661021 """
+ represent_dict_order = lambda self, data: self.represent_mapping(
+ 'tag:yaml.org,2002:map', data.items())
+ yaml.add_representer(collections.OrderedDict, represent_dict_order)
+ yaml.SafeDumper.add_representer(collections.OrderedDict, represent_dict_order)
+
+setup_yaml()
+
+adb = anidb.AniDB('anishow', client_ver=1)
+results = adb.search(sys.argv[1:])
+
+print('results: ', results)
+result = results[-1]
+print('choosing result -1:', result)
+
+print('result.type:', result.type)
+#print('result.startdate:', result.startdate)
+
+for result in results:
+ print('dump yaml:')
+ print('='*60)
+ print(yaml.safe_dump(collections.OrderedDict(
+ title=result.title,
+ type=result.type,
+ description=result.description,
+ episodecount=result.episodecount,
+ #startdate=result.startdate,
+ #enddate=result.enddate,
+ anidb_aid=result.aid,
+ ), encoding='utf8', allow_unicode=True,
+ default_flow_style=False).decode('utf8'))