= beginn:
+ feiertag = True
+ if jetzt+1 == beginn:
+ feiertag_morgen = True
+ x = x+1
+
+print('Es sind Ferien: '+ str(ferien))
+print('Es sind morgen Ferien: '+ str(ferien_morgen))
+print('Es ist ein Feiertag: '+str(feiertag))
+print('Es ist morgen ein Feiertag: '+str(feiertag_morgen))
+
+if feiertag_morgen:
+ mailzusatz = '\n \nMorgen ist ein Feiertag.\nNeue Nachrichten erst am nächsten Werktag wieder.\nGenießt die Zeit!'
+############################################################
+if ferien:
+ print('Es sind Ferien, also lass ich euch in Ruhe')
+ quit()
+if feiertag_morgen:
+ print('Morgen ist Feiertag, also gibts auch nichts, was sich lohnt, anzuschauen.')
+ #quit()
+
+try:
+ os.rename(pfad + '/mpg/heute.pdf', pfad +'/mpg/heute1.pdf')
+ url = 'heute'
+ Download(url)
+ x = os.stat(pfad+'/mpg/heute.pdf')
+ x = x.st_size
+ x1 = str(x)
+ y = os.stat(pfad+'/mpg/heute1.pdf')
+ y = y.st_size
+ y1 = str(y)
+
+
+ if x != y:
+ mail=mail+1
+ else:
+ print("Es gibt keine neuen Mals mit 'heute'")
+ d = modification_date(pfad+'/mpg/heute.pdf')
+ d = d.strftime('%H:%M:%S')
+ print("heute: " + d + ' '+ x1 + ' Bytes')
+ d = modification_date(pfad+'/mpg/heute1.pdf')
+ d = d.strftime('%H:%M:%S')
+ print("heute1: " + d + ' '+ y1 + ' Bytes')
+except FileNotFoundError:
+ print("File Heute.PDF not found")
+ print("Will try to download it from the MPG-Server")
+ url = 'heute'
+ Download(url)
+
+try:
+ os.rename(pfad+'/mpg/morgen.pdf', pfad+'/mpg/morgen1.pdf')
+ url = 'morgen'
+ Download(url)
+ x = os.stat(pfad+'/mpg/morgen.pdf')
+ x = x.st_size
+ x1 = str(x)
+ y = os.stat(pfad+'/mpg/morgen1.pdf')
+ y = y.st_size
+ y1 = str(y)
+ if x != y:
+ mail = mail + 2
+ else:
+ print("Es gibt keine neuen Mails mit 'morgen'")
+
+ d= modification_date(pfad+'/mpg/morgen.pdf')
+ d = d.strftime('%H:%M:%S')
+ print("morgen: " + d + ' ' + x1 + ' Bytes')
+ d = modification_date(pfad+'/mpg/morgen1.pdf')
+ d = d.strftime('%H:%M:%S')
+ print("morgen1: " + d + ' ' + x1 + ' Bytes')
+except FileNotFoundError:
+ print("File Morgen.PDF not found")
+ print("Will try to download it from the MPG-Server")
+ url = 'morgen'
+ Download(url)
+
+#sub='Hier kommt der Betreff rein'
+#body = 'hier der Mailtext'
+#anhang = ['adressen.txt','heute.pdf','morgen.pdf']
+#Nachricht (fradress,toadress,bcc,sub,body,anhang)
+
+if mail!=0 or jsonpass['debug']=='True':
+ if update():
+ print ('Neuer Tag, neues Gluck!')
+ if wtag == '1':
+ mailzusatz = '\n \nWillkommen in der ' + str(time.strftime('%W')) + '.Kalenderwoche.' + \
+ '\nNicht verzagen, nur Druck formt aus Kohle einen Diamanten!' \
+ '\nZitat des Tages:\n'+ jsonpass['zitat']+ \
+ '\nAutor: ' + jsonpass['autor'] + '\n'
+ if wtag == '2':
+ mailzusatz = '\n \nDer Montag liegt hinter uns.\nAb heuteb kann es nur noch aufwärts gehen!' \
+ '\nViel Spass, bei allem, was ihr so treibt\n'+ \
+ '\nZitat des Tages:\n'+ jsonpass['zitat']+ \
+ "\nAutor: " + jsonpass['autor'] + '\n'
+ if wtag == '3':
+ lotto=Lotto()
+ mailzusatz = '\n \nHallo Mittwoch!\nIch wünsche eine schöne Wochenmitte.\nKopf hoch! ' \
+ + 'Wenn ich Lotto spielen würde, dann kämen heute folgende Zahlen zum Einsatz: ' +lotto +\
+ '\n\nZitat des Tages:\n'+ jsonpass['zitat']+ \
+ "\nAutor: " + jsonpass['autor'] + '\n'
+ if wtag == '4':
+ mailzusatz = '\n \nDer Donnerstag ist bekanntlich der \'kleine Freitag\'' \
+ '\nNur noch einmal (!) Gas geben!\n' '\nZitat des Tages:\n'+ jsonpass['zitat']+\
+ '\nAutor: '+jsonpass['autor']+'\n'
+ if wtag == '5':
+ lotto=Lotto()
+ mailzusatz = '\n \nEs ist Freitag!\nIch wünsche ein schönes Wochenende.' \
+ '\nNeue Nachrichten kommen erst am Montag wieder.\n'+'Vieleicht habt ihr ja am Samstag'\
+ ' Glück beim Lotto. Probiert doch mal diese Zahlen: '+lotto+\
+ '\n\nZitat des Tages:\n'+ jsonpass['zitat']+\
+ '\nAutor: '+jsonpass['autor']+'\n'
+ else:
+ print ('im Westen nix neues')
+
+if jsonpass['debug']=="True":
+ update()
+ print('DEBUG_MODE')
+ bcc=jsonpass['debug_adress']
+ TOKEN = jsonpass['debug_TOKEN']
+ chat_id = jsonpass['debug_Chat_ID']
+ tb = telebot.TeleBot(TOKEN)
+ mailzusatz = mailzusatz + '\n \nDies ist eine Testnachricht!\nDer Versand erfolgt nur an Hubobel und schneeschieben.\n\n' \
+ 'Zitat des Tages:\n'+ jsonpass['zitat']+'\nAutor: '+jsonpass['autor']+'\n'
+if 'wetter_API' in jsonpass:
+ if jsonpass['wetter_API']!='':
+ temperatur,wetter,feuchte=Wetter()
+ bericht='\nAktuell haben wir geschmeidige '+str(temperatur)+' Grad Celsius bei '+str(feuchte)\
+ +' Luftfeuchtigkeit.\nDer Himmel ist '+str(wetter)+'.\n'
+ else:
+ bericht = 'Wie das Wetter derzeit ist? Man(n) richte seinen Blick gen Himmel oder' \
+ ' generiere einen API-Key unter https://www.wunderground.com/signup?mode=api_signup'
+else:
+ bericht='Wie das Wetter derzeit ist? Man(n) richte seinen Blick gen Himmel oder' \
+ ' generiere einen API-Key unter https://www.wunderground.com/signup?mode=api_signup'
+fact='\nChuck-Norris-Fact:\n'+Chuckfact()
+
+shutil.copy(pfad+'/mpg/morgen.pdf',pfad+'/mpg/'+morgen_name+'.pdf')
+
+if mail == 1 or jsonpass['debug']=='True':
+ body = 'Es gibt eine aktuelle Version des heutigen Vertretungsplanes.'+mailzusatz+bericht+fact
+ anhang = ['heute.pdf']
+ sub = 'MPG-heute aktualisiert'
+ if os.path.isfile(pfad + '/mpg/adressen.txt'):
+ Nachricht(fradress, toadress, bcc, sub, body, anhang)
+ print (body+' ich versende das mal an: '+str(bcc))
+ if telegram:
+ document = open(pfad+'/mpg/heute.pdf', 'rb')
+ tb.send_document(chat_id, document, caption='Es gibt eine aktuelle Version des heutigen Vertretungsplanes.')
+ tb.send_message(chat_id, mailzusatz+bericht+fact)
+if mail == 2 or jsonpass['debug']=='True':
+ body = 'Es gibt eine aktualisierte Version des Vertretungsplanes für '+morgen_name+mailzusatz+bericht+fact
+ anhang = [morgen_name+'.pdf']
+ sub = 'MPG-morgen aktualisiert'
+ if os.path.isfile(pfad + '/mpg/adressen.txt'):
+ Nachricht(fradress, toadress, bcc, sub, body, anhang)
+ print (body+' ich versende das mal an: '+str(bcc))
+ if telegram:
+ document = open(pfad + '/mpg/'+morgen_name+'.pdf', 'rb')
+ tb.send_document(chat_id, document, caption='Es gibt eine aktualisierte Version '
+ 'des Vertretungsplanes für '+morgen_name+'.')
+ tb.send_message(chat_id, mailzusatz + bericht+fact)
+if mail == 3 or jsonpass['debug']=='True':
+ body = 'Es gibt aktualisierte Versionen der MPG-Vertretungspläne.'+mailzusatz+bericht+fact
+ anhang = ['heute.pdf',morgen_name+'.pdf']
+ sub = 'MPG-Vertretungspläne aktualisiert'
+ if os.path.isfile(pfad + '/mpg/adressen.txt'):
+ Nachricht(fradress, toadress, bcc, sub, body, anhang)
+ print (body+' ich versende das mal an: '+str(bcc))
+ if telegram:
+ document = open(pfad + '/mpg/heute.pdf', 'rb')
+ tb.send_document(chat_id, document, caption='Es gibt aktualisierte Versionen der MPG-Vertretungspläne.')
+ document = open(pfad + '/mpg/'+morgen_name+'.pdf', 'rb')
+ tb.send_document(chat_id, document)
+ tb.send_message(chat_id, mailzusatz + bericht+fact)
+
diff --git a/newsblur.py b/newsblur.py
new file mode 100644
index 0000000..c486cce
--- /dev/null
+++ b/newsblur.py
@@ -0,0 +1,24 @@
+import requests
+import json
+import time
+import datetime
+import os
+
+session = requests.session()
+url = 'http://www.newsblur.com/api/login'
+datas = {'username':'hubobel','password':'polier2003'}
+resp = session.post(url,datas)
+data = resp.json()
+print (data)
+
+
+url = 'http://www.newsblur.com/reader/refresh_feeds'
+resp = session.get(url)
+data = resp.json()
+print (json.dumps(data, indent=4))
+print (data['id'])
+url = 'http://www.newsblur.com/reader/feed/6212608'
+resp = session.get(url)
+data = resp.json()
+print (json.dumps(data, indent=4))
+print(data)
\ No newline at end of file
diff --git a/newsblur_api.py b/newsblur_api.py
new file mode 100644
index 0000000..0f5dd8e
--- /dev/null
+++ b/newsblur_api.py
@@ -0,0 +1,107 @@
+import requests
+import json
+import telebot
+import os
+import pymysql
+
+def laenge():
+ datas = '{"sid":"' + id + '","op":"getHeadlines","feed_id":-1}'
+ resp = requests.post(url, datas)
+ data = resp.json()
+ a=(len(data['content']))
+ return a
+
+TOKEN ='312534798:AAFbMjS-tfd2BiZ_j3NEZuQYKwzACMcioVo'
+chat_id ='322673713'
+tb = telebot.TeleBot(TOKEN)
+
+url = 'http://hubobel.de/tt-rss/api/'
+pfad = os.path.dirname(__file__)
+
+datas = '{"op":"login","user":"admin","password":"password"}'
+resp = requests.post(url,datas)
+data = resp.json()
+id= str(data['content']['session_id'])
+datas = '{"sid":"'+id+'","op":"getFeeds","cat_id":-4}'
+resp = requests.post(url,datas)
+data = resp.json()
+ids=[]
+gefunden=[]
+laenge_start=laenge()
+
+suchstring=[]
+fobj = open(pfad+"/toFind.txt")
+for line in fobj:
+ suchstring.append(line.rstrip())
+fobj.close()
+
+
+
+for i in data['content']:
+ if int(i['unread'])>0 and int(i['id'])>0:
+ datas = '{"sid":"'+id+'","op":"getHeadlines","feed_id":'+str(i['id'])+'}'
+ resp = requests.post(url,datas)
+ feeds = resp.json()
+ for headlines in feeds['content']:
+ if headlines['unread']:
+ a=0
+ b=len(suchstring)
+ if headlines['feed_id'] == '4':
+ article_id=str(headlines['id'])
+ datas = '{"sid":"' + id + '","op":"getArticle","article_id":'+article_id+'}'
+ resp = requests.post(url, datas)
+ data = resp.json()
+ antwort=str(data['content'][0]['content'])
+
+ connection = pymysql.connect(db="hubobel",
+ user="hubobel",
+ passwd="polier2003",
+ host='10.0.1.59', charset='utf8')
+ cursor = connection.cursor()
+ sql = "SELECT * FROM facts ORDER BY nr DESC"
+ resp = cursor.execute(sql)
+ x = int(resp) + 1
+
+ line = antwort.replace('', '')
+ line = line.replace('
', '')
+ sql = "INSERT INTO `facts`(`nr`, `fact`) VALUES ('" + str(x) + "','" + line + "')"
+ sql_q = "SELECT * FROM facts WHERE fact like '%" + line + "%'"
+ resp = cursor.execute(sql_q)
+ if resp == 0:
+ resp = cursor.execute(sql)
+ connection.commit()
+ cursor.close()
+ connection.close()
+
+
+ while a0:
+ bericht='Es gibt '+str(ergebniss)+' neue Nachrichte(n) mit den Begriffen '+str(gefunden)+\
+ ' in deinen News!\nEs sind nun '+str(unreadcount)+' ungelesene Nachrichten in deinen News.'
+ tb.send_message(chat_id, bericht)
+
+
+
+
diff --git a/pass 2.json b/pass 2.json
new file mode 100644
index 0000000..5da8b85
--- /dev/null
+++ b/pass 2.json
@@ -0,0 +1,22 @@
+{
+ "Chat_ID": "@mpglu",
+ "Land": "rp",
+ "TOKEN": "467241832:AAH3e0y6Fm7ig5DtConJP29GsD-zX1psNZo",
+ "Tag_Name": "Friday",
+ "Tag_Nummer": "5",
+ "Uhrzeit": "18:04:05",
+ "autor": "Justus von Liebig",
+ "ccu_ip": "10.0.1.100",
+ "debug": "True",
+ "debug_Chat_ID": "322673713",
+ "debug_TOKEN": "312534798:AAFbMjS-tfd2BiZ_j3NEZuQYKwzACMcioVo",
+ "debug_adress": "carsten@hubobel.de",
+ "gmail_pass": "PL19zPL19z",
+ "gmail_user": "carsten.richter77@gmail.com",
+ "mpg_pass": "Ing8gresk",
+ "mpg_user": "schueler",
+ "pfad": "/Users/hubobel/Documents/Python/mpgScanner",
+ "wetter_API": "35a8e37c649985d5",
+ "wetter_Ort": "ILUDWIGS227",
+ "zitat": "Die Wissenschaft f\u00e4ngt eigentlich erst da an interessant zu werden, wo sie aufh\u00f6rt."
+}
\ No newline at end of file
diff --git a/pass.json b/pass.json
new file mode 100644
index 0000000..e1956b3
--- /dev/null
+++ b/pass.json
@@ -0,0 +1,12 @@
+{
+ "Chat_ID": "@mpglu",
+ "Land": "rp",
+ "TOKEN": "467241832:AAH3e0y6Fm7ig5DtConJP29GsD-zX1psNZo",
+ "Tag_Name": "Tuesday",
+ "Tag_Nummer": "1508865191",
+ "Uhrzeit": "2",
+ "Wochentag": "2",
+ "ccu_ip": "10.0.1.100",
+ "gmail_pass": "PL19zPL19z",
+ "gmail_user": "carsten.richter77@gmail.com"
+}
\ No newline at end of file
diff --git a/telegram.py b/telegram.py
new file mode 100644
index 0000000..d4a969f
--- /dev/null
+++ b/telegram.py
@@ -0,0 +1,10 @@
+import telebot
+
+TOKEN = '467241832:AAH3e0y6Fm7ig5DtConJP29GsD-zX1psNZo'
+chat_id = '@mpglu'
+text='Es gibt einen neuen Vertretungsplan.'
+tb=telebot.TeleBot(TOKEN)
+tb.send_message(chat_id,text)
+
+document = open('heute.pdf','rb')
+tb.send_document(chat_id, document,caption='NEUUUUU')
\ No newline at end of file
diff --git a/test 2.py b/test 2.py
new file mode 100644
index 0000000..1bb3099
--- /dev/null
+++ b/test 2.py
@@ -0,0 +1,42 @@
+import requests
+import random
+
+def Lotto():
+ a = (sorted(random.sample(range(1, 49), 6)))
+ b = random.randrange(0, 9)
+ while b in a:
+ b = random.randrange(1, 9)
+ lotto = str(a) + ',Superzahl: ' + str(b)
+ return lotto,a,b
+
+url_zitat = 'http://api.hubobel.de/lotto/Mittwoch'
+resp_zitat = requests.get(url_zitat)
+data_zitat = resp_zitat.json()
+
+
+inhalt=data_zitat[1]
+a=[]
+
+count=1
+
+while count<7:
+ index=str('Z'+str(count))
+ a.append(inhalt[index])
+ count=count+1
+
+
+b,c,d=Lotto()
+
+
+treffer=0
+ergebniss=[]
+superzahl=''
+for i in c:
+ if i in a:
+ treffer=treffer+1
+ ergebniss.append(i)
+ if d == inhalt['Superzahl']:
+ superzahl=' und die Superzahl!'
+print('Die aktuellen Lottozahlen der '+inhalt['Datum']+' lauten: '+str(a)+',Superzahl: '+str(inhalt['Superzahl']))
+print('Sie haben getippt: '+ b)
+print('Sie haben '+str(treffer)+' Richtige '+str(ergebniss)+superzahl)
\ No newline at end of file
diff --git a/test.py b/test.py
new file mode 100644
index 0000000..8b80b3c
--- /dev/null
+++ b/test.py
@@ -0,0 +1,12 @@
+import requests
+from
+file = open("LOTTO_ab_2017.csv", "br")
+file=requests.get('http://www.lottotip-check.de')
+#csv_reader = csv.reader(file, delimiter=",")
+a=[]
+for row in file:
+ print(row)
+ a.append(row)
+file.close()
+print(len(a))
+print(a[len(a)-5])
\ No newline at end of file
diff --git a/test_2.py b/test_2.py
new file mode 100644
index 0000000..cc406d5
--- /dev/null
+++ b/test_2.py
@@ -0,0 +1,61 @@
+import bs4 as bs
+import urllib.request
+
+
+
+sauce=urllib.request.urlopen('http://www.lottotip-check.de').read()
+soup=bs.BeautifulSoup(sauce,'html.parser')
+
+#print(soup.prettify())
+table=soup.find_all('table')
+row=[]
+ZahlenAll=[]
+ZahlenMittwoch={'Datum':'','Z1':'','Z2':'','Z3':'','Z4':'','Z5':'','Z6':'','Superzahl':'','Spiel77':'','Super6':''}
+ZahlenSamstag={'Datum':'','Z1':'','Z2':'','Z3':'','Z4':'','Z5':'','Z6':'','Superzahl':'','Spiel77':'','Super6':''}
+ZahlenEuro={'Datum':'','Z1':'','Z2':'','Z3':'','Z4':'','Z5':'','Superzahl1':'','Superzahl2':''}
+for i in table:
+ table_rows = i.find_all('tr')
+ for tr in table_rows:
+ #print(tr)
+ td = tr.find_all('td')
+ if td != []:
+ row = [i.text for i in td]
+ #print(row)
+ th = tr.find_all('th')
+ sz = [i.text for i in th]
+ #print(len(sz))
+ if len(sz)==5:
+ row.append(str(sz[2]))
+ row.append(str(sz[3]))
+ date = 'Ziehung vom: ' + str(sz[0])
+ sz = str(sz[1])
+ row.append(sz)
+ row.insert(0, date)
+ ZahlenAll.extend(row)
+a=0
+while a<=5:
+ a=a+1
+ ZahlenMittwoch['Z'+str(a)]=int(ZahlenAll[a])
+ZahlenMittwoch['Datum']=ZahlenAll[0]
+ZahlenMittwoch['Superzahl']=int(ZahlenAll[9])
+ZahlenMittwoch['Super6']=int(ZahlenAll[8])
+ZahlenMittwoch['Spiel77']=int(ZahlenAll[7])
+print(ZahlenMittwoch)
+a=0
+while a<=5:
+ a=a+1
+ ZahlenSamstag['Z'+str(a)]=int(ZahlenAll[a + 18])
+ZahlenSamstag['Datum']=ZahlenAll[18]
+ZahlenSamstag['Superzahl']=int(ZahlenAll[27])
+ZahlenSamstag['Super6']=int(ZahlenAll[26])
+ZahlenSamstag['Spiel77']=int(ZahlenAll[25])
+print(ZahlenSamstag)
+
+a=0
+while a<=4:
+ a=a+1
+ ZahlenEuro['Z'+str(a)]=int(ZahlenAll[a + 10])
+ZahlenEuro['Datum']=ZahlenAll[10]
+ZahlenEuro['Superzahl2']=int(ZahlenAll[17])
+ZahlenEuro['Superzahl1']=int(ZahlenAll[16])
+print(ZahlenEuro)
diff --git a/toFind.txt b/toFind.txt
new file mode 100644
index 0000000..dd1e87e
--- /dev/null
+++ b/toFind.txt
@@ -0,0 +1,14 @@
+Chuck
+Apple
+Amazon
+Gutschein
+Battlefield
+Star Wars
+Kodi
+Nolan
+Dunkirk
+Star Trek
+iPhone
+iOS
+IOS
+macOS
diff --git a/txt2json.py b/txt2json.py
new file mode 100644
index 0000000..064f5c1
--- /dev/null
+++ b/txt2json.py
@@ -0,0 +1,12 @@
+chuck_file= open(pfad + '/api/chuck.txt','r',encoding='UTF-8')
+for line in chuck_file:
+ fact.append(line.strip('\n'))
+chuck_file.close()
+ran=random.randint(1,len(fact)-1)
+fakt={}
+a=0
+for i in fact:
+ fakt[a]=i
+ a =a +1
+with open(pfad+'/api/chuck.json', 'w',encoding='ascii') as fp:
+ json.dump(fakt, fp, sort_keys=True, indent=4)
\ No newline at end of file