-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Got code some structure. added features *notifications *can ran background supports ubuntu 16.04
- Loading branch information
Showing
6 changed files
with
184 additions
and
3 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import os | ||
import time | ||
import random | ||
import magti | ||
import telasi | ||
|
||
|
||
# Change Values *required: | ||
|
||
#CO/MAGTI | ||
Username = 'YOUR CO/MAGTI USERNAME' | ||
Password = 'YOUR CO/MAGTI PASSWORD' | ||
### | ||
|
||
#Telasi | ||
Telasi_id = 'ID' | ||
|
||
|
||
# Notify me to pay | ||
|
||
|
||
until_its_left = 3 # days | ||
|
||
now = time.strftime("%d.%m.%Y") | ||
|
||
# running external py functions | ||
|
||
print('telasi = ',telasi.telasi_bil(Telasi_id, now)) | ||
|
||
print('magti = ',magti.magti_bil(Username,Password,now)) | ||
|
||
|
||
# end of running them | ||
|
||
def notifications(From,Message): | ||
os.system('notify-send "%s" "%s"' % (From, Message)) | ||
|
||
notifications(telasi.telasi_bil(Telasi_id, now)[0],telasi.telasi_bil(Telasi_id, now)[1]+' left\n' | ||
+str(telasi.telasi_bil(Telasi_id, now)[2])+' ლარი') | ||
|
||
notifications(magti.magti_bil(Username,Password,now)[0],magti.magti_bil(Username,Password,now)[1]+' left\n' | ||
+str(magti.magti_bil(Username,Password,now)[2]) +' ლარი') | ||
|
||
|
||
while True: | ||
|
||
if int(telasi.telasi_bil(Telasi_id, now)[1][:2]) <= until_its_left or int(magti.magti_bil(Username,Password,now)[1][:2]) <= until_its_left: | ||
|
||
os.system("gnome-terminal -e 'python ./payment.py'") | ||
|
||
break | ||
|
||
else: | ||
|
||
hr_in_sec = [10800, 7200] # 3 or 2 | ||
|
||
notifications('Billy','I go sleep') | ||
|
||
time.sleep(random.choice(hr_in_sec)) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
from datetime import datetime | ||
from bs4 import BeautifulSoup | ||
import requests | ||
from urllib import parse | ||
import json | ||
|
||
|
||
def magti_bil(co__username, co__password , now): | ||
session = requests.Session() | ||
session.cookies.get_dict() | ||
|
||
frst_post = session.post("https://userarea.magticom.ge", data={'UserName': co__username, 'Password': co__password}) | ||
|
||
frst_view = BeautifulSoup(frst_post.text, 'lxml') | ||
|
||
attrs = {} | ||
for vals in frst_view.findAll('input'): | ||
attrs[vals['id'][3:]] = vals['value'] | ||
|
||
attrs['TabIndex'] = '0' | ||
|
||
headers = { | ||
'Accept': '*/*', | ||
'Accept-Encoding': 'gzip, deflate, br', | ||
'Accept-Language': 'en-US,en;q=0.8,ru;q=0.6,ka;q=0.4', | ||
'Cache-Control': 'no-cache', | ||
'Connection': 'keep-alive', | ||
'Content-Length': '84', | ||
'Content-Type': 'application/x-www-form-urlencoded', | ||
'Cookie': '__utma=142200110.405086356.1478026025.1478467079.1481496629.3; _ga=GA1.2.405086356.1478026025; ' | ||
'ASP.NET_SessionId=%(ASP.NET_SessionId)s' % session.cookies.get_dict(), | ||
'Host': 'userarea.magticom.ge', | ||
'Origin': 'https://userarea.magticom.ge', | ||
'Pragma': 'no-cache', | ||
'Referer': '%s' % frst_post.url, | ||
'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.91 Safari/537.36', | ||
'X-Requested-With': 'XMLHttpRequest', | ||
} | ||
|
||
scnd_post = requests.post('https://userarea.magticom.ge/Services/LoadTab', data=parse.urlencode(attrs).encode(), | ||
headers=headers) | ||
|
||
scnd_view = BeautifulSoup(scnd_post.text, 'html.parser') | ||
|
||
eaten = json.loads(scnd_view.text) | ||
|
||
third_view = BeautifulSoup(eaten['Data'], 'html.parser') | ||
|
||
dirty_p = third_view.findAll('p') | ||
clean_p = [] | ||
|
||
for clean in dirty_p: | ||
clean_p.append(clean.text) | ||
|
||
latest_dict = dict([(k, v) for k, v in zip(clean_p[::2], clean_p[1::2])]) | ||
|
||
pay_day = latest_dict['გათიშვის თარიღი'] | ||
|
||
pay_day = datetime.strptime(pay_day, "%d.%m.%Y") | ||
|
||
now = datetime.strptime(now, "%d.%m.%Y") | ||
|
||
time = pay_day - now | ||
|
||
ret_list = ['CO/Magti',str(time)[:7], latest_dict['ბალანსი']] | ||
|
||
return ret_list |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import os | ||
|
||
|
||
inp = input("Do you want me to pay bills?") | ||
|
||
if inp == 'Y': | ||
print("Can't do this right now") | ||
|
||
# Here will be added support of online banking when I'll have time |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
from datetime import datetime | ||
from bs4 import BeautifulSoup | ||
import requests | ||
|
||
|
||
def telasi_bil (ID,now): | ||
frst_post = requests.get('http://my.telasi.ge/customers/info/%s' % ID) | ||
soup = BeautifulSoup(frst_post.text,'html.parser') | ||
|
||
result = [] | ||
for code in soup.findAll('code'): | ||
result.append(code.text) | ||
|
||
|
||
result = [float(i) for i in result[1:4]] | ||
|
||
|
||
pay_day_water_filter = [] | ||
|
||
for ultag in soup.find_all('div', {'class': 'pull-right'}): | ||
pay_day_water_filter.append(ultag.text) | ||
|
||
bill_for_water = sum(result) | ||
|
||
pay_day = pay_day_water_filter[-1] | ||
|
||
pay_day = datetime.strptime(pay_day.strip(), "%d/%m/%Y") | ||
|
||
now = datetime.strptime(now, "%d.%m.%Y") | ||
|
||
time = pay_day - now | ||
|
||
ret_list = ['Telasi',str(time)[:6], bill_for_water] | ||
|
||
return ret_list |