Преглед на файлове

Summary: added special treatment for picturesfromthezone

Markus Spring преди 3 години
родител
ревизия
9725b8dc89
променени са 1 файла, в които са добавени 40 реда и са изтрити 11 реда
  1. 40 11
      blogsiread.py

+ 40 - 11
blogsiread.py

@@ -1,9 +1,12 @@
 #!/usr/bin/python3
 
-# 	$Id: blogsiread.py,v 1.5 2022/10/01 11:36:32 springm Exp springm $
-#       $Revision: 1.5 $
-#       $Date: 2022/10/01 11:36:32 $
+# 	$Id: blogsiread.py,v 1.6 2022/10/10 14:30:28 springm Exp springm $
+#       $Revision: 1.6 $
+#       $Date: 2022/10/10 14:30:28 $
 #       $Log: blogsiread.py,v $
+#       Revision 1.6  2022/10/10 14:30:28  springm
+#       Summary: lfi repariert
+#
 #       Revision 1.5  2022/10/01 11:36:32  springm
 #       Summary: Works
 #
@@ -180,12 +183,10 @@ def lfionlinede(b, domain, i):
     m = hashlib.sha256()
     html = ""
     ts = 0                      # timestamp
-    url = 'https://lfi-online.de/ceemes/de/blog/'
-    logger.debug(f"{b[1]}")
     with urllib.request.urlopen(b[1]) as response:
         html = response.read()
         p = re.search('titlebox30 cu-pointer[\'"] onclick=[\'"]window.location\s*=\s*[\'"](https://.*?)[\'"][\'"]>\s*<h1.*?>(.*?)</h1', html.decode('utf-8'), re.MULTILINE | re.DOTALL)
-        logger.debug(f"{p[2]}")
+        # logger.debug(f"{p[2]}")
         string2hash = f"""p[2]"""
         m.update(string2hash.encode('utf-8'))
         hash = (m.hexdigest())
@@ -213,6 +214,37 @@ def lfionlinede(b, domain, i):
             return (q, meta_values[domain]['timestamp'])
         return (b, meta_values[domain]['timestamp'])
 
+def picturesfromthezone(b, domain, i):
+    global meta_values
+    m = hashlib.sha256()
+    html = ""
+    ts = 0                      # timestamp
+    with urllib.request.urlopen(b[1]) as response:
+        html = response.read()
+        string2hash = f"""html"""
+        m.update(string2hash.encode('utf-8'))
+        hash = (m.hexdigest())
+        if not domain in meta_values: # first run
+            logger.debug(domain)
+            meta_values[domain] = { 'hash': '1' } # fake value
+        if not meta_values[domain]['hash'] == hash:      # Unterschiedliche Hashes
+            logger.debug('unterschiedliche hashes')
+            meta_values[domain] = { 'hash': hash,
+                                    'timestamp': timestamp - i,
+                                    'posttitle': '',
+                                    'posturl':   b[1] }
+            q = {}
+            q[2] = ''
+            q[1] = b[1]
+            return (q, timestamp + i)
+        else:
+            logger.debug('gleiche hashes')
+            q = {}
+            q[1] = meta_values[domain]['posturl']
+            q[2] = meta_values[domain]['posttitle']
+            return (q, meta_values[domain]['timestamp'])
+        # return (b, meta_values[domain]['timestamp'])
+
 def treat_special_domain(domain, b, i):
     ts = 0
     if domain == 'www.orengrad.com':
@@ -220,12 +252,11 @@ def treat_special_domain(domain, b, i):
     # elif domain == 'jims-ramblings.blogspot.com':
     #     print(f"special: {domain}")
     elif domain == 'lfi-online.de':
-        logger.debug(f"{b[1]} {b[2]}")
         (b, ts)  = lfionlinede(b, domain, i)
     elif domain == 'photoplacegallery.com':
         (b, ts)  = photoplacegallery(b, domain, i)
-    # elif domain == 'www.picturesfromthezone.com':
-    #     print(f"special: {domain}")
+    elif domain == 'www.picturesfromthezone.com':
+        (b, ts)  = picturesfromthezone(b, domain, i)
     return (b, ts)
 
 def read_spring2life_links():
@@ -252,8 +283,6 @@ def read_spring2life_links():
         else:
             (z, ts) = treat_special_domain(bdomain, b, counter)
             blogtimestamp = ts
-            if bdomain == 'lfi-online.de':
-                logger.debug(f"into list: \n{burl} // {b[2]}\n{z[1]} // {z[2]}")
         counter += 1
         list_of_blogs[int(blogtimestamp)] = (f"""<li><a href='{burl}' target='_blank'>{b[2]}</a>"""
                                              f"""&nbsp;//&nbsp;<a href='{z[1]}' target='_blank'>{z[2]}</a></li>""")