Advertisement
Guest User

Untitled

a guest
Mar 24th, 2017
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 12.36 KB | None | 0 0
  1. from tkinter import ttk
  2. from tkinter import filedialog
  3. import os
  4. import shutil
  5. import time
  6. import tkinter.scrolledtext
  7. from tkinter import *
  8. import tkinter.scrolledtext as ScrolledText
  9. from pathlib import Path
  10. import glob
  11.  
  12. GUI = Tk()
  13. bname = StringVar()
  14. mpls = StringVar()
  15. playlist = StringVar()
  16. gtag = StringVar()
  17. msub = StringVar()
  18. mvtid = StringVar()
  19. matid = StringVar()
  20. comm1 = StringVar()
  21. comm2 = StringVar()
  22. comm3 = StringVar()
  23. commnum1 = StringVar()
  24. commnum2 = StringVar()
  25. commnum3 = StringVar()
  26. commnum4 = StringVar()
  27. rmpls = StringVar()
  28.  
  29. path2 = "D:\HEVC.Encoder.1.0\Tools\Eac3to\eac3to.exe"
  30. path3 = "D:\HEVC.Encoder.1.0\Tools\MKV_Tools\mkvmerge.exe"
  31.  
  32. def combine_funcs(*funcs):
  33.     def combined_func(*args, **kwargs):
  34.         for f in funcs:
  35.             f(*args, **kwargs)
  36.     return combined_func
  37.  
  38. def fdopenfol():
  39.     import tkinter as tk
  40.     from tkinter import ttk
  41.     blu = bname.get()
  42.     dirname = filedialog.askdirectory(parent=GUI,initialdir="/",title='Please select a File')
  43.     mplayq = ("\""+str(dirname)+"\"")
  44.     tmp = os.popen("D:\HEVC.Encoder.1.0\Tools\Eac3to\eac3to.exe -log=\"filename.txt\" "+str(mplayq)+"")
  45.     time.sleep(5)
  46.     lines = open('filename.txt').readlines()  
  47.     open(''+str(blu)+'.txt', 'w').writelines(lines[3:])
  48.     readd = open(''+str(blu)+'.txt')
  49.     rread = readd.read()
  50.     readd.close()
  51.     #time.sleep(1)
  52.     Label(GUI, text = "Eac3to Results", font = "underline", bg='Light gray').place(x=600,y=5)
  53.     Label(GUI, bg='White', width=53, height=30, borderwidth=4, relief="ridge").place(x=486,y=30)
  54.     st = ScrolledText.ScrolledText(GUI, bg='White', width=50, height=30, font = "Helvetica 9")
  55.     Label(GUI, text = "1", bg='Light gray').place(x=475,y=45)
  56.     st.pack()
  57.     st.place(x=488,y=30)
  58.     st.insert(INSERT, rread)
  59.     e2.delete(0,END)
  60.     e2.insert(0, dirname)
  61.     time.sleep(1)
  62.     filelist = glob.glob("*.txt")
  63.     for f in filelist:
  64.         os.remove(f)
  65.    
  66.    
  67. def deltxt():
  68.     blu = bname.get()
  69.     os.remove('filename.txt')
  70.     os.remove(''+str(blu)+'.txt')
  71.  
  72. def output():
  73.     mplay = mpls.get()
  74.     mpsub = msub.get()
  75.     mplay = mpls.get()
  76.     play = playlist.get()
  77.     blu = bname.get()
  78.     gt = gtag.get()
  79.     Reln = blu.replace(" ", ".")
  80.     mplayq = ("\""+str(mplay)+"\"")
  81.     #print(mplayq)
  82.     #dirname = filedialog.askdirectory(parent=GUI,initialdir="/",title='Please Select Output Folder')
  83.     #status = Label(GUI,text = "Demuxing Title.......%", bg='Light gray').place(x=50,y=400)
  84.     os.system(""+str(path2)+" "+str(mplayq)+" "+str(play)+") -demux -log=\""+str(Reln)+" - Eac3to Logfile.txt\"")
  85.     #status = Label(GUI,text = "Demuxing Title.......Complete", bg='Light gray').place(x=50,y=400)
  86.     #status = Label(GUI,text = "Processing Subtitles.......%", bg='Light gray').place(x=50,y=425)
  87.     os.system(""+str(path3)+" " "--ui-language en --output subs.mks --no-global-tags --no-track-tags --no-audio --no-video --no-chapters --no-attachments --default-track 0:no --default-track 1:no --default-track 2:no --default-track 3:no --default-track 4:no --default-track 5:no --default-track 6:no --default-track 7:no --default-track 8:no --default-track 9:no  --default-track 10:no --default-track 11:no --default-track 12:no --default-track 13:no --default-track 14:no --default-track 15:no --default-track 16:no  --default-track 17:no --default-track 18:no --default-track 19:no --default-track 20:no --default-track 21:no --default-track 22:no --default-track 23:no --default-track 24:no --default-track 25:no --default-track 26:no --default-track 27:no --default-track 28:no  --default-track 29:no --default-track 30:no " ""+str(mplayq)+"\BDMV\PLAYLIST\\"+str(mpsub)+".mpls")
  88.     #status = Label(GUI,text = "Processing Subtitles.......Complete", bg='Light gray').place(x=50,y=425)
  89.     #status = Label(GUI,text = "Remuxing Title.......%", bg='Light gray').place(x=50,y=450)
  90.     #status = Label(GUI,text = "Remuxing Title.......Complete", bg='Light gray').place(x=50,y=450)
  91.     #video Vars
  92.     for file_path2 in Path('').glob('**/*English, 5.1*.ac3'):
  93.         my_file = Path(file_path2)
  94.         if my_file.is_file():
  95.             acodec = ("DD")
  96.     for file_path1 in Path('').glob('**/*German*.dtsma'):
  97.         os.remove(''+str(file_path1)+'')
  98.     for file_path2 in Path('').glob('**/*English*.dtsma'):
  99.         my_file = Path(file_path2)
  100.         if my_file.is_file():
  101.             acodec = ("DTS-HD.MA")
  102.             file_path2 = file_path2
  103.     for file_path2 in Path('').glob('**/*Atmos*.thd+ac3'):
  104.         my_file = Path(file_path2)
  105.         if my_file.is_file():
  106.             acodec = ("Atmos.TrueHD")
  107.             #achan = ("7.1")
  108.         for file_path1 in Path('').glob('**/*English*.dtsma'):
  109.             os.remove(''+str(file_path1)+'')
  110.     for file_path3 in Path('').glob('**/*.h264'):
  111.         if my_file.is_file():
  112.             vcodec = ("AVC")
  113.             file_path3 = file_path3
  114.     for file_path3 in Path('').glob('**/*.vc1'):
  115.         if my_file.is_file():
  116.             vcodec = ("VC-1")
  117.             file_path3 = file_path3
  118.     for file_path4 in Path('').glob('**/*Chapters*.txt'):
  119.         print(file_path4)
  120.     for file_path6 in Path('').glob('**/*English*.dts'):
  121.         os.remove(''+str(file_path6)+'')
  122.     for file_path3 in Path('').glob('**/*.m2v'):
  123.         if my_file.is_file():
  124.             vcodec = ("MPEG-2")
  125.             file_path3 = file_path3
  126.     #audio Vars
  127.     for file_path10 in Path('').glob('**/*5.1*.ac3'):
  128.         my_file = Path(file_path10)
  129.         if my_file.is_file():
  130.             achan = ("5.1")
  131.     for file_path8 in Path('').glob('**/*5.1*.dtsma'):
  132.         my_file = Path(file_path8)
  133.         if my_file.is_file():
  134.             achan = ("5.1")
  135.     for file_path8 in Path('').glob('**/*7.1*.thd+ac3'):
  136.         my_file = Path(file_path8)
  137.         if my_file.is_file():
  138.             achan = ("7.1")
  139.     #rem Auto Track Tagging        
  140.     if vcodec == "MPEG-2":
  141.         for file_path9 in Path('').glob('**/*1080p24*.m2v'):
  142.             fps = "23.976"
  143.         e5.insert(0, ""+str(vcodec)+"" " Video / Biterate PH / 1080p / """+str(fps)+""" / 16:9""")
  144.     if vcodec == "VC-1":
  145.         e5.insert(0, ""+str(vcodec)+"" " Video / Biterate PH / 1080p / """+str(fps)+""" / 16:9 / Profile PH""")
  146.     if vcodec == "AVC":
  147.         for file_path9 in Path('').glob('**/*1080p24*.h264'):
  148.             fps = "23.976"
  149.         e5.insert(0, "MPEG-4 " ""+str(vcodec)+"" " Video / Biterate PH / 1080p / """+str(fps)+""" / 16:9 / Profile PH""")
  150.     if acodec == "DTS-HD.MA":
  151.         for file_path9 in Path('').glob('**/*48kHz*.dtsma'):
  152.             khz = "48kHz"
  153.         for file_path10 in Path('').glob('**/*24*.dtsma'):
  154.             abit = "24 bits"
  155.         for file_path10 in Path('').glob('**/*16*.dtsma'):
  156.             abit = "16 bits"
  157.         e6.insert(0, "DTS-HD Master Audio / "" / """+str(achan)+""" / """+str(khz)+""" / """+str(abit)+"")
  158.     vtrack = ("\""+str(file_path3)+"\"")
  159.     mtaudio = ("\""+str(file_path2)+"\"")
  160.     chapters = ("\""+str(file_path4)+"\"")
  161.     Label(GUI, text = " ", bg='Light gray').place(x=475,y=45)
  162.     Label(GUI, bg='White', width=50, height=30, borderwidth=4, relief="ridge").place(x=486,y=30)
  163.     ScrolledText.ScrolledText(GUI, bg='White', width=50, height=30, font = "Helvetica 9")
  164.     Label(GUI, text = "Source Files", bg='white', font = "Times 12").place(x=625,y=45)
  165.     Label(GUI, text = "Video", bg='Light gray', font = "Times 8").place(x=500,y=90)
  166.     Label(GUI, text = ""+str(vcodec)+"", bg='Light gray', font = "Times 8").place(x=530,y=90)
  167.     Label(GUI, text = ""+str(vtrack)+"", bg='white', font = "Times 7").place(x=500,y=110)
  168.     Label(GUI, text = "Audio", bg='Light gray', font = "Times 8").place(x=500,y=130)
  169.     Label(GUI, text = ""+str(achan)+"", bg='Light gray', font = "Times 8").place(x=530,y=130)
  170.     Label(GUI, text = ""+str(acodec)+"", bg='Light gray', font = "Times 8").place(x=545,y=130)
  171.     Label(GUI, text = ""+str(mtaudio)+"", bg='White', font = "Times 7").place(x=500,y=150)
  172.     Label(GUI, text = "Chapters", bg='Light gray', font = "Times 8").place(x=500,y=165)
  173.     Label(GUI, text = ""+str(chapters)+"", bg='white', font = "Times 7").place(x=500,y=180)
  174.     Label(GUI, text = "Subtitles", bg='Light gray', font = "Times 8").place(x=500,y=200)
  175.     Label(GUI, text = "Subs.mks", bg='white', font = "Times 7").place(x=500,y=220)
  176.    
  177.    
  178.  
  179. def rmpls():
  180.     gt = gtag.get()
  181.     Reln = blu.replace(" ", ".")
  182.     #vtrack = ("\""+str(file_path3)+"\"")
  183.     #mtaudio = ("\""+str(file_path2)+"\"")
  184.     #chapters = ("\""+str(file_path4)+"\"")
  185.     outname = ("\""+str(Reln)+"\".1080p.BluRay.REMUX."+str(vcodec)+"""."""+str(acodec)+""+str(achan)+"-"+str(gt)+"")
  186.     #print(""+str(path3)+" -o "+str(outname)+".mkv --track-name 0:Video "+str(vtrack)+" --language 0:\"English\" "+str(mtaudio)+"  --track-order 0:0,1:0 --chapter-language eng --chapters "+str(chapters)+"")
  187.     os.system(""+str(path3)+" -o "+str(outname)+".mkv --track-name 0:Hevc "+str(vtrack)+" --language 0:\"English\" "+str(mtaudio)+"  --track-order 0:0,1:0 --chapter-language eng --chapters "+str(chapters)+" subs.mks")
  188.     os.remove(""+str(file_path2)+"")
  189.     os.remove(""+str(file_path3)+"")
  190.     os.remove(""+str(file_path4)+"")
  191.     os.remove("subs.mks")
  192.     filelist = glob.glob("*.ac3")
  193.     for f in filelist:
  194.         os.remove(f)
  195.     filelist2 = glob.glob("*.sup")
  196.     for f in filelist2:
  197.         os.remove(f)
  198.     filelist3 = glob.glob("*.dts")
  199.     for f in filelist3:
  200.         os.remove(f)
  201.     filelist4 = glob.glob("*.dtsma")
  202.     for f in filelist4:
  203.         os.remove(f)
  204.  
  205. def pmpls():
  206.     mplay = mpls.get()
  207.     mpsub = msub.get()
  208.     print(""+str(mplay)+"\BDMV\PLAYLIST\\"+str(mpsub)+".mpls")
  209.     os.popen(""+str(mplay)+"\BDMV\PLAYLIST\\"+str(mpsub)+".mpls")
  210.    
  211.      
  212.  
  213.  
  214.  
  215. GUI.geometry('860x485+200+200')
  216. GUI.title('PHD Eac3to Remux GUI')
  217. GUI.iconbitmap('addons/privatehd-favicon.ico')
  218. e1 = Entry(GUI, textvariable=bname, bg='White', width=35, font = "Helvetica 8 italic")
  219. e1.insert(0,"Enter Bluray Title Here S#E# \"Year\"")
  220. e1.place(x=1,y=1)
  221. e2 = Entry(GUI, textvariable=mpls, bg='White', width=75, font = "Helvetica 8 italic")
  222. e2.insert(0,"Source Destination")
  223. e2.place(x=1,y=55)
  224. e3 = Entry(GUI, textvariable=gtag, bg='White', width=15, font = "Helvetica 8 italic")
  225. e3.insert(0,"Group Tag")
  226. e3.place(x=225,y=1)
  227. e4 = Entry(GUI, textvariable=msub, bg='White', width=15, font = "Helvetica 8 italic")
  228. e4.insert(0,"MPLS #")
  229. e4.place(x=50,y=84)
  230. e5 = Entry(GUI, textvariable=mvtid, bg='White', width=65, font = "Helvetica 8 italic")
  231. e5.place(x=75,y=165)
  232. e6 = Entry(GUI, textvariable=matid, bg='White', width=65, font = "Helvetica 8 italic")
  233. e6.place(x=75,y=200)
  234. e7 = Entry(GUI, textvariable=comm1, bg='White', width=65, font = "Helvetica 8 italic")
  235. e7.place(x=75,y=230)
  236. e8 = Entry(GUI, textvariable=comm2, bg='White', width=65, font = "Helvetica 8 italic")
  237. e8.place(x=75,y=265)
  238. e9 = Entry(GUI, textvariable=comm3, bg='White', width=65, font = "Helvetica 8 italic")
  239. e9.place(x=75,y=300)
  240. but4 = Button(GUI, text = "1. Open Blu-Ray Folder",command=combine_funcs(fdopenfol)).place(x=1,y=25)
  241. but5 = Button(GUI, text = "2. Demux Playlist",command=combine_funcs(output, deltxt)).place(x=150,y=80)
  242. but6 = Button(GUI, text = "Play MPLS",command=pmpls).place(x=255,y=80)
  243. but7 = Button(GUI, text = "3. Remux MKV",command=rmpls).place(x=325,y=80)
  244. Label(GUI,text="Assing Tracks as Commentary", bg='Light gray').place(x=0,y=115)
  245. spinbox2 = Spinbox(GUI,textvariable=commnum1,width=4, bg="White", values=(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10)).place(x=175,y=115)
  246. spinbox3 = Spinbox(GUI,textvariable=commnum2,width=4, bg="White", values=(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10)).place(x=225,y=115)
  247. spinbox4 = Spinbox(GUI,textvariable=commnum3,width=4, bg="White", values=(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10)).place(x=275,y=115)
  248. spinbox5 = Spinbox(GUI,textvariable=commnum4,width=4, bg="White", values=(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10)).place(x=325,y=115)
  249. Label(GUI,text="Track Tagging", bg='Light gray').place(x=225,y=135)
  250. Label(GUI,text="Video", bg='Light gray').place(x=15,y=165)
  251. Label(GUI,text="Main Audio", bg='Light gray').place(x=0,y=200)
  252. Label(GUI,text="Comm. 1", bg='Light gray').place(x=5,y=230)
  253. Label(GUI,text="Comm. 2", bg='Light gray').place(x=5,y=265)
  254. Label(GUI,text="Comm. 3", bg='Light gray').place(x=5,y=300)
  255.  
  256. spinbox1 = Spinbox(GUI,textvariable=playlist,width=4, bg="White", values=(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)).place(x=5,y=85)
  257. frame = Frame(GUI)
  258. GUI.configure(bg='Light gray')
  259. frame.pack()
  260. GUI = mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement