Basic functionality implemented
This commit is contained in:
51
downloader/Scripts/Activate.ps1
Normal file
51
downloader/Scripts/Activate.ps1
Normal file
@@ -0,0 +1,51 @@
|
||||
function global:deactivate ([switch]$NonDestructive) {
|
||||
# Revert to original values
|
||||
if (Test-Path function:_OLD_VIRTUAL_PROMPT) {
|
||||
copy-item function:_OLD_VIRTUAL_PROMPT function:prompt
|
||||
remove-item function:_OLD_VIRTUAL_PROMPT
|
||||
}
|
||||
|
||||
if (Test-Path env:_OLD_VIRTUAL_PYTHONHOME) {
|
||||
copy-item env:_OLD_VIRTUAL_PYTHONHOME env:PYTHONHOME
|
||||
remove-item env:_OLD_VIRTUAL_PYTHONHOME
|
||||
}
|
||||
|
||||
if (Test-Path env:_OLD_VIRTUAL_PATH) {
|
||||
copy-item env:_OLD_VIRTUAL_PATH env:PATH
|
||||
remove-item env:_OLD_VIRTUAL_PATH
|
||||
}
|
||||
|
||||
if (Test-Path env:VIRTUAL_ENV) {
|
||||
remove-item env:VIRTUAL_ENV
|
||||
}
|
||||
|
||||
if (!$NonDestructive) {
|
||||
# Self destruct!
|
||||
remove-item function:deactivate
|
||||
}
|
||||
}
|
||||
|
||||
deactivate -nondestructive
|
||||
|
||||
$env:VIRTUAL_ENV="C:\Users\Shaq992\Documents\VSCode projects\iOS-Websockets-jDownloader\downloader"
|
||||
|
||||
if (! $env:VIRTUAL_ENV_DISABLE_PROMPT) {
|
||||
# Set the prompt to include the env name
|
||||
# Make sure _OLD_VIRTUAL_PROMPT is global
|
||||
function global:_OLD_VIRTUAL_PROMPT {""}
|
||||
copy-item function:prompt function:_OLD_VIRTUAL_PROMPT
|
||||
function global:prompt {
|
||||
Write-Host -NoNewline -ForegroundColor Green '(downloader) '
|
||||
_OLD_VIRTUAL_PROMPT
|
||||
}
|
||||
}
|
||||
|
||||
# Clear PYTHONHOME
|
||||
if (Test-Path env:PYTHONHOME) {
|
||||
copy-item env:PYTHONHOME env:_OLD_VIRTUAL_PYTHONHOME
|
||||
remove-item env:PYTHONHOME
|
||||
}
|
||||
|
||||
# Add the venv to the PATH
|
||||
copy-item env:PATH env:_OLD_VIRTUAL_PATH
|
||||
$env:PATH = "$env:VIRTUAL_ENV\Scripts;$env:PATH"
|
76
downloader/Scripts/activate
Normal file
76
downloader/Scripts/activate
Normal file
@@ -0,0 +1,76 @@
|
||||
# This file must be used with "source bin/activate" *from bash*
|
||||
# you cannot run it directly
|
||||
|
||||
deactivate () {
|
||||
# reset old environment variables
|
||||
if [ -n "${_OLD_VIRTUAL_PATH:-}" ] ; then
|
||||
PATH="${_OLD_VIRTUAL_PATH:-}"
|
||||
export PATH
|
||||
unset _OLD_VIRTUAL_PATH
|
||||
fi
|
||||
if [ -n "${_OLD_VIRTUAL_PYTHONHOME:-}" ] ; then
|
||||
PYTHONHOME="${_OLD_VIRTUAL_PYTHONHOME:-}"
|
||||
export PYTHONHOME
|
||||
unset _OLD_VIRTUAL_PYTHONHOME
|
||||
fi
|
||||
|
||||
# This should detect bash and zsh, which have a hash command that must
|
||||
# be called to get it to forget past commands. Without forgetting
|
||||
# past commands the $PATH changes we made may not be respected
|
||||
if [ -n "${BASH:-}" -o -n "${ZSH_VERSION:-}" ] ; then
|
||||
hash -r
|
||||
fi
|
||||
|
||||
if [ -n "${_OLD_VIRTUAL_PS1:-}" ] ; then
|
||||
PS1="${_OLD_VIRTUAL_PS1:-}"
|
||||
export PS1
|
||||
unset _OLD_VIRTUAL_PS1
|
||||
fi
|
||||
|
||||
unset VIRTUAL_ENV
|
||||
if [ ! "${1:-}" = "nondestructive" ] ; then
|
||||
# Self destruct!
|
||||
unset -f deactivate
|
||||
fi
|
||||
}
|
||||
|
||||
# unset irrelevant variables
|
||||
deactivate nondestructive
|
||||
|
||||
VIRTUAL_ENV="C:\Users\Shaq992\Documents\VSCode projects\iOS-Websockets-jDownloader\downloader"
|
||||
export VIRTUAL_ENV
|
||||
|
||||
_OLD_VIRTUAL_PATH="$PATH"
|
||||
PATH="$VIRTUAL_ENV/Scripts:$PATH"
|
||||
export PATH
|
||||
|
||||
# unset PYTHONHOME if set
|
||||
# this will fail if PYTHONHOME is set to the empty string (which is bad anyway)
|
||||
# could use `if (set -u; : $PYTHONHOME) ;` in bash
|
||||
if [ -n "${PYTHONHOME:-}" ] ; then
|
||||
_OLD_VIRTUAL_PYTHONHOME="${PYTHONHOME:-}"
|
||||
unset PYTHONHOME
|
||||
fi
|
||||
|
||||
if [ -z "${VIRTUAL_ENV_DISABLE_PROMPT:-}" ] ; then
|
||||
_OLD_VIRTUAL_PS1="${PS1:-}"
|
||||
if [ "x(downloader) " != x ] ; then
|
||||
PS1="(downloader) ${PS1:-}"
|
||||
else
|
||||
if [ "`basename \"$VIRTUAL_ENV\"`" = "__" ] ; then
|
||||
# special case for Aspen magic directories
|
||||
# see http://www.zetadev.com/software/aspen/
|
||||
PS1="[`basename \`dirname \"$VIRTUAL_ENV\"\``] $PS1"
|
||||
else
|
||||
PS1="(`basename \"$VIRTUAL_ENV\"`)$PS1"
|
||||
fi
|
||||
fi
|
||||
export PS1
|
||||
fi
|
||||
|
||||
# This should detect bash and zsh, which have a hash command that must
|
||||
# be called to get it to forget past commands. Without forgetting
|
||||
# past commands the $PATH changes we made may not be respected
|
||||
if [ -n "${BASH:-}" -o -n "${ZSH_VERSION:-}" ] ; then
|
||||
hash -r
|
||||
fi
|
33
downloader/Scripts/activate.bat
Normal file
33
downloader/Scripts/activate.bat
Normal file
@@ -0,0 +1,33 @@
|
||||
@echo off
|
||||
|
||||
rem This file is UTF-8 encoded, so we need to update the current code page while executing it
|
||||
for /f "tokens=2 delims=:." %%a in ('"%SystemRoot%\System32\chcp.com"') do (
|
||||
set _OLD_CODEPAGE=%%a
|
||||
)
|
||||
if defined _OLD_CODEPAGE (
|
||||
"%SystemRoot%\System32\chcp.com" 65001 > nul
|
||||
)
|
||||
|
||||
set VIRTUAL_ENV=C:\Users\Shaq992\Documents\VSCode projects\iOS-Websockets-jDownloader\downloader
|
||||
|
||||
if not defined PROMPT set PROMPT=$P$G
|
||||
|
||||
if defined _OLD_VIRTUAL_PROMPT set PROMPT=%_OLD_VIRTUAL_PROMPT%
|
||||
if defined _OLD_VIRTUAL_PYTHONHOME set PYTHONHOME=%_OLD_VIRTUAL_PYTHONHOME%
|
||||
|
||||
set _OLD_VIRTUAL_PROMPT=%PROMPT%
|
||||
set PROMPT=(downloader) %PROMPT%
|
||||
|
||||
if defined PYTHONHOME set _OLD_VIRTUAL_PYTHONHOME=%PYTHONHOME%
|
||||
set PYTHONHOME=
|
||||
|
||||
if defined _OLD_VIRTUAL_PATH set PATH=%_OLD_VIRTUAL_PATH%
|
||||
if not defined _OLD_VIRTUAL_PATH set _OLD_VIRTUAL_PATH=%PATH%
|
||||
|
||||
set PATH=%VIRTUAL_ENV%\Scripts;%PATH%
|
||||
|
||||
:END
|
||||
if defined _OLD_CODEPAGE (
|
||||
"%SystemRoot%\System32\chcp.com" %_OLD_CODEPAGE% > nul
|
||||
set _OLD_CODEPAGE=
|
||||
)
|
BIN
downloader/Scripts/chardetect.exe
Normal file
BIN
downloader/Scripts/chardetect.exe
Normal file
Binary file not shown.
21
downloader/Scripts/deactivate.bat
Normal file
21
downloader/Scripts/deactivate.bat
Normal file
@@ -0,0 +1,21 @@
|
||||
@echo off
|
||||
|
||||
if defined _OLD_VIRTUAL_PROMPT (
|
||||
set "PROMPT=%_OLD_VIRTUAL_PROMPT%"
|
||||
)
|
||||
set _OLD_VIRTUAL_PROMPT=
|
||||
|
||||
if defined _OLD_VIRTUAL_PYTHONHOME (
|
||||
set "PYTHONHOME=%_OLD_VIRTUAL_PYTHONHOME%"
|
||||
set _OLD_VIRTUAL_PYTHONHOME=
|
||||
)
|
||||
|
||||
if defined _OLD_VIRTUAL_PATH (
|
||||
set "PATH=%_OLD_VIRTUAL_PATH%"
|
||||
)
|
||||
|
||||
set _OLD_VIRTUAL_PATH=
|
||||
|
||||
set VIRTUAL_ENV=
|
||||
|
||||
:END
|
BIN
downloader/Scripts/easy_install-3.7.exe
Normal file
BIN
downloader/Scripts/easy_install-3.7.exe
Normal file
Binary file not shown.
BIN
downloader/Scripts/easy_install.exe
Normal file
BIN
downloader/Scripts/easy_install.exe
Normal file
Binary file not shown.
BIN
downloader/Scripts/flask.exe
Normal file
BIN
downloader/Scripts/flask.exe
Normal file
Binary file not shown.
BIN
downloader/Scripts/pip.exe
Normal file
BIN
downloader/Scripts/pip.exe
Normal file
Binary file not shown.
BIN
downloader/Scripts/pip3.7.exe
Normal file
BIN
downloader/Scripts/pip3.7.exe
Normal file
Binary file not shown.
BIN
downloader/Scripts/pip3.exe
Normal file
BIN
downloader/Scripts/pip3.exe
Normal file
Binary file not shown.
BIN
downloader/Scripts/python.exe
Normal file
BIN
downloader/Scripts/python.exe
Normal file
Binary file not shown.
BIN
downloader/Scripts/pythonw.exe
Normal file
BIN
downloader/Scripts/pythonw.exe
Normal file
Binary file not shown.
217
downloader/Scripts/wsdump.py
Normal file
217
downloader/Scripts/wsdump.py
Normal file
@@ -0,0 +1,217 @@
|
||||
#!c:\users\shaq992\documents\vscode projects\ios-websockets-jdownloader\downloader\scripts\python.exe
|
||||
|
||||
import argparse
|
||||
import code
|
||||
import sys
|
||||
import threading
|
||||
import time
|
||||
import ssl
|
||||
import gzip
|
||||
import zlib
|
||||
|
||||
import six
|
||||
from six.moves.urllib.parse import urlparse
|
||||
|
||||
import websocket
|
||||
|
||||
try:
|
||||
import readline
|
||||
except ImportError:
|
||||
pass
|
||||
|
||||
|
||||
def get_encoding():
|
||||
encoding = getattr(sys.stdin, "encoding", "")
|
||||
if not encoding:
|
||||
return "utf-8"
|
||||
else:
|
||||
return encoding.lower()
|
||||
|
||||
|
||||
OPCODE_DATA = (websocket.ABNF.OPCODE_TEXT, websocket.ABNF.OPCODE_BINARY)
|
||||
ENCODING = get_encoding()
|
||||
|
||||
|
||||
class VAction(argparse.Action):
|
||||
|
||||
def __call__(self, parser, args, values, option_string=None):
|
||||
if values is None:
|
||||
values = "1"
|
||||
try:
|
||||
values = int(values)
|
||||
except ValueError:
|
||||
values = values.count("v") + 1
|
||||
setattr(args, self.dest, values)
|
||||
|
||||
|
||||
def parse_args():
|
||||
parser = argparse.ArgumentParser(description="WebSocket Simple Dump Tool")
|
||||
parser.add_argument("url", metavar="ws_url",
|
||||
help="websocket url. ex. ws://echo.websocket.org/")
|
||||
parser.add_argument("-p", "--proxy",
|
||||
help="proxy url. ex. http://127.0.0.1:8080")
|
||||
parser.add_argument("-v", "--verbose", default=0, nargs='?', action=VAction,
|
||||
dest="verbose",
|
||||
help="set verbose mode. If set to 1, show opcode. "
|
||||
"If set to 2, enable to trace websocket module")
|
||||
parser.add_argument("-n", "--nocert", action='store_true',
|
||||
help="Ignore invalid SSL cert")
|
||||
parser.add_argument("-r", "--raw", action="store_true",
|
||||
help="raw output")
|
||||
parser.add_argument("-s", "--subprotocols", nargs='*',
|
||||
help="Set subprotocols")
|
||||
parser.add_argument("-o", "--origin",
|
||||
help="Set origin")
|
||||
parser.add_argument("--eof-wait", default=0, type=int,
|
||||
help="wait time(second) after 'EOF' received.")
|
||||
parser.add_argument("-t", "--text",
|
||||
help="Send initial text")
|
||||
parser.add_argument("--timings", action="store_true",
|
||||
help="Print timings in seconds")
|
||||
parser.add_argument("--headers",
|
||||
help="Set custom headers. Use ',' as separator")
|
||||
|
||||
return parser.parse_args()
|
||||
|
||||
|
||||
class RawInput:
|
||||
|
||||
def raw_input(self, prompt):
|
||||
if six.PY3:
|
||||
line = input(prompt)
|
||||
else:
|
||||
line = raw_input(prompt)
|
||||
|
||||
if ENCODING and ENCODING != "utf-8" and not isinstance(line, six.text_type):
|
||||
line = line.decode(ENCODING).encode("utf-8")
|
||||
elif isinstance(line, six.text_type):
|
||||
line = line.encode("utf-8")
|
||||
|
||||
return line
|
||||
|
||||
|
||||
class InteractiveConsole(RawInput, code.InteractiveConsole):
|
||||
|
||||
def write(self, data):
|
||||
sys.stdout.write("\033[2K\033[E")
|
||||
# sys.stdout.write("\n")
|
||||
sys.stdout.write("\033[34m< " + data + "\033[39m")
|
||||
sys.stdout.write("\n> ")
|
||||
sys.stdout.flush()
|
||||
|
||||
def read(self):
|
||||
return self.raw_input("> ")
|
||||
|
||||
|
||||
class NonInteractive(RawInput):
|
||||
|
||||
def write(self, data):
|
||||
sys.stdout.write(data)
|
||||
sys.stdout.write("\n")
|
||||
sys.stdout.flush()
|
||||
|
||||
def read(self):
|
||||
return self.raw_input("")
|
||||
|
||||
|
||||
def main():
|
||||
start_time = time.time()
|
||||
args = parse_args()
|
||||
if args.verbose > 1:
|
||||
websocket.enableTrace(True)
|
||||
options = {}
|
||||
if args.proxy:
|
||||
p = urlparse(args.proxy)
|
||||
options["http_proxy_host"] = p.hostname
|
||||
options["http_proxy_port"] = p.port
|
||||
if args.origin:
|
||||
options["origin"] = args.origin
|
||||
if args.subprotocols:
|
||||
options["subprotocols"] = args.subprotocols
|
||||
opts = {}
|
||||
if args.nocert:
|
||||
opts = {"cert_reqs": ssl.CERT_NONE, "check_hostname": False}
|
||||
if args.headers:
|
||||
options['header'] = list(map(str.strip, args.headers.split(',')))
|
||||
ws = websocket.create_connection(args.url, sslopt=opts, **options)
|
||||
if args.raw:
|
||||
console = NonInteractive()
|
||||
else:
|
||||
console = InteractiveConsole()
|
||||
print("Press Ctrl+C to quit")
|
||||
|
||||
def recv():
|
||||
try:
|
||||
frame = ws.recv_frame()
|
||||
except websocket.WebSocketException:
|
||||
return websocket.ABNF.OPCODE_CLOSE, None
|
||||
if not frame:
|
||||
raise websocket.WebSocketException("Not a valid frame %s" % frame)
|
||||
elif frame.opcode in OPCODE_DATA:
|
||||
return frame.opcode, frame.data
|
||||
elif frame.opcode == websocket.ABNF.OPCODE_CLOSE:
|
||||
ws.send_close()
|
||||
return frame.opcode, None
|
||||
elif frame.opcode == websocket.ABNF.OPCODE_PING:
|
||||
ws.pong(frame.data)
|
||||
return frame.opcode, frame.data
|
||||
|
||||
return frame.opcode, frame.data
|
||||
|
||||
def recv_ws():
|
||||
while True:
|
||||
opcode, data = recv()
|
||||
msg = None
|
||||
if six.PY3 and opcode == websocket.ABNF.OPCODE_TEXT and isinstance(data, bytes):
|
||||
data = str(data, "utf-8")
|
||||
if isinstance(data, bytes) and len(data)>2 and data[:2] == b'\037\213': # gzip magick
|
||||
try:
|
||||
data = "[gzip] " + str(gzip.decompress(data), "utf-8")
|
||||
except:
|
||||
pass
|
||||
elif isinstance(data, bytes):
|
||||
try:
|
||||
data = "[zlib] " + str(zlib.decompress(data, -zlib.MAX_WBITS), "utf-8")
|
||||
except:
|
||||
pass
|
||||
|
||||
if isinstance(data, bytes):
|
||||
data = repr(data)
|
||||
|
||||
if args.verbose:
|
||||
msg = "%s: %s" % (websocket.ABNF.OPCODE_MAP.get(opcode), data)
|
||||
else:
|
||||
msg = data
|
||||
|
||||
if msg is not None:
|
||||
if args.timings:
|
||||
console.write(str(time.time() - start_time) + ": " + msg)
|
||||
else:
|
||||
console.write(msg)
|
||||
|
||||
if opcode == websocket.ABNF.OPCODE_CLOSE:
|
||||
break
|
||||
|
||||
thread = threading.Thread(target=recv_ws)
|
||||
thread.daemon = True
|
||||
thread.start()
|
||||
|
||||
if args.text:
|
||||
ws.send(args.text)
|
||||
|
||||
while True:
|
||||
try:
|
||||
message = console.read()
|
||||
ws.send(message)
|
||||
except KeyboardInterrupt:
|
||||
return
|
||||
except EOFError:
|
||||
time.sleep(args.eof_wait)
|
||||
return
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
try:
|
||||
main()
|
||||
except Exception as e:
|
||||
print(e)
|
3
downloader/pyvenv.cfg
Normal file
3
downloader/pyvenv.cfg
Normal file
@@ -0,0 +1,3 @@
|
||||
home = C:\Users\Shaq992\AppData\Local\Programs\Python\Python37
|
||||
include-system-site-packages = false
|
||||
version = 3.7.9
|
Reference in New Issue
Block a user