Browse Source

Add 'start.py'

master
Joshua Pickard 3 years ago
parent
commit
6f825fdd0f
  1. 82
      start.py

82
start.py

@ -0,0 +1,82 @@
import customtkinter
import wget
import os
import urllib
import urllib.request
import requests
import fileinput
import zipfile
from pathlib import Path
import glob, os, shutil
p = Path('.')
target_folder = './Videos' + '//'
source_folder = (os.getcwd()) + '//'
def buttonclick():
# CREATE TXT FILE OF LIST
listofurls = urltextbox.get("0.0", "end")
file = open('urls.txt', 'w')
file.write(listofurls)
file.close()
# DOWNLOAD ALL ZIPS
for lines in fileinput.FileInput("urls.txt"):
print(lines)
openurl = wget.download(lines)
for f in p.glob('*.zip'):
with zipfile.ZipFile(f, 'r') as archive:
archive.extractall(path=f'./{f.stem}')
print(f'Done {f.stem}')
# DELETE ALL ZIP FILES
filelist = p.glob(os.path.join("*.zip"))
for f in filelist:
os.remove(f)
# MAKE VIDEOS DIRECTORY AND MOVE FILES
if not os.path.exists('./Videos'):
os.mkdir('./Videos')
for path, dir, files in os.walk(source_folder):
if files:
for file in files:
if not os.path.isfile(target_folder + file):
if file.endswith('.mp4'):
os.rename(path + '//' + file, target_folder + file)
# SET PROGRESS BAR TO 100% TEMPORARY
progressBar.set(100)
print("Done!")
print("Check the Videos Directory.")
customtkinter.set_appearance_mode("dark")
customtkinter.set_default_color_theme("dark-blue")
root = customtkinter.CTk()
# root.iconbitmap('c:/file.ico')
root.geometry("540x450")
root.title('LCCC Viapath Downloader')
frame = customtkinter.CTkFrame(master=root)
frame.pack(pady=1, padx=1, fill="both", expand=True)
# URL BOX
urllabel = customtkinter.CTkLabel(master=frame, text="Paste URLs:")
urllabel.pack(pady=1, padx=1)
urltextbox = customtkinter.CTkTextbox(master=frame, wrap='word', height=150, width=400)
urltextbox.pack(pady=10, padx=10)
# BUTTON
wgetbutton = customtkinter.CTkButton(master=frame, width=40, height=40, text="Get Videos", command=buttonclick)
wgetbutton.pack()
# PROGRESS BAR
progressBar = customtkinter.CTkProgressBar(master=frame, mode='determinate')
progressBar.pack(padx=10, pady=10)
progressBar.set(0)
root.mainloop()
Loading…
Cancel
Save