mirror of
https://github.com/house-of-vanity/tracker_watcher.git
synced 2025-07-07 09:54:08 +00:00
Change project wide timezone to UTC.
This commit is contained in:
@ -1,3 +1,9 @@
|
|||||||
[bot]
|
[bot]
|
||||||
telegram_key = 539154645:ASJDDHaseytrrl9mHzGuKBiqegHAxaRZxVw
|
telegram_key = 539154645:ASJDDHaseytrrl9mHzGuKBiqegHAxaRZxVw
|
||||||
telegram_api = https://api.telegram.org/
|
telegram_api = https://api.telegram.org/
|
||||||
|
|
||||||
|
[mysql]
|
||||||
|
mysql_user = root
|
||||||
|
mysql_pass =
|
||||||
|
mysql_host = localhost
|
||||||
|
mysql_db = test
|
22
updater.py
22
updater.py
@ -3,12 +3,22 @@
|
|||||||
import pymysql.cursors
|
import pymysql.cursors
|
||||||
import urllib.request, json
|
import urllib.request, json
|
||||||
import datetime as dt
|
import datetime as dt
|
||||||
|
from configparser import ConfigParser
|
||||||
|
import pytz
|
||||||
|
|
||||||
|
parser = ConfigParser()
|
||||||
|
parser.read('settings.ini')
|
||||||
|
mysql_user = parser.get('mysql', 'mysql_user')
|
||||||
|
mysql_host = parser.get('mysql', 'mysql_host')
|
||||||
|
mysql_db = parser.get('mysql', 'mysql_db')
|
||||||
|
mysql_pass = parser.get('mysql', 'mysql_pass')
|
||||||
|
|
||||||
interval = '1 HOUR'
|
interval = '1 HOUR'
|
||||||
|
interval = '1 MINUTE'
|
||||||
# Connect to the database
|
# Connect to the database
|
||||||
connection = pymysql.connect(host='localhost',
|
connection = pymysql.connect(host=mysql_host,
|
||||||
user='root',
|
user=mysql_user,
|
||||||
db='test',
|
db=mysql_db,
|
||||||
cursorclass=pymysql.cursors.DictCursor)
|
cursorclass=pymysql.cursors.DictCursor)
|
||||||
|
|
||||||
# If u_date which already stored older than fresh u_date
|
# If u_date which already stored older than fresh u_date
|
||||||
@ -18,8 +28,9 @@ def check_updates(id, u_date):
|
|||||||
with urllib.request.urlopen(
|
with urllib.request.urlopen(
|
||||||
"http://api.rutracker.org/v1/get_tor_topic_data?by=topic_id&val="+id) as url:
|
"http://api.rutracker.org/v1/get_tor_topic_data?by=topic_id&val="+id) as url:
|
||||||
data = json.loads(url.read().decode())
|
data = json.loads(url.read().decode())
|
||||||
last_check = dt.datetime.now()
|
last_check = dt.datetime.now(tz=pytz.utc)
|
||||||
new_u_date = dt.datetime.fromtimestamp(int(data['result'][id]['reg_time']))
|
new_u_date = dt.datetime.fromtimestamp(int(data['result'][id]['reg_time']), tz=pytz.utc)
|
||||||
|
u_date = pytz.utc.localize(u_date)
|
||||||
if new_u_date > u_date:
|
if new_u_date > u_date:
|
||||||
print("There is an update. Going to notify.")
|
print("There is an update. Going to notify.")
|
||||||
|
|
||||||
@ -36,6 +47,7 @@ try:
|
|||||||
with connection.cursor() as cursor:
|
with connection.cursor() as cursor:
|
||||||
# Read a single record
|
# Read a single record
|
||||||
sql = "SELECT * FROM url WHERE last_check < DATE_SUB(NOW(), INTERVAL %s)" % interval
|
sql = "SELECT * FROM url WHERE last_check < DATE_SUB(NOW(), INTERVAL %s)" % interval
|
||||||
|
sql = "SELECT * FROM url"
|
||||||
cursor.execute(sql)
|
cursor.execute(sql)
|
||||||
result = cursor.fetchall()
|
result = cursor.fetchall()
|
||||||
for line in result:
|
for line in result:
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
$config = parse_ini_file("../settings.ini");
|
$config = parse_ini_file("../settings.ini");
|
||||||
$dbh = new PDO('mysql:host=localhost;dbname=test', 'root');
|
|
||||||
|
$dbh = new PDO('mysql:host='.$config['mysql_host'].';dbname='.$config['mysql_db'], $config['mysql_user']);
|
||||||
|
|
||||||
$request = file_get_contents('php://input');
|
$request = file_get_contents('php://input');
|
||||||
$request = json_decode( $request, TRUE );
|
$request = json_decode( $request, TRUE );
|
||||||
|
Reference in New Issue
Block a user