12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091 |
- #!/usr/bin/env python3
- import sys
- import db_methods
-
-
- def help_info():
- print(""" _.-~` `~-.
- _.--~~~---,.__ _.,;; . -=(@'`\\
- .-` ``~~~~--~~` ';;; ____)
- _.' '. ';;;;; '`_.'
- .-~;` `\ ' ';;;;;__.~`
- .' .' `'. | / /;''
- \/ .---'''``) /'-._____.--'\ \\
- _/| (` / /` `\ \__
- ', `/- \ \ __/ (_ /-\-\-`
- `;'-..___) | `/-\-\-` Lizard
- `-. .' the 8chan monitor
- `~~~~`` v0.2
-
- Usage: ./lizard [command] [options]
-
- Available commands:
- l - Lists all threads in database. Legend: ! - new replies, x - 404'd.
- r - Refresh all threads and update database.
- rc - Conservative refresh: Tries to refresh only threads which are likely to receive new replies, reducing
- unnecessary network activity.
- rl - Conservative refresh and list threads.
- ro - Conservative refresh and open threads with new replies in browsed.
- o - Open threads with new replies in the default browser. Will also update the "new replies"
- field accordingly.
- oa - Open all threads.
- p - Purge (remove) 404'd threads from database.
- c - Create new database.
- b - Backup current database.
- e - Export list of threads. This will create a list of lizard add commands for all threads currently in the
- database. Useful for migrating between database versions.
- a - Add thread to database. Requires option (URL of the thread). Will also attempt to download
- the thread.
- d - Remove all instances of a thread (board & number) from the database.
- Example: "lizard d b 123" will remove thread >>>/b/123
- """)
- exit()
-
-
- def main():
- n = len(sys.argv)
- if n < 2: help_info()
- command = sys.argv[1]
- if n == 2:
- if command == 'l':
- db_methods.list_threads()
- elif command == 'r':
- db_methods.refresh_all_threads()
- elif command == 'rc':
- db_methods.refresh_all_threads(conservative=True)
- elif command == 'rl':
- db_methods.refresh_all_threads(conservative=True)
- db_methods.list_threads()
- elif command == 'ro':
- db_methods.refresh_all_threads(conservative=True)
- db_methods.open_threads_with_new_replies()
- elif command == 'o':
- db_methods.open_threads_with_new_replies()
- elif command == 'oa':
- db_methods.open_all_threads()
- elif command == 'p':
- db_methods.remove_404_threads()
- elif command == 'c':
- db_methods.create_new_database()
- elif command == 'b':
- db_methods.backup_database()
- elif command == 'e':
- db_methods.export_thread_list()
- else:
- help_info()
- elif n == 3:
- if command == 'a':
- db_methods.add_thread_to_db(sys.argv[2])
- else:
- help_info()
- elif n == 4:
- if command == 'd':
- db_methods.remove_thread_by_id(sys.argv[2], sys.argv[3])
- else:
- help_info()
- else:
- help_info()
-
-
- if __name__ == '__main__':
- main()
|