diff --git a/__pycache__/lib_pornhub.cpython-311.pyc b/__pycache__/lib_pornhub.cpython-311.pyc index 4b67ce3..0a6fc0e 100644 Binary files a/__pycache__/lib_pornhub.cpython-311.pyc and b/__pycache__/lib_pornhub.cpython-311.pyc differ diff --git a/lib_pornhub.py b/lib_pornhub.py index 50411bb..0fc1902 100644 --- a/lib_pornhub.py +++ b/lib_pornhub.py @@ -44,10 +44,11 @@ def run_command(command): state = 0 current_frag = 0 total_frag = 1 + result_txt = '' while True: output = process.stdout.readline().decode("utf-8") if "[download] 100" in output: - result_txt = 'Result: ' + output.split("[download]")[-1].strip() + result_txt = 'Result: ' + output.split("[download]")[1].strip() if output == '' and process.poll() is not None: break @@ -63,7 +64,7 @@ def run_command(command): pbar.update(100 - state) pbar.close() rc = process.poll() - print(result_txt) + if result_txt != '': print(result_txt) return rc except Exception as e: print(e) @@ -126,16 +127,26 @@ def ph_download_playlist(url, model_name, limit): # global duration check_output_dir(model_name) - # tmp_playlist download - print('... Getting playlist information...') - playlist_download_command = [".\yt-dlp", "-j", - "--flat-playlist", "--no-check-certificate", url] - res = subprocess.run(playlist_download_command, - capture_output=True, text=True).stdout.split("\n") if (limit != 0): print("[!] Limit: {} videos".format(limit)) + + # tmp_playlist download + print('... Getting playlist information...') + try: + playlist_download_command = [".\yt-dlp", "-j", + "--flat-playlist", "--no-check-certificate", url] + res = subprocess.run(playlist_download_command, + capture_output=True, text=True).stdout.split("\n") + except Exception as e: + print(e) + sys.exit(1) count = 0 + if res == ['']: + print("Cannot download playlist information!") + sys.exit(1) + print("Playlist has {} videos".format(len(res))) + for i in range(len(res) - 1): if (count == limit and limit != 0): break