forked from speedyseal/audiosetdl
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The pafy has not had any release since 2019 Should fix download errors like KeyError 'like_count', ref mps-youtube/pafy#287
- Loading branch information
Showing
5 changed files
with
169 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
youtube-dl==2017.9.15 | ||
pafy==0.5.3.1 | ||
multiprocessing-logging==0.2.4 | ||
sox==1.3.3 | ||
sk-video==1.1.8 | ||
|
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
|
||
import sys | ||
import os.path | ||
import json | ||
|
||
here = os.path.dirname(__file__) | ||
|
||
sys.path.insert(0, os.path.join(here, '..')) | ||
import download_audioset as audiosetdl | ||
|
||
|
||
|
||
def read_json_file(path): | ||
with open(path, 'r') as f: | ||
contents = f.read() | ||
data = json.loads(contents) | ||
return data | ||
|
||
def test_get_best_audio(): | ||
|
||
p = os.path.join(here, 'data/69kudlOXwMs.info.json') | ||
info = read_json_file(p) | ||
expected_best_bitrate = 130.955 | ||
|
||
s = audiosetdl.sort_audio_formats(info["formats"]) | ||
print(list(f['abr'] for f in s)) | ||
|
||
assert s[0]['abr'] == expected_best_bitrate | ||
|
||
best = audiosetdl.get_best_audio_format(info["formats"]) | ||
print(best['abr']) | ||
|
||
def test_get_best_video(): | ||
p = os.path.join(here, 'data/69kudlOXwMs.info.json') | ||
info = read_json_file(p) | ||
|
||
for f in info['formats']: | ||
print(f.get('width'), f.get('vbr'), f.get('tbr')) | ||
|
||
expected_best_width = 1280 | ||
expected_best_bitrate_videoaudio = 1662.976 | ||
expected_best_bitrate_video_only = 1530.31 | ||
|
||
# with audio | ||
best = audiosetdl.get_best_video_format(info["formats"], video_mode='bestvideoaudio') | ||
assert best['width'] == expected_best_width | ||
assert best['tbr'] == expected_best_bitrate_videoaudio | ||
|
||
# without audio | ||
best = audiosetdl.get_best_video_format(info["formats"], video_mode='bestvideo') | ||
assert best['width'] == expected_best_width | ||
assert best['tbr'] == expected_best_bitrate_video_only | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters