Browse Source

Fixes #10

Signed-off-by: Abrax <abrax@teknik.io>
master
Abrax 3 years ago
parent
commit
008206ffbd
2 changed files with 14 additions and 0 deletions
  1. 4
    0
      lizard.py
  2. 10
    0
      logic/db_methods.py

+ 4
- 0
lizard.py View File

@@ -29,6 +29,8 @@ Available commands:
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.
@@ -59,6 +61,8 @@ if __name__ == '__main__':
logic.db_methods.create_new_database()
elif command == 'b':
logic.db_methods.backup_database()
elif command == 'e':
logic.db_methods.export_thread_list()
else:
help_info()
elif n == 3:

+ 10
- 0
logic/db_methods.py View File

@@ -10,6 +10,7 @@ import logic.time_methods
import logic.web_methods
from logic import constants
from logic import db_model
from logic import time_methods
from logic.db_model import Thread
from logic.file_io import get_cache_path
from logic.json_methods import time_of_last_reply, get_oldest_reply
@@ -161,3 +162,12 @@ def remove_404_threads():

for t in threads:
t.delete_instance()


def export_thread_list():
threads = Thread.select()
print('Exporting {} threads.'.format(len(threads)))

with open(os.path.join(constants.cache_path, 'Exported {}.txt'.format(time_methods.timestamp_now())), 'w') as f:
for t in threads:
f.write('./lizard.py a "{}"\n'.format(t.original_url))

Loading…
Cancel
Save