Browse Source

All version strings are automatically obtained from the current install + more informative useragent.

master
Abrax 3 years ago
parent
commit
8ed199f00b
3 changed files with 11 additions and 5 deletions
  1. 1
    0
      db_model.py
  2. 5
    2
      lizard.py
  3. 5
    3
      web_methods.py

+ 1
- 0
db_model.py View File

@@ -3,6 +3,7 @@ from file_io import path_to_database

db = SqliteDatabase(path_to_database())


class Thread(Model):
original_url = CharField()
board = CharField()

+ 5
- 2
lizard.py View File

@@ -1,6 +1,9 @@
#!/usr/bin/env python3
import sys
import db_methods
import pkg_resources

version = pkg_resources.require("lizard")[0].version


def help_info():
@@ -15,7 +18,7 @@ def help_info():
', `/- \ \ __/ (_ /-\-\-`
`;'-..___) | `/-\-\-` Lizard
`-. .' the 8chan monitor
`~~~~`` v0.2
`~~~~`` v{}

Usage: ./lizard [command] [options]

@@ -38,7 +41,7 @@ Available commands:
the thread.
d - Remove all instances of a thread (board & number) from the database.
Example: "lizard d b 123" will remove thread >>>/b/123
""")
""".format(version))
exit()



+ 5
- 3
web_methods.py View File

@@ -1,11 +1,13 @@
import json
import re
import requests
from lizard import version
from file_io import *
from file_io import generate_json_path
from json_methods import extract_filenames

user_agent = 'https://git.teknik.io/abrax/lizard'
user_agent = 'Lizard v{}: https://git.teknik.io/abrax/lizard'.format(version)


def fetch_and_parse_thread_json(board, thread_no):
url = generate_thread_json_url(board, thread_no)
@@ -96,6 +98,6 @@ def parse_url(url):
parts = url.split('#', 1)

board, thread_no = re.findall('(\w+)\/res\/(\d+)', parts[0])[0]
anchored_reply = '' if len(parts)<2 else re.findall('q?(\d+)$', parts[1])[0]
anchored_reply = '' if len(parts) < 2 else re.findall('q?(\d+)$', parts[1])[0]

return [board, thread_no, anchored_reply]
return [board, thread_no, anchored_reply]

Loading…
Cancel
Save