AdBlock: added the NoCoin list to the defaults and fixed an issue updating subscriptions.

Thu, 15 Feb 2018 19:05:22 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Thu, 15 Feb 2018 19:05:22 +0100
changeset 6150
20efcd29b237
parent 6149
e611e45a17d6
child 6151
29564aad2f97

AdBlock: added the NoCoin list to the defaults and fixed an issue updating subscriptions.

WebBrowser/AdBlock/AdBlockManager.py file | annotate | diff | comparison | revisions
WebBrowser/AdBlock/AdBlockSubscription.py file | annotate | diff | comparison | revisions
--- a/WebBrowser/AdBlock/AdBlockManager.py	Tue Feb 13 19:59:44 2018 +0100
+++ b/WebBrowser/AdBlock/AdBlockManager.py	Thu Feb 15 19:05:22 2018 +0100
@@ -66,6 +66,11 @@
             "abp:subscribe?location=" \
             "https://easylist-downloads.adblockplus.org/easylist.txt&"\
             "title=EasyList"
+        self.__additionalDefaultSubscriptionUrlStrings = (
+            "abp:subscribe?location=https://raw.githubusercontent.com/"
+            "hoshsadiq/adblock-nocoin-list/master/nocoin.txt&"
+            "title=NoCoin",
+        )
         self.__customSubscriptionUrlString = \
             bytes(self.__customSubscriptionUrl().toEncoded()).decode()
         
@@ -407,19 +412,16 @@
         subscriptions = Preferences.getWebBrowser("AdBlockSubscriptions")
         if subscriptions:
             for subscription in subscriptions:
-                if subscription.startswith(
-                        self.__defaultSubscriptionUrlString):
-                    break
-            else:
-                subscriptions.insert(0, self.__defaultSubscriptionUrlString)
-            for subscription in subscriptions:
                 if subscription.startswith(self.__customSubscriptionUrlString):
                     break
             else:
                 subscriptions.append(self.__customSubscriptionUrlString)
         else:
-            subscriptions = [self.__defaultSubscriptionUrlString,
-                             self.__customSubscriptionUrlString]
+            subscriptions = [
+                self.__defaultSubscriptionUrlString,
+                *self.__additionalDefaultSubscriptionUrlStrings,
+                self.__customSubscriptionUrlString,
+            ]
         for subscription in subscriptions:
             url = QUrl.fromEncoded(subscription.encode("utf-8"))
             adBlockSubscription = AdBlockSubscription(
--- a/WebBrowser/AdBlock/AdBlockSubscription.py	Tue Feb 13 19:59:44 2018 +0100
+++ b/WebBrowser/AdBlock/AdBlockSubscription.py	Thu Feb 15 19:05:22 2018 +0100
@@ -329,6 +329,9 @@
                             if time:
                                 self.__remoteModified.setTime(
                                     QTime(int(hour), int(minute)))
+                            else:
+                                # no time given, set it to 23:59
+                                self.__remoteModified.setTime(QTime(23, 59))
                     self.changed.emit()
         elif not fileName.endswith("_custom"):
             self.__lastUpdate = QDateTime()
@@ -368,10 +371,11 @@
             return
         
         from WebBrowser.WebBrowserWindow import WebBrowserWindow
-        self.__downloading = WebBrowserWindow.networkManager().get(
+        reply = WebBrowserWindow.networkManager().get(
             QNetworkRequest(self.location()))
-        self.__downloading.finished.connect(
-            lambda: self.__rulesDownloaded(self.__downloading))
+        reply.finished.connect(
+            lambda: self.__rulesDownloaded(reply))
+        self.__downloading = reply
     
     def __rulesDownloaded(self, reply):
         """

eric ide

mercurial