File tree 1 file changed +11
-5
lines changed
1 file changed +11
-5
lines changed Original file line number Diff line number Diff line change 13
13
from selenium .common .exceptions import NoSuchElementException
14
14
from bs4 import BeautifulSoup
15
15
from datetime import datetime
16
+ import re
16
17
17
18
18
19
class GetSource :
@@ -184,14 +185,19 @@ async def visitPage(self, channelItems):
184
185
reverse = True ,
185
186
) # Sort by date
186
187
infoList = await self .compareSpeed (infoList ) # Sort by speed
188
+
189
+ def extract_resolution (resolution_str ):
190
+ numbers = re .findall (r"\d+x\d+" , resolution_str )
191
+ if numbers :
192
+ width , height = map (int , numbers [0 ].split ("x" ))
193
+ return width * height
194
+ else :
195
+ return 0
196
+
187
197
infoList .sort (
188
198
key = lambda x : (
189
199
x [2 ] is not None ,
190
- (
191
- int (x [2 ].split ("x" )[0 ]) * int (x [2 ].split ("x" )[1 ])
192
- if x [2 ]
193
- else 0
194
- ),
200
+ extract_resolution (x [2 ]) if x [2 ] else 0 ,
195
201
),
196
202
reverse = True ,
197
203
) # Sort by resolution
You can’t perform that action at this time.
0 commit comments