@@ -79,43 +79,6 @@ def get_rss_update_type(update: dict) -> RSSUpdateType:
7979 return RSSUpdateType .RSS_CORRECTION
8080 else :
8181 return RSSUpdateType .RSS_UNKNOWN
82-
83- @staticmethod
84- def en_page_exists (url : str ) -> bool :
85- """
86- Converts a branch URL into an EN URL of the same page and checks if it exists on EN
87- """
88- try :
89- parsed_url = parse .urlparse (url )
90- except ValueError :
91- error (f'Cannot parse URL "{ url } "' )
92- return False
93- parsed_url = parsed_url ._replace (scheme = 'https' )._replace (netloc = 'scp-wiki.wikidot.com' )
94- wl_parsed_url = parsed_url ._replace (scheme = 'https' )._replace (netloc = 'wanderers-library.wikidot.com' )
95- en_url = parse .urlunparse (parsed_url )
96- wl_url = parse .urlunparse (wl_parsed_url )
97- try :
98- head_result = requests .head (en_url , headers = {'User-Agent' : USER_AGENT })
99- except requests .RequestException as e :
100- error (f'Request to { en_url } failed ({ str (e )} )' )
101- return False
102- #TODO: Refactor this
103- match head_result .status_code :
104- case 200 :
105- return True
106- case 404 :
107- head_result = requests .head (wl_url , headers = {'User-Agent' : USER_AGENT })
108- match head_result .status_code :
109- case 200 :
110- return True
111- case 404 :
112- return False
113- case _:
114- warning (f'Got unusual status code ({ head_result .status_code } ) for URL { en_url } ' )
115- return False
116- case _:
117- warning (f'Got unusual status code ({ head_result .status_code } ) for URL { en_url } ' )
118- return False
11982
12083 def get_rss_update_author (self , update : dict ) -> Optional [User ]:
12184 update_description = update ['description' ]
@@ -146,17 +109,11 @@ def _process_new_page(self, update) -> bool:
146109 info ('Ignoring {title} in RSS feed (couldn\' t match wikidot username {author} to a user)' )
147110 return False
148111 debug (f'Check { title } with ts { timestamp } , last db update was { self .__dbs .lastupdated } ' )
149- #if title.lower().endswith(IGNORE_BRANCH_TAG):
150- # info(f'Ignoring {title} in RSS feed (not a translation)')
151- # return False
152112
153113 if timestamp + TIMEZONE_UTC_OFFSET > self .__dbs .lastupdated :
154114 if self .__dbs .get_article_by_link (update ['link' ]):
155115 info (f'Ignoring { title } in RSS feed (added manually)' )
156116 return False
157- #if not RSSMonitor.en_page_exists(update['link']):
158- # info(f'Ignoring {title} in RSS feed (EN Wiki page doesn\'t exist)')
159- # return False
160117 self .__updates .append (RSSUpdate (timestamp + TIMEZONE_UTC_OFFSET , update ['link' ], title , author , uuid4 (), RSSUpdateType .RSS_NEWPAGE ))
161118 return True
162119 return False
@@ -172,7 +129,6 @@ def _process_correction(self, update) -> bool:
172129 translation = self .__dbs .get_article_by_link (update ['link' ])
173130 if not translation :
174131 self .__updates .append (RSSUpdate (timestamp + TIMEZONE_UTC_OFFSET , update ['link' ], real_title , author , uuid4 (), RSSUpdateType .RSS_CORRECTION ))
175- #self.__webhook.send_text(f'Korekci od {author.nickname} pro {real_title} nelze přiřadit k článku. Zapište manuálně.')
176132 warning (f"Correction for { real_title } by { author .nickname } cannot be assigned to an article" )
177133 else :
178134 self .__dbs .assign_corrector (translation , author )
@@ -194,8 +150,6 @@ def _process_update(self, update) -> bool:
194150 case RSSUpdateType .RSS_CORRECTION :
195151 self ._process_correction (update )
196152
197-
198-
199153 return False
200154
201155 def check (self ):
0 commit comments