|
27 | 27 | import io |
28 | 28 | import re |
29 | 29 | import sys |
| 30 | +import platform |
30 | 31 | import socket |
31 | 32 | import shutil |
32 | 33 | import time |
@@ -317,16 +318,67 @@ def unquote(x): # very small fallback |
317 | 318 | except NameError: |
318 | 319 | basestring = str |
319 | 320 |
|
320 | | -# Module metadata |
| 321 | +# --- Configuration --- |
| 322 | +__use_pysftp__ = False |
| 323 | +if(not havepysftp): |
| 324 | + __use_pysftp__ = False |
| 325 | +__use_http_lib__ = "httpx" |
| 326 | +if(__use_http_lib__ == "httpx" and haverequests and not havehttpx): |
| 327 | + __use_http_lib__ = "requests" |
| 328 | +if(__use_http_lib__ == "requests" and havehttpx and not haverequests): |
| 329 | + __use_http_lib__ = "httpx" |
| 330 | +if((__use_http_lib__ == "httpx" or __use_http_lib__ == "requests") and not havehttpx and not haverequests): |
| 331 | + __use_http_lib__ = "urllib" |
| 332 | + |
321 | 333 | __program_name__ = "PyWWW-Get" |
| 334 | +__program_alt_name__ = "PyWWWGet" |
| 335 | +__program_small_name__ = "wwwget" |
322 | 336 | __project__ = __program_name__ |
323 | 337 | __project_url__ = "https://github.com/GameMaker2k/PyWWW-Get" |
324 | | -__version__ = "optimized-v1.0" |
325 | | -__author__ = "Optimized Version" |
326 | | -__license__ = "MIT" |
327 | | - |
328 | | -__use_http_lib__ = "httpx" if havehttpx else ("requests" if haverequests else "urllib") |
329 | | -__use_pysftp__ = False # can toggle |
| 338 | +__version_info__ = (2, 1, 6, "RC 1", 1) |
| 339 | +__version_date_info__ = (2025, 8, 14, "RC 1", 1) |
| 340 | +__version_date__ = str(__version_date_info__[0])+"."+str(__version_date_info__[ |
| 341 | + 1]).zfill(2)+"."+str(__version_date_info__[2]).zfill(2) |
| 342 | +__revision__ = __version_info__[3] |
| 343 | +__revision_id__ = "$Id$" |
| 344 | +if(__version_info__[4] is not None): |
| 345 | + __version_date_plusrc__ = __version_date__ + \ |
| 346 | + "-"+str(__version_date_info__[4]) |
| 347 | +if(__version_info__[4] is None): |
| 348 | + __version_date_plusrc__ = __version_date__ |
| 349 | +if(__version_info__[3] is not None): |
| 350 | + __version__ = str(__version_info__[0])+"."+str(__version_info__[1])+"."+str( |
| 351 | + __version_info__[2])+" "+str(__version_info__[3]) |
| 352 | +if(__version_info__[3] is None): |
| 353 | + __version__ = str( |
| 354 | + __version_info__[0])+"."+str(__version_info__[1])+"."+str(__version_info__[2]) |
| 355 | + |
| 356 | +PyBitness = platform.architecture() |
| 357 | +if(PyBitness == "32bit" or PyBitness == "32"): |
| 358 | + PyBitness = "32" |
| 359 | +elif(PyBitness == "64bit" or PyBitness == "64"): |
| 360 | + PyBitness = "64" |
| 361 | +else: |
| 362 | + PyBitness = "32" |
| 363 | + |
| 364 | +geturls_ua_pywwwget_python = "Mozilla/5.0 (compatible; {proname}/{prover}; +{prourl})".format( |
| 365 | + proname=__project__, prover=__version__, prourl=__project_url__) |
| 366 | +if(platform.python_implementation() != ""): |
| 367 | + py_implementation = platform.python_implementation() |
| 368 | +if(platform.python_implementation() == ""): |
| 369 | + py_implementation = "Python" |
| 370 | +geturls_ua_pywwwget_python_alt = "Mozilla/5.0 ({osver}; {archtype}; +{prourl}) {pyimp}/{pyver} (KHTML, like Gecko) {proname}/{prover}".format(osver=platform.system( |
| 371 | +)+" "+platform.release(), archtype=platform.machine(), prourl=__project_url__, pyimp=py_implementation, pyver=platform.python_version(), proname=__project__, prover=__version__) |
| 372 | +geturls_ua_googlebot_google = "Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)" |
| 373 | +geturls_ua_googlebot_google_old = "Googlebot/2.1 (+http://www.google.com/bot.html)" |
| 374 | +geturls_headers_pywwwget_python = {'Referer': "http://google.com/", 'User-Agent': geturls_ua_pywwwget_python, 'Accept-Encoding': "none", 'Accept-Language': "en-US,en;q=0.8,en-CA,en-GB;q=0.6", 'Accept-Charset': "ISO-8859-1,ISO-8859-15,utf-8;q=0.7,*;q=0.7", 'Accept': "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8", 'Connection': "close", |
| 375 | + 'SEC-CH-UA': "\""+__project__+"\";v=\""+str(__version__)+"\", \"Not;A=Brand\";v=\"8\", \""+py_implementation+"\";v=\""+str(platform.release())+"\"", 'SEC-CH-UA-FULL-VERSION': str(__version__), 'SEC-CH-UA-PLATFORM': ""+py_implementation+"", 'SEC-CH-UA-ARCH': ""+platform.machine()+"", 'SEC-CH-UA-PLATFORM-VERSION': str(__version__), 'SEC-CH-UA-BITNESS': str(PyBitness)} |
| 376 | +geturls_headers_pywwwget_python_alt = {'Referer': "http://google.com/", 'User-Agent': geturls_ua_pywwwget_python_alt, 'Accept-Encoding': "none", 'Accept-Language': "en-US,en;q=0.8,en-CA,en-GB;q=0.6", 'Accept-Charset': "ISO-8859-1,ISO-8859-15,utf-8;q=0.7,*;q=0.7", 'Accept': "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8", 'Connection': "close", |
| 377 | + 'SEC-CH-UA': "\""+__project__+"\";v=\""+str(__version__)+"\", \"Not;A=Brand\";v=\"8\", \""+py_implementation+"\";v=\""+str(platform.release())+"\"", 'SEC-CH-UA-FULL-VERSION': str(__version__), 'SEC-CH-UA-PLATFORM': ""+py_implementation+"", 'SEC-CH-UA-ARCH': ""+platform.machine()+"", 'SEC-CH-UA-PLATFORM-VERSION': str(__version__), 'SEC-CH-UA-BITNESS': str(PyBitness)} |
| 378 | +geturls_headers_googlebot_google = {'Referer': "http://google.com/", 'User-Agent': geturls_ua_googlebot_google, 'Accept-Encoding': "none", 'Accept-Language': "en-US,en;q=0.8,en-CA,en-GB;q=0.6", |
| 379 | + 'Accept-Charset': "ISO-8859-1,ISO-8859-15,utf-8;q=0.7,*;q=0.7", 'Accept': "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8", 'Connection': "close"} |
| 380 | +geturls_headers_googlebot_google_old = {'Referer': "http://google.com/", 'User-Agent': geturls_ua_googlebot_google_old, 'Accept-Encoding': "none", 'Accept-Language': "en-US,en;q=0.8,en-CA,en-GB;q=0.6", |
| 381 | + 'Accept-Charset': "ISO-8859-1,ISO-8859-15,utf-8;q=0.7,*;q=0.7", 'Accept': "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8", 'Connection': "close"} |
330 | 382 |
|
331 | 383 | __use_inmem__ = True |
332 | 384 | __use_memfd__ = True |
|
0 commit comments