1
0
mirror of https://github.com/HorlogeSkynet/CDNUpdates synced 2025-02-26 16:00:45 +01:00
CDNUpdates/CDNCheckForCDNProviders.py
Samuel FORESTIER 9a52f9b468 Refactors the code (separates main methods into classes)
+ Implements `CheckForUpdates` as another thread !
2017-12-27 12:24:45 -05:00

30 lines
956 B
Python

from urllib.parse import urlparse
from CDNUpdates.CDNContent import CDNContent, CDNPROVIDERS
class CheckForCDNProviders():
def __init__(self, view, cdnContentList, regionList):
self.view = view
self.cdnContentList = cdnContentList
self.regionList = regionList
"""
Simple method to filter out the regions containing a link not handled.
"""
for region in self.regionList:
# We parse the URL taken from that region...
parsedResult = urlparse(
self.view.substr(region)
)
# ... to check if it's a known CDN provider
if parsedResult.netloc in CDNPROVIDERS:
# If this matches, we store it and move on to the next element.
self.cdnContentList.append(CDNContent(region, parsedResult))
# If not, we'll just ignore this region in the future
else:
pass