Check-in [ef2604c3a4]
Overview
| Comment: | Support json= POST requests. |
|---|---|
| Downloads: | Tarball | ZIP archive | SQL archive |
| Timelines: | family | ancestors | descendants | both | trunk |
| Files: | files | file ages | folders |
| SHA1: |
ef2604c3a49a9e62ce995c625468b59c |
| User & Date: | mario on 2017-02-26 21:42:23 |
| Other Links: | manifest | tags |
Context
|
2017-02-26
| ||
| 21:43 | Enable search with post/json=1 and seperating token from other params{} check-in: 85f1271d4d user: mario tags: trunk | |
| 21:42 | Support json= POST requests. check-in: ef2604c3a4 user: mario tags: trunk | |
|
2017-02-25
| ||
| 00:06 | Add dirble search (but keep disabled: error "504 not allowed"). Reintroduce pagination (slower, but with progress bar now). Add "Popular" and "Recent" categories. Reenable thumbnail fetching rather than plain favicons. check-in: b042a5112f user: mario tags: trunk | |
Changes
Modified ahttp.py from [c85e234893] to [08b50af3db].
| ︙ | ︙ | |||
48 49 50 51 52 53 54 |
except: pass
# prepare default query object
session = requests.Session()
# default HTTP headers for requests
session.headers.update({
| | | | | > > > | | 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 |
except: pass
# prepare default query object
session = requests.Session()
# default HTTP headers for requests
session.headers.update({
"User-Agent": "streamtuner2/2.2 (X11; Linux amd64; rv:52.0) like WinAmp/2.1",
"Accept": "*/*",
"Accept-Language": "en-US,en,de,es,fr,it,*;q=0.1",
"Accept-Encoding": "gzip, deflate",
"Accept-Charset": "UTF-8, ISO-8859-1;q=0.5, *;q=0.1",
})
#-- Retrieve data via HTTP
#
# Well, it says "get", but it actually does POST and AJAXish GET requests too.
#
def get(
url, params={}, referer=None, post=0, ajax=0, json=0,
binary=0, content=True, encoding=None, verify=False,
statusmsg=None, timeout=9.25, quieter=0, add_headers={}
):
# statusbar info
if not quieter:
progress_feedback(url, timeout=timeout/1.5)
# combine headers
headers = {}.update(add_headers)
if ajax:
headers["X-Requested-With"] = "XMLHttpRequest"
if referer:
headers["Referer"] = (referer if referer not in [True, 1] else url)
#ifdef BLD_DEBUG
#srcout raise Exception("Simulated HTTP error")
#endif
# read
if post:
log.HTTP("POST", url, params)
if json:
r = session.post(url, json=params, headers=headers, timeout=timeout)
else:
r = session.post(url, data=params, headers=headers, timeout=timeout)
else:
log.HTTP("GET"+(" AJAX" if ajax else ""), url, params )
r = session.get(url, params=params, headers=headers, verify=verify, timeout=timeout)
if not quieter:
log.HTTP(">>>", r.request.headers );
log.HTTP("<<<", r.headers );
|
| ︙ | ︙ |