Coder Social home page Coder Social logo

mansuf / zippyshare-downloader Goto Github PK

View Code? Open in Web Editor NEW
57.0 3.0 15.0 127 KB

Download file from zippyshare directly with python

Home Page: https://zippyshare-downloader.readthedocs.io

License: MIT License

Python 100.00%
python zippyshare downloader cli

zippyshare-downloader's Introduction

pypi-total-downloads python-ver pypi-release-ver

zippyshare-downloader

Download file from zippyshare directly from python

Table of Contents

Key Features

In zippyshare-downloader you can:

  • download file from Zippyshare (Yes of course).
  • Extract filename, date uploaded, file size, and downloadable url information from given url.
  • Fast Download, allows you to download in 2 connections at same time simultaneously.

Minimum Python version

3.5.x

Installation

Python Packages Index (PyPI)

pip install zippyshare-downloader

From the source

Clone the repository

git clone https://github.com/mansuf/zippyshare-downloader.git
cd zippyshare-downloader

And then run setup.py

python setup.py install

NOTE: If you think zippyshare-downloader are already downloaded with latest version, but the app doesn't seems work properly (like this case #11). You can reinstall zippyshare-downloader by following this command:

# For Windows
py -3 -m pip cache purge zippyshare_downloader
py -3 -m pip uninstall zippyshare-downloader
py -3 -m pip install -U zippyshare-downloader

# For Linux / Mac OS
python3 -m pip cache purge zippyshare_downloader
python3 -m pip uninstall zippyshare-downloader
python3 -m pip install -U zippyshare-downloader

If still doesn't work properly that means Zippyshare change their code, you can open issue here

Simple Usage

Command Line Interface (CLI)

Read here for more informations

zippyshare-dl "insert zippyshare url here"

# or

zippyshare-downloader "insert zippyshare url here"

# Use this if `zippyshare-dl` and `zippyshare-downloader` didn't work

python -m zippyshare_downloader "insert zippyshare url here"

Embedding (API)

Use zippyshare-downloader in your python script

Read here for more informations

from zippyshare_downloader import extract_info, extract_info_coro

# by default, parameter download is True
file = extract_info('insert zippyshare url here', download=True)

print(file)

# Output: <Zippyshare File name="..." size="...">

# async version
async def get_info():
    file = await extract_info_coro('insert zippyshare url here', download=True)
    print(file)

Links

FAQ

Q: I always getting NameError: The use of "bla bla" is not allowed, what should i do ?
A: Zippyshare always change their code, Please update to last version, if your zippyshare-downloader is latest version, then open a issue here

zippyshare-downloader's People

Contributors

dependabot-preview[bot] avatar hiddn avatar mansuf avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

zippyshare-downloader's Issues

ModuleNotFoundError

