Update lib_pornhub.py
Signed-off-by: Lev Rusanov <30170278+JDM170@users.noreply.github.com>
This commit is contained in:
@@ -28,11 +28,11 @@ def ph_config_dl_dir(dir):
|
||||
if (dir != None):
|
||||
download_dir = dir
|
||||
print("Output directory: " + download_dir + "\\model\\")
|
||||
if (os.path.exists(download_dir) != True):
|
||||
if not os.path.exists(download_dir):
|
||||
print('Invalid Directory!')
|
||||
sys.exit()
|
||||
download_dir = download_dir + "\\model\\"
|
||||
if (os.path.exists(download_dir) != True):
|
||||
if not os.path.exists(download_dir):
|
||||
os.mkdir(download_dir)
|
||||
|
||||
|
||||
@@ -49,7 +49,7 @@ def run_command(command):
|
||||
output = process.stdout.readline().decode("utf-8")
|
||||
if "[download] 100" in output:
|
||||
result_txt = 'Result: ' + output.split("[download]")[1].strip()
|
||||
if output == '' and process.poll() is not None:
|
||||
if (output == '') and process.poll() is not None:
|
||||
break
|
||||
if 'Total fragments' in output:
|
||||
total_frag = int(output.split(':')[1].strip())
|
||||
@@ -67,7 +67,7 @@ def run_command(command):
|
||||
return rc
|
||||
except Exception as e:
|
||||
print(e)
|
||||
sys.exit(0)
|
||||
sys.exit()
|
||||
|
||||
|
||||
# Main functions
|
||||
@@ -82,7 +82,6 @@ def ph_check_valid_pornhub_url(url):
|
||||
|
||||
|
||||
def download_video(url, filename):
|
||||
# global duration
|
||||
state = 0
|
||||
print('[+] Save as: ' + filename + '\n')
|
||||
try:
|
||||
@@ -104,9 +103,9 @@ def fix_title(s):
|
||||
|
||||
def check_output_dir(model_name):
|
||||
global download_dir
|
||||
download_dir = download_dir
|
||||
if (os.path.exists(download_dir + model_name) != True):
|
||||
os.mkdir(download_dir+model_name)
|
||||
# download_dir = download_dir
|
||||
if not os.path.exists(download_dir + model_name):
|
||||
os.mkdir(download_dir + model_name)
|
||||
|
||||
|
||||
def ph_download_video(url, model_name, filename):
|
||||
@@ -135,18 +134,17 @@ def ph_download_playlist(url, model_name, limit):
|
||||
capture_output=True, text=True).stdout.split("\n")
|
||||
except Exception as e:
|
||||
print(e)
|
||||
sys.exit(1)
|
||||
count = 0
|
||||
sys.exit()
|
||||
|
||||
if res == ['']:
|
||||
print("Cannot download playlist information!")
|
||||
sys.exit(1)
|
||||
sys.exit()
|
||||
|
||||
print("Playlist has {} videos".format(len(res)))
|
||||
count = 0
|
||||
for i in range(len(res) - 1):
|
||||
if (count == limit and limit != 0):
|
||||
if (count == limit) and (limit != 0):
|
||||
break
|
||||
sys.exit()
|
||||
try:
|
||||
# print(res[i])
|
||||
# video_dict = ast.literal_eval(res[i])
|
||||
@@ -165,7 +163,7 @@ def ph_download_playlist(url, model_name, limit):
|
||||
count = count + 1
|
||||
except KeyboardInterrupt:
|
||||
print("Cannot download video")
|
||||
sys.exit()
|
||||
sys.exit()
|
||||
|
||||
|
||||
def fix_url(url, type):
|
||||
|
||||
Reference in New Issue
Block a user