mirror of
https://github.com/soimort/you-get.git
synced 2025-01-23 21:45:02 +03:00
Merge branch 'develop' into THVideo
This commit is contained in:
commit
178a9a54ad
17
.github/ISSUE_TEMPLATE.md
vendored
Normal file
17
.github/ISSUE_TEMPLATE.md
vendored
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
Please make sure these boxes are checked before submitting your issue – thank you!
|
||||||
|
|
||||||
|
- [ ] You can actually watch the video in your browser, but not download them with `you-get`.
|
||||||
|
- [ ] Your `you-get` is up-to-date.
|
||||||
|
- [ ] The issue is not yet reported on <https://github.com/soimort/you-get/issues> or <https://github.com/soimort/you-get/wiki/Known-Bugs>.
|
||||||
|
- [ ] The issue (or question) is really about `you-get`, not about some other code or project.
|
||||||
|
|
||||||
|
Run the command with the `--debug` option, and paste the full output inside the fences:
|
||||||
|
|
||||||
|
```
|
||||||
|
[PASTE IN ME]
|
||||||
|
```
|
||||||
|
|
||||||
|
If there's anything else you would like to say (e.g. in case your issue is not about downloading a specific video; it might as well be a general discussion or proposal for a new feature), fill in the box below; otherwise, you may want to post an emoji or meme instead:
|
||||||
|
|
||||||
|
> [WRITE SOMETHING]
|
||||||
|
> [OR HAVE SOME :icecream:!]
|
22
.github/PULL_REQUEST_TEMPLATE.md
vendored
Normal file
22
.github/PULL_REQUEST_TEMPLATE.md
vendored
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
**(PLEASE DELETE ALL THESE AFTER READING)**
|
||||||
|
|
||||||
|
Thank you for the pull request! `you-get` is a growing open source project, which would not have been possible without contributors like you.
|
||||||
|
|
||||||
|
Here are some simple rules to follow, please recheck them before sending the pull request:
|
||||||
|
|
||||||
|
- [ ] If you want to propose two or more unrelated patches, please open separate pull requests for them, instead of one;
|
||||||
|
- [ ] All pull requests should be based upon the latest `develop` branch;
|
||||||
|
- [ ] Name your branch (from which you will send the pull request) properly; use a meaningful name like `add-this-shining-feature` rather than just `develop`;
|
||||||
|
- [ ] All commit messages, as well as comments in code, should be written in understandable English.
|
||||||
|
|
||||||
|
As a contributor, you must be aware that
|
||||||
|
|
||||||
|
- [ ] You agree to contribute your code to this project, under the terms of the MIT license, so that any person may freely use or redistribute them; of course, you will still reserve the copyright for your own authorship.
|
||||||
|
- [ ] You may not contribute any code not authored by yourself, unless they are licensed under either public domain or the MIT license, literally.
|
||||||
|
|
||||||
|
Not all pull requests can eventually be merged. I consider merged / unmerged patches as equally important for the community: as long as you think a patch would be helpful, someone else might find it helpful, too, therefore they could take your fork and benefit in some way. In any case, I would like to thank you in advance for taking your time to contribute to this project.
|
||||||
|
|
||||||
|
Cheers,
|
||||||
|
Mort
|
||||||
|
|
||||||
|
**(PLEASE REPLACE ALL ABOVE WITH A DETAILED DESCRIPTION OF YOUR PULL REQUEST)**
|
@ -542,8 +542,7 @@ def url_save_chunked(url, filepath, bar, refer = None, is_part = False, faker =
|
|||||||
os.rename(temp_filepath, filepath)
|
os.rename(temp_filepath, filepath)
|
||||||
|
|
||||||
class SimpleProgressBar:
|
class SimpleProgressBar:
|
||||||
bar_size = term.get_terminal_size()[1] - 42
|
term_size = term.get_terminal_size()[1]
|
||||||
bar = '{0:>5}% ({1:>5}/{2:<5}MB) ├{3:─<' + str(bar_size) + '}┤[{4}/{5}] {6}'
|
|
||||||
|
|
||||||
def __init__(self, total_size, total_pieces = 1):
|
def __init__(self, total_size, total_pieces = 1):
|
||||||
self.displayed = False
|
self.displayed = False
|
||||||
@ -554,11 +553,19 @@ class SimpleProgressBar:
|
|||||||
self.speed = ''
|
self.speed = ''
|
||||||
self.last_updated = time.time()
|
self.last_updated = time.time()
|
||||||
|
|
||||||
|
total_pieces_len = len(str(total_pieces))
|
||||||
|
# 38 is the size of all statically known size in self.bar
|
||||||
|
total_str = '%5s' % round(self.total_size / 1048576, 1)
|
||||||
|
total_str_width = max(len(total_str), 5)
|
||||||
|
self.bar_size = self.term_size - 27 - 2*total_pieces_len - 2*total_str_width
|
||||||
|
self.bar = '{:>4}%% ({:>%s}/%sMB) ├{:─<%s}┤[{:>%s}/{:>%s}] {}' % (
|
||||||
|
total_str_width, total_str, self.bar_size, total_pieces_len, total_pieces_len)
|
||||||
|
|
||||||
def update(self):
|
def update(self):
|
||||||
self.displayed = True
|
self.displayed = True
|
||||||
bar_size = self.bar_size
|
bar_size = self.bar_size
|
||||||
percent = round(self.received * 100 / self.total_size, 1)
|
percent = round(self.received * 100 / self.total_size, 1)
|
||||||
if percent > 100:
|
if percent >= 100:
|
||||||
percent = 100
|
percent = 100
|
||||||
dots = bar_size * int(percent) // 100
|
dots = bar_size * int(percent) // 100
|
||||||
plus = int(percent) - dots // bar_size * 100
|
plus = int(percent) - dots // bar_size * 100
|
||||||
@ -569,7 +576,7 @@ class SimpleProgressBar:
|
|||||||
else:
|
else:
|
||||||
plus = ''
|
plus = ''
|
||||||
bar = '█' * dots + plus
|
bar = '█' * dots + plus
|
||||||
bar = self.bar.format(percent, round(self.received / 1048576, 1), round(self.total_size / 1048576, 1), bar, self.current_piece, self.total_pieces, self.speed)
|
bar = self.bar.format(percent, round(self.received / 1048576, 1), bar, self.current_piece, self.total_pieces, self.speed)
|
||||||
sys.stdout.write('\r' + bar)
|
sys.stdout.write('\r' + bar)
|
||||||
sys.stdout.flush()
|
sys.stdout.flush()
|
||||||
|
|
||||||
@ -577,8 +584,10 @@ class SimpleProgressBar:
|
|||||||
self.received += n
|
self.received += n
|
||||||
time_diff = time.time() - self.last_updated
|
time_diff = time.time() - self.last_updated
|
||||||
bytes_ps = n / time_diff if time_diff else 0
|
bytes_ps = n / time_diff if time_diff else 0
|
||||||
if bytes_ps >= 1048576:
|
if bytes_ps >= 1024 ** 3:
|
||||||
self.speed = '{:4.0f} MB/s'.format(bytes_ps / 1048576)
|
self.speed = '{:4.0f} GB/s'.format(bytes_ps / 1024 ** 3)
|
||||||
|
elif bytes_ps >= 1024 ** 2:
|
||||||
|
self.speed = '{:4.0f} MB/s'.format(bytes_ps / 1024 ** 2)
|
||||||
elif bytes_ps >= 1024:
|
elif bytes_ps >= 1024:
|
||||||
self.speed = '{:4.0f} kB/s'.format(bytes_ps / 1024)
|
self.speed = '{:4.0f} kB/s'.format(bytes_ps / 1024)
|
||||||
else:
|
else:
|
||||||
@ -689,11 +698,13 @@ def download_urls(urls, title, ext, total_size, output_dir='.', refer=None, merg
|
|||||||
if len(urls) == 1:
|
if len(urls) == 1:
|
||||||
url = urls[0]
|
url = urls[0]
|
||||||
print('Downloading %s ...' % tr(output_filename))
|
print('Downloading %s ...' % tr(output_filename))
|
||||||
|
bar.update()
|
||||||
url_save(url, output_filepath, bar, refer = refer, faker = faker, headers = headers)
|
url_save(url, output_filepath, bar, refer = refer, faker = faker, headers = headers)
|
||||||
bar.done()
|
bar.done()
|
||||||
else:
|
else:
|
||||||
parts = []
|
parts = []
|
||||||
print('Downloading %s.%s ...' % (tr(title), ext))
|
print('Downloading %s.%s ...' % (tr(title), ext))
|
||||||
|
bar.update()
|
||||||
for i, url in enumerate(urls):
|
for i, url in enumerate(urls):
|
||||||
filename = '%s[%02d].%s' % (title, i, ext)
|
filename = '%s[%02d].%s' % (title, i, ext)
|
||||||
filepath = os.path.join(output_dir, filename)
|
filepath = os.path.join(output_dir, filename)
|
||||||
|
@ -9,12 +9,11 @@ def tudou_download_by_iid(iid, title, output_dir = '.', merge = True, info_only
|
|||||||
data = json.loads(get_decoded_html('http://www.tudou.com/outplay/goto/getItemSegs.action?iid=%s' % iid))
|
data = json.loads(get_decoded_html('http://www.tudou.com/outplay/goto/getItemSegs.action?iid=%s' % iid))
|
||||||
temp = max([data[i] for i in data if 'size' in data[i][0]], key=lambda x:sum([part['size'] for part in x]))
|
temp = max([data[i] for i in data if 'size' in data[i][0]], key=lambda x:sum([part['size'] for part in x]))
|
||||||
vids, size = [t["k"] for t in temp], sum([t["size"] for t in temp])
|
vids, size = [t["k"] for t in temp], sum([t["size"] for t in temp])
|
||||||
urls = [[n.firstChild.nodeValue.strip()
|
|
||||||
for n in
|
urls = []
|
||||||
parseString(
|
for vid in vids:
|
||||||
get_html('http://ct.v2.tudou.com/f?id=%s' % vid))
|
for i in parseString(get_html('http://ct.v2.tudou.com/f?id=%s' % vid)).getElementsByTagName('f'):
|
||||||
.getElementsByTagName('f')][0]
|
urls.append(i.firstChild.nodeValue.strip())
|
||||||
for vid in vids]
|
|
||||||
|
|
||||||
ext = r1(r'http://[\w.]*/(\w+)/[\w.]*', urls[0])
|
ext = r1(r'http://[\w.]*/(\w+)/[\w.]*', urls[0])
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user