Hello, as soon as I try to import the module I get an error (I'm running on python 3.10):

C:\Users\matth\OneDrive\Bureau>python test.py
Traceback (most recent call last):
  File "C:\Users\matth\OneDrive\Bureau\test.py", line 3, in <module>
    from zippyshare_downloader import *
ModuleNotFoundError: No module named 'zippyshare_downloader'
```

New 5th Pattern Solution

Hi,

I use my own personal Bash implementation of a Zippyshare downloader, recently it broke, I hate when that happens. Thanks to the debug mode's Inspector of Firefox, I figured it out, despite not being a programmer. I like your project, but my Python skills are too bad to contribute, and I hope the solution of mine will help to bring back your script too.

Short: "+ a() + b() + c() + d + 5/5" is "+ 11" in reality.

<span id="omg" class="2" style="display:none;"></span>
<script type="text/javascript">
    var a = function() {return 1};
    var b = function() {return a() + 1};
    var c = function() {return b() + 1};
    var d = document.getElementById('omg').getAttribute('class');
    if (true) { d = d*2;}
    document.getElementById('dlbutton').href = "/d/XXXXXXX/"+(981255%1000 + a() + b() + c() + d + 5/5)+"/example.txt";
    if (document.getElementById('fimage')) {
        document.getElementById('fimage').href = "/i/XXXXXXX/"+(981255%1000 + a() + b() + c() + d + 5/5)+"/example.txt";
    }
</script>

The math is, simply:
981255%1000+11=266

Python script alternate download method is not working.

I ran the following python script in Google Colab:

from zippyshare_downloader import Zippyshare

z = Zippyshare()

info1 = z.extract_info('https://www26.zippyshare.com/v/pz2tYmok/file.html', download=False)

from download import download

you can pass verbose, progress_bar, and replace arguments as well

download(info1['download_url'], 'Weeds.S05E01.Wonderful.Wonderful.1080p.DTS-HD.MA.7.1.AVC.REMUX-FraMeSToR.part01.rar')

and that's it.

And got the following output:

[INFO] Fetching URL "https://www26.zippyshare.com/v/pz2tYmok/file.html"
[INFO] Parsing info
[INFO] Getting Download URL from "https://www26.zippyshare.com/v/pz2tYmok/file.html"
Traceback (most recent call last):
File "/content/drive/MyDrive/Unrar/Weeds/Season 05/weedss05.py", line 5, in
info1 = z.extract_info('https://www26.zippyshare.com/v/pz2tYmok/file.html', download=False)
File "/usr/local/lib/python3.7/dist-packages/zippyshare_downloader/init.py", line 237, in extract_info
custom_filename=custom_filename
File "/usr/local/lib/python3.7/dist-packages/zippyshare_downloader/init.py", line 177, in _extract_info
info = self._get_info(url, r)
File "/usr/local/lib/python3.7/dist-packages/zippyshare_downloader/init.py", line 161, in _get_info
'download_url': self._get_url(u, r)
File "/usr/local/lib/python3.7/dist-packages/zippyshare_downloader/init.py", line 74, in _get_url
raise ParserError('omg attribute in download button javascript cannot be found')
zippyshare_downloader.errors.ParserError: omg attribute in download button javascript cannot be found

Script broken, ZS change?

Previously things seemed to work. Am on the latest version. Has ZS changed something, or has something broken locally I've not been aware of?

% zippyshare-dl --verbose url.txt
[INFO] Grabbing required informations in https://www61.zippyshare.com/v/op8XYTSL/file.html
[DEBUG] Establishing connection to Zippyshare.
[DEBUG] Successfully established connection to Zippyshare.
[DEBUG] Checking if file is not expired
[DEBUG] Checking if file is exist
[DEBUG] Getting Name file, size, date upload.
[DEBUG] Getting download url.
[DEBUG] pattern1 failed to get download url, ParserError: omg attribute in download button javascript cannot be found
[DEBUG] pattern2 failed to get download url, NameError: The use of 'n' is not allowed. Expression used: n + b + z - 3
[ERROR] all patterns parser failed to get required informations
NoneType: None
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.9/bin/zippyshare-dl", line 33, in <module>
    sys.exit(load_entry_point('zippyshare-downloader==0.2.0', 'console_scripts', 'zippyshare-dl')())
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/zippyshare_downloader/cli/process.py", line 110, in main
    process(**kwargs)
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/zippyshare_downloader/cli/process.py", line 39, in process
    files = download(*urls, **kwargs)
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/zippyshare_downloader/fetcher.py", line 111, in download
    info = get_info(url)
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/zippyshare_downloader/fetcher.py", line 46, in get_info
    return finalization_info(parse_info(url, r.text))
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/zippyshare_downloader/parser.py", line 52, in parse_info
    raise ParserError('all patterns parser is failed to get required informations')
zippyshare_downloader.errors.ParserError: all patterns parser is failed to get required information


The file url.txt has two URLs.

% cat url.txt
https://www61.zippyshare.com/v/op8XYTSL/file.html
https://www70.zippyshare.com/v/Vz9vh7DJ/file.html

How to get direct download url (please read this before opening duplicate issue)

I have no motivation to make this app show the download url only. Please use this hacky thing to extract the download url.

Python

from zippyshare_downloader import extract_info

file = extract_info("insert zippyshare url", download=False)
print(file.download_url)

Shell / Terminal / Command-line prompt

# For Linux / Mac OS
python3 -c "from zippyshare_downloader import extract_info; file = extract_info('insert zippyshare url here', download=False); print(file.download_url)"

# For Windows
py -3 -c "from zippyshare_downloader import extract_info; file = extract_info('insert zippyshare url here', download=False); print(file.download_url)"

Error 104

First of all I'm using PyDroid3 to run the script under "Download" folder and I'm using a VPN (the same I've used so far).
Hello, I'm using the script with the sintax "zippyshare-dl link.txt". For time everything went ok but now an error shows up: it's errno 104 connection reset by peer.
Here is the exception:
Traceback (most recent call last):
File "/data/user/0/ru.iiec.pydroid3/files/aarch64-linux-android/lib/python3.9/site-packages/urllib3/response.py", line 444, in _error_catcher
yield
File "/data/user/0/ru.iiec.pydroid3/files/aarch64-linux-android/lib/python3.9/site-packages/urllib3/response.py", line 567, in read
data = self._fp_read(amt) if not fp_closed else b""
File "/data/user/0/ru.iiec.pydroid3/files/aarch64-linux-android/lib/python3.9/site-packages/urllib3/response.py", line 533, in _fp_read
return self._fp.read(amt) if amt is not None else self._fp.read()
File "/data/user/0/ru.iiec.pydroid3/files/aarch64-linux-android/lib/python3.9/http/client.py", line 462, in read
n = self.readinto(b)
File "/data/user/0/ru.iiec.pydroid3/files/aarch64-linux-android/lib/python3.9/http/client.py", line 506, in readinto
n = self.fp.readinto(b)
File "/data/user/0/ru.iiec.pydroid3/files/aarch64-linux-android/lib/python3.9/socket.py", line 704, in readinto
return self._sock.recv_into(b)
File "/data/user/0/ru.iiec.pydroid3/files/aarch64-linux-android/lib/python3.9/ssl.py", line 1241, in recv_into
return self.read(nbytes, buffer)
File "/data/user/0/ru.iiec.pydroid3/files/aarch64-linux-android/lib/python3.9/ssl.py", line 1099, in read
return self._sslobj.read(len, buffer)
ConnectionResetError: [Errno 104] Connection reset by peer

During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/data/user/0/ru.iiec.pydroid3/files/aarch64-linux-android/bin/zippyshare-dl", line 8, in
sys.exit(main())
File "/data/user/0/ru.iiec.pydroid3/files/aarch64-linux-android/lib/python3.9/site-packages/zippyshare_downloader/cli/process.py", line 165, in main
process(**kwargs)
File "/data/user/0/ru.iiec.pydroid3/files/aarch64-linux-android/lib/python3.9/site-packages/zippyshare_downloader/cli/process.py", line 58, in process
files = download(*urls, **kwargs)
File "/data/user/0/ru.iiec.pydroid3/files/aarch64-linux-android/lib/python3.9/site-packages/zippyshare_downloader/fetcher.py", line 122, in download
file_path = file.download(**kwargs)
File "/data/user/0/ru.iiec.pydroid3/files/aarch64-linux-android/lib/python3.9/site-packages/zippyshare_downloader/file.py", line 105, in download
downloader.download()
File "/data/user/0/ru.iiec.pydroid3/files/aarch64-linux-android/lib/python3.9/site-packages/zippyshare_downloader/downloader.py", line 107, in download
chunk = resp.raw.read(chunk_size)
File "/data/user/0/ru.iiec.pydroid3/files/aarch64-linux-android/lib/python3.9/site-packages/urllib3/response.py", line 593, in read
raise IncompleteRead(self._fp_bytes_read, self.length_remaining)
File "/data/user/0/ru.iiec.pydroid3/files/aarch64-linux-android/lib/python3.9/contextlib.py", line 137, in exit
self.gen.throw(typ, value, traceback)
File "/data/user/0/ru.iiec.pydroid3/files/aarch64-linux-android/lib/python3.9/site-packages/urllib3/response.py", line 461, in _error_catcher
raise ProtocolError("Connection broken: %r" % e, e)
urllib3.exceptions.ProtocolError: ("Connection broken: ConnectionResetError(104, 'Connection reset by peer')", ConnectionResetError(104, 'Connection reset by peer'))

file_sizes: 19%|█████▌ | 100M/524M [04:41<19:49, 356kB/s]
/storage/emulated/0/Download $

After that I need to restart the script, and sometimes it works sometimes not.

Patterns parser issue (i think)

using current version, Windows 10, python 3.9. I'm guessing this is zippyshare changing implementations

[ERROR] all patterns parser failed to get required informations
NoneType: None
Traceback (most recent call last):
File "c:\python39\lib\runpy.py", line 197, in _run_module_as_main
return _run_code(code, main_globals, None,
File "c:\python39\lib\runpy.py", line 87, in run_code
exec(code, run_globals)
File "C:\dev\test\env39\Scripts\zippyshare-dl.exe_main
.py", line 7, in
File "c:\dev\test\env39\lib\site-packages\zippyshare_downloader\cli\process.py", line 165, in main
process(**kwargs)
File "c:\dev\test\env39\lib\site-packages\zippyshare_downloader\cli\process.py", line 80, in process
file = extract_info(urls, **kwargs)
File "c:\dev\test\env39\lib\site-packages\zippyshare_downloader\fetcher.py", line 155, in extract_info
info = get_info(url)
File "c:\dev\test\env39\lib\site-packages\zippyshare_downloader\fetcher.py", line 51, in get_info
return finalization_info(parse_info(url, r.text))
File "c:\dev\test\env39\lib\site-packages\zippyshare_downloader\parser.py", line 53, in parse_info
raise ParserError('all patterns parser is failed to get required informations')
zippyshare_downloader.errors.ParserError: all patterns parser is failed to get required informations

Multiple URLs simultaneously?

Does this script allow users to download from multiple zippyshare URLs simultaneously? I can't figure out how to do it

Error about SSL certificate

I try to get a direct link with your sample code

from zippyshare_downloader import extract_info

file = extract_info("https://www21.zippyshare.com/v/eG62avGB/file.html", download=False)
print(file.download_url)

but i get an error

PS C:\Users\Administrator> & C:/Users/Administrator/AppData/Local/Programs/Python/Python311/python.exe c:/Users/Administrator/Desktop/main.py
Traceback (most recent call last):
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python311\Lib\site-packages\urllib3\connectionpool.py", line 703, in urlopen
    httplib_response = self._make_request(
                       ^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python311\Lib\site-packages\urllib3\connectionpool.py", line 386, in _make_request
    self._validate_conn(conn)
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python311\Lib\site-packages\urllib3\connectionpool.py", line 1042, in _validate_conn
    conn.connect()
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python311\Lib\site-packages\urllib3\connection.py", line 414, in connect    self.sock = ssl_wrap_socket(
                ^^^^^^^^^^^^^^^^
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python311\Lib\site-packages\urllib3\util\ssl_.py", line 449, in ssl_wrap_socket
    ssl_sock = _ssl_wrap_socket_impl(
               ^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python311\Lib\site-packages\urllib3\util\ssl_.py", line 493, in _ssl_wrap_socket_impl
    return ssl_context.wrap_socket(sock, server_hostname=server_hostname)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python311\Lib\ssl.py", line 517, in wrap_socket
    return self.sslsocket_class._create(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python311\Lib\ssl.py", line 1075, in _create
    self.do_handshake()
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python311\Lib\ssl.py", line 1346, in do_handshake
    self._sslobj.do_handshake()
ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:992)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python311\Lib\site-packages\requests\adapters.py", line 489, in send    
    resp = conn.urlopen(
           ^^^^^^^^^^^^^
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python311\Lib\site-packages\urllib3\connectionpool.py", line 787, in urlopen
    retries = retries.increment(
              ^^^^^^^^^^^^^^^^^^
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python311\Lib\site-packages\urllib3\util\retry.py", line 592, in increment
    raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='www21.zippyshare.com', port=443): Max retries exceeded with url: /v/eG62avGB/file.html (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to 
get local issuer certificate (_ssl.c:992)')))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "c:\Users\Administrator\Desktop\main.py", line 3, in <module>
    file = extract_info("https://www21.zippyshare.com/v/eG62avGB/file.html", download=False)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python311\Lib\site-packages\zippyshare_downloader\fetcher.py", line 155, in extract_info
    info = get_info(url)
           ^^^^^^^^^^^^^
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python311\Lib\site-packages\zippyshare_downloader\fetcher.py", line 36, 
in get_info
    r = Net.requests.get(url)
        ^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python311\Lib\site-packages\requests\sessions.py", line 600, in get     
    return self.request("GET", url, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python311\Lib\site-packages\requests\sessions.py", line 587, in request 
    resp = self.send(prep, **send_kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python311\Lib\site-packages\requests\sessions.py", line 701, in send    
    r = adapter.send(request, **kwargs)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python311\Lib\site-packages\requests\adapters.py", line 563, in send    
    raise SSLError(e, request=request)
requests.exceptions.SSLError: HTTPSConnectionPool(host='www21.zippyshare.com', port=443): Max retries exceeded with url: /v/eG62avGB/file.html (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get 
local issuer certificate (_ssl.c:992)')))

Ask

i want to show download url, how to do it?

zippyshare-dl error when upgrade ubuntu...

zippyshare-dl or zippyshare-downloader version 0.3.3, Im using Python 3.10.6 and pip 23.0.1 from /usr/local/lib/python3.10/dist-packages/pip (python 3.10)

root@ubuntu:~# zippyshare-dl "https://www76.zippyshare.com/v/xxx/file.html" --proxy "socks5h://user:[email protected]:1212"
[INFO] Grabbing required informations in https://www76.zippyshare.com/v/xxx/file.html
[INFO] Downloading "ASD.mp4" 
Traceback (most recent call last):
  File "/usr/local/bin/zippyshare-dl", line 8, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.10/dist-packages/zippyshare_downloader/cli/process.py", line 165, in main
    process(**kwargs)
  File "/usr/local/lib/python3.10/dist-packages/zippyshare_downloader/cli/process.py", line 80, in process
    file = extract_info(urls, **kwargs)
  File "/usr/local/lib/python3.10/dist-packages/zippyshare_downloader/fetcher.py", line 158, in extract_info
    file_path = file.download(**kwargs)
  File "/usr/local/lib/python3.10/dist-packages/zippyshare_downloader/file.py", line 105, in download
    downloader.download()
  File "/usr/local/lib/python3.10/dist-packages/zippyshare_downloader/downloader.py", line 86, in download
    file_sizes = float(resp.headers.get('Content-Length'))
TypeError: float() argument must be a string or a real number, not 'NoneType'

Please help me, thanks mansuf!

Idea: Use youtube-dl's minimal javascript interpreter to make this robust against future changes

The key thing we want to do is safely run a piece of javascript code that contains some function evaluations and arithmetic. This is exactly what youtube-dl's tiny JS implementation was designed for. For instance, here's a completely self-contained example of you might use it

#!/usr/bin/env python3

from __future__ import unicode_literals

import json
import operator
import re

def remove_quotes(s):
	if s is None or len(s) < 2:
		return s
	for quote in ('"', "'", ):
		if s[0] == quote and s[-1] == quote:
			return s[1:-1]
	return s


_OPERATORS = [
	('|', operator.or_),
	('^', operator.xor),
	('&', operator.and_),
	('>>', operator.rshift),
	('<<', operator.lshift),
	('-', operator.sub),
	('+', operator.add),
	('%', operator.mod),
	('/', operator.truediv),
	('*', operator.mul),
]
_ASSIGN_OPERATORS = [(op + '=', opfunc) for op, opfunc in _OPERATORS]
_ASSIGN_OPERATORS.append(('=', lambda cur, right: right))

_NAME_RE = r'[a-zA-Z_$][a-zA-Z_$0-9]*'


class JSInterpreter(object):
	def __init__(self, code, objects=None):
		if objects is None:
			objects = {}
		self.code = code
		self._functions = {}
		self._objects = objects
		
	def interpret_statement(self, stmt, local_vars, allow_recursion=100):
		if allow_recursion < 0:
			raise Exception('Recursion limit reached')
			
		should_abort = False
		stmt = stmt.lstrip()
		stmt_m = re.match(r'var\s', stmt)
		if stmt_m:
			expr = stmt[len(stmt_m.group(0)):]
		else:
			return_m = re.match(r'return(?:\s+|$)', stmt)
			if return_m:
				expr = stmt[len(return_m.group(0)):]
				should_abort = True
			else:
				# Try interpreting it as an expression
				expr = stmt
				
		v = self.interpret_expression(expr, local_vars, allow_recursion)
		return v, should_abort
	
	def interpret_expression(self, expr, local_vars, allow_recursion):
		expr = expr.strip()
		if expr == '':  # Empty expression
			return None
	
		if expr.startswith('('):
			parens_count = 0
			for m in re.finditer(r'[()]', expr):
				if m.group(0) == '(':
					parens_count += 1
				else:
					parens_count -= 1
					if parens_count == 0:
						sub_expr = expr[1:m.start()]
						sub_result = self.interpret_expression(
							sub_expr, local_vars, allow_recursion)
						remaining_expr = expr[m.end():].strip()
						if not remaining_expr:
							return sub_result
						else:
							expr = json.dumps(sub_result) + remaining_expr
						break
			else:
				raise Exception('Premature end of parens in %r' % expr)
				
		for op, opfunc in _ASSIGN_OPERATORS:
			m = re.match(r'''(?x)
				(?P<out>%s)(?:\[(?P<index>[^\]]+?)\])?
				\s*%s
				(?P<expr>.*)$''' % (_NAME_RE, re.escape(op)), expr)
			if not m:
				continue
			right_val = self.interpret_expression(
				m.group('expr'), local_vars, allow_recursion - 1)
			
			if m.groupdict().get('index'):
				lvar = local_vars[m.group('out')]
				idx = self.interpret_expression(
					m.group('index'), local_vars, allow_recursion)
				assert isinstance(idx, int)
				cur = lvar[idx]
				val = opfunc(cur, right_val)
				lvar[idx] = val
				return val
			else:
				cur = local_vars.get(m.group('out'))
				val = opfunc(cur, right_val)
				local_vars[m.group('out')] = val
				return val
			
		if expr.isdigit():
			return int(expr)
	
		var_m = re.match(
			r'(?!if|return|true|false)(?P<name>%s)$' % _NAME_RE,
			expr)
		if var_m:
			return local_vars[var_m.group('name')]
	
		try:
			return json.loads(expr)
		except ValueError:
			pass
			
		m = re.match(
			r'(?P<in>%s)\[(?P<idx>.+)\]$' % _NAME_RE, expr)
		if m:
			val = local_vars[m.group('in')]
			idx = self.interpret_expression(
				m.group('idx'), local_vars, allow_recursion - 1)
			return val[idx]
	
		m = re.match(
			r'(?P<var>%s)(?:\.(?P<member>[^(]+)|\[(?P<member2>[^]]+)\])\s*(?:\(+(?P<args>[^()]*)\))?$' % _NAME_RE,
			expr)
		if m:
			variable = m.group('var')
			member = remove_quotes(m.group('member') or m.group('member2'))
			arg_str = m.group('args')
			
			if variable in local_vars:
				obj = local_vars[variable]
			else:
				if variable not in self._objects:
					self._objects[variable] = self.extract_object(variable)
				obj = self._objects[variable]
				
			if arg_str is None:
				# Member access
				if member == 'length':
					return len(obj)
				return obj[member]
			
			assert expr.endswith(')')
			# Function call
			if arg_str == '':
				argvals = tuple()
			else:
				argvals = tuple([
					self.interpret_expression(v, local_vars, allow_recursion)
					for v in arg_str.split(',')])
				
			if member == 'split':
				assert argvals == ('',)
				return list(obj)
			if member == 'join':
				assert len(argvals) == 1
				return argvals[0].join(obj)
			if member == 'reverse':
				assert len(argvals) == 0
				obj.reverse()
				return obj
			if member == 'slice':
				assert len(argvals) == 1
				return obj[argvals[0]:]
			if member == 'splice':
				assert isinstance(obj, list)
				index, howMany = argvals
				res = []
				for i in range(index, min(index + howMany, len(obj))):
					res.append(obj.pop(index))
				return res
			
			return obj[member](argvals)
	
		for op, opfunc in _OPERATORS:
			m = re.match(r'(?P<x>.+?)%s(?P<y>.+)' % re.escape(op), expr)
			if not m:
				continue
			x, abort = self.interpret_statement(
				m.group('x'), local_vars, allow_recursion - 1)
			if abort:
				raise Exception(
					'Premature left-side return of %s in %r' % (op, expr))
			y, abort = self.interpret_statement(
				m.group('y'), local_vars, allow_recursion - 1)
			if abort:
				raise Exception(
					'Premature right-side return of %s in %r' % (op, expr))
			return opfunc(x, y)
	
		m = re.match(
			r'^(?P<func>%s)\((?P<args>[a-zA-Z0-9_$,]*)\)$' % _NAME_RE, expr)
		if m:
			fname = m.group('func')
			argvals = tuple([
				int(v) if v.isdigit() else local_vars[v]
				for v in m.group('args').split(',')]) if len(m.group('args')) > 0 else tuple()
			if fname not in self._functions:
				self._functions[fname] = self.extract_function(fname)
			return self._functions[fname](argvals)
	
		raise Exception('Unsupported JS expression %r' % expr)
	
	def extract_object(self, objname):
		_FUNC_NAME_RE = r'''(?:[a-zA-Z$0-9]+|"[a-zA-Z$0-9]+"|'[a-zA-Z$0-9]+')'''
		obj = {}
		obj_m = re.search(
			r'''(?x)
				(?<!this\.)%s\s*=\s*{\s*
					(?P<fields>(%s\s*:\s*function\s*\(.*?\)\s*{.*?}(?:,\s*)?)*)
				}\s*;
			''' % (re.escape(objname), _FUNC_NAME_RE),
			self.code)
		fields = obj_m.group('fields')
		# Currently, it only supports function definitions
		fields_m = re.finditer(
			r'''(?x)
				(?P<key>%s)\s*:\s*function\s*\((?P<args>[a-z,]+)\){(?P<code>[^}]+)}
			''' % _FUNC_NAME_RE,
			fields)
		for f in fields_m:
			argnames = f.group('args').split(',')
			obj[remove_quotes(f.group('key'))] = self.build_function(argnames, f.group('code'))
			
		return obj
	
	def extract_function(self, funcname):
		func_m = re.search(
			r'''(?x)
				(?:function\s+%s|[{;,]\s*%s\s*=\s*function|var\s+%s\s*=\s*function)\s*
				\((?P<args>[^)]*)\)\s*
				\{(?P<code>[^}]+)\}''' % (
				re.escape(funcname), re.escape(funcname), re.escape(funcname)),
			self.code)
		if func_m is None:
			raise Exception('Could not find JS function %r' % funcname)
		argnames = func_m.group('args').split(',')
		
		return self.build_function(argnames, func_m.group('code'))
	
	def call_function(self, funcname, *args):
		f = self.extract_function(funcname)
		return f(args)
	
	def build_function(self, argnames, code):
		def resf(args):
			local_vars = dict(zip(argnames, args))
			for stmt in code.split(';'):
				res, abort = self.interpret_statement(stmt, local_vars)
				if abort:
					break
			return res
		return resf
	
	
code = '''
function f() {
x = 5;
y = x + 3; return y;}
'''

jsi = JSInterpreter(code)
print(jsi.call_function("f"))

Filenames are still not writing correctly.

I executed the following in a Google Colab session:

!zippyshare-downloader https://www103.zippyshare.com/v/7S3vO6Op/file.html --verbose --progress-bar && zippyshare-downloader https://www103.zippyshare.com/v/4jjHYw2d/file.html --verbose --progress-bar && zippyshare-downloader https://www103.zippyshare.com/v/5cjVlAUm/file.html --verbose --progress-bar && zippyshare-downloader https://www103.zippyshare.com/v/ZZotSH97/file.html --verbose --progress-bar && zippyshare-downloader https://www103.zippyshare.com/v/ebuvfMVY/file.html --verbose --progress-bar && zippyshare-downloader https://www103.zippyshare.com/v/EjkGpC8i/file.html --verbose --progress-bar && zippyshare-downloader https://www103.zippyshare.com/v/gIjQiQfx/file.html --verbose --progress-bar && zippyshare-downloader https://www103.zippyshare.com/v/fJNQgAi3/file.html --verbose --progress-bar

And got the following output:

[INFO] Fetching URL "https://www103.zippyshare.com/v/7S3vO6Op/file.html"
[INFO] Parsing info
[INFO] Getting Download URL from "https://www103.zippyshare.com/v/7S3vO6Op/file.html"
[INFO] Downloading "Fear.the.Walking.Dead.S06E08.The.Door.1080p.AMZN.WEB-DL.DDP5.1.H.264-NTb.mkv.par..."
Downloading data from https://www103.zippyshare.com/d/7S3vO6Op/859190/Fear.the.Walking.Dead.S06E08.The.Door.1080p.AMZN.WEB-DL.DDP5.1.H.264-NTb.mkv.part1.rar (500.0 MB)

file_sizes: 100%|████████████████████████████| 524M/524M [00:46<00:00, 11.4MB/s]
Successfully downloaded file to Fear.the.Walking.Dead.S06E08.The.Door.1080p.AMZN.WEB-DL.DDP5.1.H.264-NTb.mkv.par...
{'name_file': 'Fear.the.Walking.Dead.S06E08.The.Door.1080p.AMZN.WEB-DL.DDP5.1.H.264-NTb.mkv.par...', 'size': '500 MB', 'date_upload': '04-04-2021 17:36', 'download_url': 'https://www103.zippyshare.com/d/7S3vO6Op/859190/Fear.the.Walking.Dead.S06E08.The.Door.1080p.AMZN.WEB-DL.DDP5.1.H.264-NTb.mkv.part1.rar'}
[INFO] Fetching URL "https://www103.zippyshare.com/v/4jjHYw2d/file.html"
[INFO] Parsing info
[INFO] Getting Download URL from "https://www103.zippyshare.com/v/4jjHYw2d/file.html"
[INFO] Downloading "Fear.the.Walking.Dead.S06E08.The.Door.1080p.AMZN.WEB-DL.DDP5.1.H.264-NTb.mkv.par..."
Replace is False and data exists, so doing nothing. Use replace=True to re-download the data.
{'name_file': 'Fear.the.Walking.Dead.S06E08.The.Door.1080p.AMZN.WEB-DL.DDP5.1.H.264-NTb.mkv.par...', 'size': '500 MB', 'date_upload': '04-04-2021 17:37', 'download_url': 'https://www103.zippyshare.com/d/4jjHYw2d/430404/Fear.the.Walking.Dead.S06E08.The.Door.1080p.AMZN.WEB-DL.DDP5.1.H.264-NTb.mkv.part2.rar'}
[INFO] Fetching URL "https://www103.zippyshare.com/v/5cjVlAUm/file.html"
[INFO] Parsing info
[INFO] Getting Download URL from "https://www103.zippyshare.com/v/5cjVlAUm/file.html"
[INFO] Downloading "Fear.the.Walking.Dead.S06E08.The.Door.1080p.AMZN.WEB-DL.DDP5.1.H.264-NTb.mkv.par..."
Replace is False and data exists, so doing nothing. Use replace=True to re-download the data.
{'name_file': 'Fear.the.Walking.Dead.S06E08.The.Door.1080p.AMZN.WEB-DL.DDP5.1.H.264-NTb.mkv.par...', 'size': '500 MB', 'date_upload': '04-04-2021 17:38', 'download_url': 'https://www103.zippyshare.com/d/5cjVlAUm/762364/Fear.the.Walking.Dead.S06E08.The.Door.1080p.AMZN.WEB-DL.DDP5.1.H.264-NTb.mkv.part3.rar'}
[INFO] Fetching URL "https://www103.zippyshare.com/v/ZZotSH97/file.html"
[INFO] Parsing info
[INFO] Getting Download URL from "https://www103.zippyshare.com/v/ZZotSH97/file.html"
[INFO] Downloading "Fear.the.Walking.Dead.S06E08.The.Door.1080p.AMZN.WEB-DL.DDP5.1.H.264-NTb.mkv.par..."
Replace is False and data exists, so doing nothing. Use replace=True to re-download the data.
{'name_file': 'Fear.the.Walking.Dead.S06E08.The.Door.1080p.AMZN.WEB-DL.DDP5.1.H.264-NTb.mkv.par...', 'size': '500 MB', 'date_upload': '04-04-2021 17:38', 'download_url': 'https://www103.zippyshare.com/d/ZZotSH97/150614/Fear.the.Walking.Dead.S06E08.The.Door.1080p.AMZN.WEB-DL.DDP5.1.H.264-NTb.mkv.part4.rar'}
[INFO] Fetching URL "https://www103.zippyshare.com/v/ebuvfMVY/file.html"
[INFO] Parsing info
[INFO] Getting Download URL from "https://www103.zippyshare.com/v/ebuvfMVY/file.html"
[INFO] Downloading "Fear.the.Walking.Dead.S06E08.The.Door.1080p.AMZN.WEB-DL.DDP5.1.H.264-NTb.mkv.par..."
Replace is False and data exists, so doing nothing. Use replace=True to re-download the data.
{'name_file': 'Fear.the.Walking.Dead.S06E08.The.Door.1080p.AMZN.WEB-DL.DDP5.1.H.264-NTb.mkv.par...', 'size': '500 MB', 'date_upload': '04-04-2021 17:39', 'download_url': 'https://www103.zippyshare.com/d/ebuvfMVY/860808/Fear.the.Walking.Dead.S06E08.The.Door.1080p.AMZN.WEB-DL.DDP5.1.H.264-NTb.mkv.part5.rar'}
[INFO] Fetching URL "https://www103.zippyshare.com/v/EjkGpC8i/file.html"
[INFO] Parsing info
[INFO] Getting Download URL from "https://www103.zippyshare.com/v/EjkGpC8i/file.html"
[INFO] Downloading "Fear.the.Walking.Dead.S06E08.The.Door.1080p.AMZN.WEB-DL.DDP5.1.H.264-NTb.mkv.par..."
Replace is False and data exists, so doing nothing. Use replace=True to re-download the data.
{'name_file': 'Fear.the.Walking.Dead.S06E08.The.Door.1080p.AMZN.WEB-DL.DDP5.1.H.264-NTb.mkv.par...', 'size': '500 MB', 'date_upload': '04-04-2021 17:40', 'download_url': 'https://www103.zippyshare.com/d/EjkGpC8i/340215/Fear.the.Walking.Dead.S06E08.The.Door.1080p.AMZN.WEB-DL.DDP5.1.H.264-NTb.mkv.part6.rar'}
[INFO] Fetching URL "https://www103.zippyshare.com/v/gIjQiQfx/file.html"
[INFO] Parsing info
[INFO] Getting Download URL from "https://www103.zippyshare.com/v/gIjQiQfx/file.html"
[INFO] Downloading "Fear.the.Walking.Dead.S06E08.The.Door.1080p.AMZN.WEB-DL.DDP5.1.H.264-NTb.mkv.par..."
Replace is False and data exists, so doing nothing. Use replace=True to re-download the data.
{'name_file': 'Fear.the.Walking.Dead.S06E08.The.Door.1080p.AMZN.WEB-DL.DDP5.1.H.264-NTb.mkv.par...', 'size': '500 MB', 'date_upload': '04-04-2021 17:40', 'download_url': 'https://www103.zippyshare.com/d/gIjQiQfx/908321/Fear.the.Walking.Dead.S06E08.The.Door.1080p.AMZN.WEB-DL.DDP5.1.H.264-NTb.mkv.part7.rar'}
[INFO] Fetching URL "https://www103.zippyshare.com/v/fJNQgAi3/file.html"
[INFO] Parsing info
[INFO] Getting Download URL from "https://www103.zippyshare.com/v/fJNQgAi3/file.html"
[INFO] Downloading "Fear.the.Walking.Dead.S06E08.The.Door.1080p.AMZN.WEB-DL.DDP5.1.H.264-NTb.mkv.par..."
Replace is False and data exists, so doing nothing. Use replace=True to re-download the data.
{'name_file': 'Fear.the.Walking.Dead.S06E08.The.Door.1080p.AMZN.WEB-DL.DDP5.1.H.264-NTb.mkv.par...', 'size': '256.31 MB', 'date_upload': '04-04-2021 17:40', 'download_url': 'https://www103.zippyshare.com/d/fJNQgAi3/263794/Fear.the.Walking.Dead.S06E08.The.Door.1080p.AMZN.WEB-DL.DDP5.1.H.264-NTb.mkv.part8.rar'}

sometimes the module fails to get the download link

image
If the module function fails the download size of the file will be less than 1MB but the problem is even if the module function fails to get the direct download link it will give file size as 500 (I will use recursive function to recheck since zippyshare website will change every time we visit)
Code used is shown below

import  re
from zippyshare_downloader import Zippyshare




def size_check(txt):
 
 
  z = Zippyshare()
  info=z.extract_info(txt,0)
  print(info["size"])
  a3=0
  temp = re.compile("([0-9]+)")
  ras = temp.match(info["size"]).groups()
  a3=int(ras[0])
 
  if(a3>1):
     z.extract_info(txt)
  else :
    size_check(txt)


txt =input("test")

x = txt.split()

for i in range(len(x)):
  size_check(x[i])

The app doesn't write the filename properly when downloading.

Here's some code output I got:

[INFO] Fetching URL "https://www108.zippyshare.com/v/kt8db8LC/file.html"
[INFO] Parsing info
[INFO] Getting Download URL from "https://www108.zippyshare.com/v/kt8db8LC/file.html"
[INFO] Downloading "file name"
Downloading data from https://www108.zippyshare.com/d/kt8db8LC/271977/Prison.Break.S01E01.Pilot.1080p.BluRay.REMUX.AVC.DTS-HD.MA.5.1-EPSiLON.part01.rar (500.0 MB)

file_sizes: 3%|▉ | 17.5M/524M [00:01<00:51, 9.79MB/s]
Traceback (most recent call last):
File "/usr/local/bin/zippyshare-downloader", line 8, in
sys.exit(main())
File "/usr/local/lib/python3.7/dist-packages/zippyshare_downloader/main.py", line 21, in main
print(z.extract_info(args.ZIPPYSHARE_URL, download=True))
File "/usr/local/lib/python3.7/dist-packages/zippyshare_downloader/init.py", line 184, in extract_info
return self._extract_info(url, download=download)
File "/usr/local/lib/python3.7/dist-packages/zippyshare_downloader/init.py", line 158, in _extract_info
dl(info['download_url'], info['name_file'], progressbar=self._progress_bar, verbose=self._verbose, replace=self._replace)
File "/usr/local/lib/python3.7/dist-packages/download/download.py", line 124, in download
progressbar=progressbar,
File "/usr/local/lib/python3.7/dist-packages/download/download.py", line 254, in _fetch_file
ncols=80,
File "/usr/local/lib/python3.7/dist-packages/download/download.py", line 381, in _get_http
chunk = response.read(chunk_size)
File "/usr/lib/python3.7/http/client.py", line 461, in read
n = self.readinto(b)
File "/usr/lib/python3.7/http/client.py", line 505, in readinto
n = self.fp.readinto(b)
File "/usr/lib/python3.7/socket.py", line 589, in readinto
return self._sock.recv_into(b)
File "/usr/lib/python3.7/ssl.py", line 1071, in recv_into
return self.read(nbytes, buffer)
File "/usr/lib/python3.7/ssl.py", line 929, in read
return self._sslobj.read(len, buffer)
KeyboardInterrupt

Inheritance class aiohttpProxiedSession from ClientSession is forbidden

Hi!
It raises error.

Python version:

d:\JDownloader\zippyshare-downloader-0.3.4>python
Python 3.8.2 (tags/v3.8.2:7b3ab59, Feb 25 2020, 22:45:29) [MSC v.1916 32 bit (Intel)] on win32

CLI output:

d:\JDownloader\zippyshare-downloader-0.3.4>python -m zippyshare_downloader https://filecrypt.cc/Container/8B69C3762B.html
Traceback (most recent call last):
File "C:\Users\Leolapi4\AppData\Local\Programs\Python\Python38-32\lib\runpy.py", line 184, in _run_module_as_main
mod_name, mod_spec, code = _get_module_details(mod_name, _Error)
File "C:\Users\Leolapi4\AppData\Local\Programs\Python\Python38-32\lib\runpy.py", line 143, in _get_module_details
return _get_module_details(pkg_main_name, error)
File "C:\Users\Leolapi4\AppData\Local\Programs\Python\Python38-32\lib\runpy.py", line 110, in get_module_details
import(pkg_name)
File "d:\JDownloader\zippyshare-downloader-0.3.4\zippyshare_downloader_init
.py", line 11, in
from .network import *
File "d:\JDownloader\zippyshare-downloader-0.3.4\zippyshare_downloader\network.py", line 23, in
class aiohttpProxiedSession(aiohttp.ClientSession):
File "C:\Users\Leolapi4\AppData\Local\Programs\Python\Python38-32\lib\site-packages\aiohttp-4.0.0a1-py3.8-win32.egg\aiohttp\client.py", line 265, in init_subclass
raise TypeError("Inheritance class {} from ClientSession "
TypeError: Inheritance class aiohttpProxiedSession from ClientSession is forbidden

The app is not working.

When you try to download any zippyshare link, it gives the following output:

Traceback (most recent call last):
File "/usr/lib/python3.7/runpy.py", line 193, in _run_module_as_main
"main", mod_spec)
File "/usr/lib/python3.7/runpy.py", line 85, in _run_code
exec(code, run_globals)
File "/usr/local/lib/python3.7/dist-packages/zippyshare_downloader/main.py", line 77, in
main()
File "/usr/local/lib/python3.7/dist-packages/zippyshare_downloader/main.py", line 73, in main
custom_filename=args.filename
File "/usr/local/lib/python3.7/dist-packages/zippyshare_downloader/main.py", line 25, in extract_single_urls
result = json.dumps(z.extract_info(url, download=download, folder=folder, custom_filename=custom_filename))
File "/usr/local/lib/python3.7/dist-packages/zippyshare_downloader/init.py", line 237, in extract_info
custom_filename=custom_filename
File "/usr/local/lib/python3.7/dist-packages/zippyshare_downloader/init.py", line 188, in _extract_info
self._logger_info(f'Using directory "{os.path.join(os.getcwd(), folder)}"')
File "/usr/lib/python3.7/posixpath.py", line 94, in join
genericpath._check_arg_types('join', a, *p)
File "/usr/lib/python3.7/genericpath.py", line 153, in _check_arg_types
(funcname, s.class.name)) from None
TypeError: join() argument must be str or bytes, not 'NoneType'

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.