# -*- coding: utf-8 -*-

# Form implementation generated from reading ui file 'mush_converter.ui'
#
# Created by: PyQt5 UI code generator 5.15.4
#
# WARNING: Any manual changes made to this file will be lost when pyuic5 is
# run again.  Do not edit this file unless you know what you are doing.
import os
import sys
from moviepy.editor import *
from PyQt5 import QtCore, QtGui, QtWidgets
from PyQt5.QtCore import *
from PyQt5.QtGui import *
from PyQt5.QtWidgets import *
import os
import sys
from moviepy import editor
import time



#===================================================================================================================================================

class prograssBarScreen(QMainWindow):
    def __init__(self):
        super(prograssBarScreen, self).__init__()

        self.resize(475, 225)
        self.setMaximumWidth(480)
        self.setMaximumHeight(200)
        self.setMinimumWidth(459)
        self.setMinimumHeight(200)
        self.setStyleSheet("background-color: rgb(0, 0, 80);color:white;")

        self.pushButton = QPushButton('start')
        self.pushButton.setGeometry(QtCore.QRect(170, 150, 90, 30))
        self.pushButton.setStyleSheet("background-color: rgb(0, 0, 255);color: rgb(255, 255, 255);border-radius:10px;")
        self.pushButton.setObjectName("pushButton")
        self.pushButton.move(120, 150)

        self.progressBar = QProgressBar()



    def run(self):

        self.progressBar.setGeometry(QtCore.QRect(10, 40, 470, 31))
        self.progressBar.setStyleSheet("height:0;width:0;font-size:20px")
        self.progressBar.setMinimumWidth(100)
        self.progressBar.setProperty("value", 0)
        self.progressBar.setObjectName("progressBar")


        self.text.setText('Please wait.. ')
        for i in range(self.n):
            time.sleep(0.500)
            self.progressBar.setValue(i+1)
            if i == 60:
                self.text.setText('Almost done... ')
            elif i == 85:
                self.text.setText('finalizing file... ')
            elif i == 98:
                self.text.setText('Done!')







#=====================================================================================================================================================


class Ui_window(object):
    def setupUi(self, window):
        window.setWindowIcon(QIcon('icon/titlelogo.png'))
        window.setMaximumWidth(851)
        window.setMaximumWidth(1210)
        window.setObjectName("window")
        window.resize(851, 465)
        window.setStyleSheet("background-color: rgb(0, 0, 80);")


        self.searchBox = QtWidgets.QLineEdit(window)
        self.searchBox.setGeometry(QtCore.QRect(90, 200, 621, 51))

        self.searchBox.setStyleSheet("border-radius:20px;\n"
"background-color: rgb(181, 181, 181);\n"
"padding-left:50px;\n"
"font: 75 10pt \"MS Shell Dlg 2\";")
        self.searchBox.setObjectName("searchBox")

        self.search = QtWidgets.QPushButton(window)
        self.search.setGeometry(QtCore.QRect(720, 210, 121, 41))
        self.search.setStyleSheet("border-right-color: rgb(170, 255, 255);\n"
"\n"
"font: 75 13pt \"MS Shell Dlg 2\";\n"
"border-radius:20px;\n"
"background-color:rgb(85, 170, 255);")
        self.search.setObjectName("search")
        self.search.clicked.connect(self.getFile)

        self.path = QtWidgets.QLabel(window)
        self.path.setGeometry(QtCore.QRect(20, 210, 61, 21))
        self.path.setStyleSheet("font: 75 13pt \"MS Shell Dlg 2\";\n"
"color: rgb(255, 255, 255);")
        self.path.setObjectName("path")

        self.label_2 = QtWidgets.QLabel(window)
        self.label_2.setGeometry(QtCore.QRect(160, 30, 101, 91))
        self.label_2.setStyleSheet("image:url(icon/download (2).jpg)")
        self.label_2.setText("")
        self.label_2.setObjectName("label_2")


        ''' self.progressBar = QtWidgets.QProgressBar(window)
        self.progressBar.setGeometry(QtCore.QRect(300, 360, 300, 23))
        self.progressBar.setStyleSheet("color: rgb(255, 255, 255);")
        self.progressBar.setProperty("value", 0)
        self.progressBar.setObjectName("progressBar")'''

        self.converter = QtWidgets.QPushButton(window)
        self.converter.setGeometry(QtCore.QRect(340, 290, 121, 41))
        self.converter.setStyleSheet("border-right-color: rgb(170, 255, 255);\n"
"\n"
"font: 75 13pt \"MS Shell Dlg 2\";\n"
"border-radius:20px;\n"
"background-color:rgb(85, 170, 255);")
        self.converter.setObjectName("converter")
        self.converter.clicked.connect(self.convert)


        self.label_3 = QtWidgets.QLabel(window)
        self.label_3.setGeometry(QtCore.QRect(260, 60, 371, 41))
        self.label_3.setStyleSheet("color: rgb(255, 255, 255);\n"
"font: 18pt \"Showcard Gothic\";")
        self.label_3.setObjectName("label_3")


        #self.saveFile.clicked.connect(self.Directory)
        self.label_4 = QtWidgets.QLabel(window)
        self.label_4.setGeometry(QtCore.QRect(100, 210, 31, 31))
        self.label_4.setStyleSheet("image: url(icon/download (1).jpg);")
        self.label_4.setText("")
        self.label_4.setObjectName("label_4")

        self.retranslateUi(window)
        QtCore.QMetaObject.connectSlotsByName(window)

        self.status = QtWidgets.QLabel('status:',window)
        self.status.setGeometry(QtCore.QRect(20, 210, 61, 21))
        self.status.setStyleSheet("font: 75 13pt \"MS Shell Dlg 2\";\n"
                                "color: rgb(255, 255, 255);")
        self.status.setObjectName("status")
        self.status.setGeometry(QtCore.QRect(240, 360, 50, 23))

    def retranslateUi(self, window):
        _translate = QtCore.QCoreApplication.translate
        window.setWindowTitle(_translate("window", "Mush Converter"))
        self.search.setText(_translate("window", "Search"))
        self.path.setText(_translate("window", "PATH:"))
        self.converter.setText(_translate("window", "Convert"))
        self.label_3.setText(_translate("window", "Mush Video Converter"))
        #self.status.setText(_translate("window", "Status:"))




    def getFile(self):
        file_filter = 'Video (*.mp4);;(*.mkv);;(*.webm)'
        getVideoFile = QFileDialog.getOpenFileName(
            caption ='Select a Video File',
            directory = os.getcwd(),
            filter=file_filter,
            initialFilter= 'Video (*.mp4)'
        )

        self.videoFile = getVideoFile[0]
        file = self.videoFile.split('/')
        self.show = file[-1]
        #self.searchBox.setText(self.show)

        self.file = str(self.show)


        if  '.mp4' in self.file:

            #fileGet = self.file.replace('.mp4', '.mp3')
            self.searchBox.setText(self.show)
        else :
            self.searchBox.setText('File not supported try selecting .mp4 file')





    def convert(self):
        time.sleep(0.100)
        self.saveTo = QFileDialog.getSaveFileName(
            caption='Save to',
            filter = '*.mp3',

        )
        videoPath = self.videoFile
        audio = self.saveTo[0]+'audio.mp3'
        videoClip = VideoFileClip(videoPath)
        audioClip = videoClip.audio
        audioClip.write_audiofile(audio)
        audioClip.close()
        videoClip.close()



def prograssStatus(self):
    w = prograssBarScreen()
    w.show()


if __name__ == "__main__":
    import sys
    app = QtWidgets.QApplication(sys.argv)
    window = QtWidgets.QWidget()
    ui = Ui_window()
    ui.setupUi(window)
    window.show()
    sys.exit(app.exec_())

# -*- coding: utf-8 -*-

# Form implementation generated from reading ui file 'mush_converter.ui'
#
# Created by: PyQt5 UI code generator 5.15.4
#
# WARNING: Any manual changes made to this file will be lost when pyuic5 is
# run again.  Do not edit this file unless you know what you are doing.
import os
import sys
from moviepy.editor import *
from PyQt5 import QtCore, QtGui, QtWidgets
from PyQt5.QtCore import *
from PyQt5.QtGui import *
from PyQt5.QtWidgets import *
import os
import sys
from moviepy import editor
import time



#===================================================================================================================================================

class prograssBarScreen(QMainWindow):
    def __init__(self):
        super(prograssBarScreen, self).__init__()

        self.resize(475, 225)
        self.setMaximumWidth(480)
        self.setMaximumHeight(200)
        self.setMinimumWidth(459)
        self.setMinimumHeight(200)
        self.setStyleSheet("background-color: rgb(0, 0, 80);color:white;")

        self.pushButton = QPushButton('start')
        self.pushButton.setGeometry(QtCore.QRect(170, 150, 90, 30))
        self.pushButton.setStyleSheet("background-color: rgb(0, 0, 255);color: rgb(255, 255, 255);border-radius:10px;")
        self.pushButton.setObjectName("pushButton")
        self.pushButton.move(120, 150)

        self.progressBar = QProgressBar()



    def run(self):

        self.progressBar.setGeometry(QtCore.QRect(10, 40, 470, 31))
        self.progressBar.setStyleSheet("height:0;width:0;font-size:20px")
        self.progressBar.setMinimumWidth(100)
        self.progressBar.setProperty("value", 0)
        self.progressBar.setObjectName("progressBar")


        self.text.setText('Please wait.. ')
        for i in range(self.n):
            time.sleep(0.500)
            self.progressBar.setValue(i+1)
            if i == 60:
                self.text.setText('Almost done... ')
            elif i == 85:
                self.text.setText('finalizing file... ')
            elif i == 98:
                self.text.setText('Done!')







#=====================================================================================================================================================


class Ui_window(object):
    def setupUi(self, window):
        window.setWindowIcon(QIcon('icon/titlelogo.png'))
        window.setMaximumWidth(851)
        window.setMaximumWidth(1210)
        window.setObjectName("window")
        window.resize(851, 465)
        window.setStyleSheet("background-color: rgb(0, 0, 80);")


        self.searchBox = QtWidgets.QLineEdit(window)
        self.searchBox.setGeometry(QtCore.QRect(90, 200, 621, 51))

        self.searchBox.setStyleSheet("border-radius:20px;\n"
"background-color: rgb(181, 181, 181);\n"
"padding-left:50px;\n"
"font: 75 10pt \"MS Shell Dlg 2\";")
        self.searchBox.setObjectName("searchBox")

        self.search = QtWidgets.QPushButton(window)
        self.search.setGeometry(QtCore.QRect(720, 210, 121, 41))
        self.search.setStyleSheet("border-right-color: rgb(170, 255, 255);\n"
"\n"
"font: 75 13pt \"MS Shell Dlg 2\";\n"
"border-radius:20px;\n"
"background-color:rgb(85, 170, 255);")
        self.search.setObjectName("search")
        self.search.clicked.connect(self.getFile)

        self.path = QtWidgets.QLabel(window)
        self.path.setGeometry(QtCore.QRect(20, 210, 61, 21))
        self.path.setStyleSheet("font: 75 13pt \"MS Shell Dlg 2\";\n"
"color: rgb(255, 255, 255);")
        self.path.setObjectName("path")

        self.label_2 = QtWidgets.QLabel(window)
        self.label_2.setGeometry(QtCore.QRect(160, 30, 101, 91))
        self.label_2.setStyleSheet("image:url(icon/download (2).jpg)")
        self.label_2.setText("")
        self.label_2.setObjectName("label_2")


        ''' self.progressBar = QtWidgets.QProgressBar(window)
        self.progressBar.setGeometry(QtCore.QRect(300, 360, 300, 23))
        self.progressBar.setStyleSheet("color: rgb(255, 255, 255);")
        self.progressBar.setProperty("value", 0)
        self.progressBar.setObjectName("progressBar")'''

        self.converter = QtWidgets.QPushButton(window)
        self.converter.setGeometry(QtCore.QRect(340, 290, 121, 41))
        self.converter.setStyleSheet("border-right-color: rgb(170, 255, 255);\n"
"\n"
"font: 75 13pt \"MS Shell Dlg 2\";\n"
"border-radius:20px;\n"
"background-color:rgb(85, 170, 255);")
        self.converter.setObjectName("converter")
        self.converter.clicked.connect(self.convert)


        self.label_3 = QtWidgets.QLabel(window)
        self.label_3.setGeometry(QtCore.QRect(260, 60, 371, 41))
        self.label_3.setStyleSheet("color: rgb(255, 255, 255);\n"
"font: 18pt \"Showcard Gothic\";")
        self.label_3.setObjectName("label_3")


        #self.saveFile.clicked.connect(self.Directory)
        self.label_4 = QtWidgets.QLabel(window)
        self.label_4.setGeometry(QtCore.QRect(100, 210, 31, 31))
        self.label_4.setStyleSheet("image: url(icon/download (1).jpg);")
        self.label_4.setText("")
        self.label_4.setObjectName("label_4")

        self.retranslateUi(window)
        QtCore.QMetaObject.connectSlotsByName(window)

        self.status = QtWidgets.QLabel('status:',window)
        self.status.setGeometry(QtCore.QRect(20, 210, 61, 21))
        self.status.setStyleSheet("font: 75 13pt \"MS Shell Dlg 2\";\n"
                                "color: rgb(255, 255, 255);")
        self.status.setObjectName("status")
        self.status.setGeometry(QtCore.QRect(240, 360, 50, 23))

    def retranslateUi(self, window):
        _translate = QtCore.QCoreApplication.translate
        window.setWindowTitle(_translate("window", "Mush Converter"))
        self.search.setText(_translate("window", "Search"))
        self.path.setText(_translate("window", "PATH:"))
        self.converter.setText(_translate("window", "Convert"))
        self.label_3.setText(_translate("window", "Mush Video Converter"))
        #self.status.setText(_translate("window", "Status:"))




    def getFile(self):
        file_filter = 'Video (*.mp4);;(*.mkv);;(*.webm)'
        getVideoFile = QFileDialog.getOpenFileName(
            caption ='Select a Video File',
            directory = os.getcwd(),
            filter=file_filter,
            initialFilter= 'Video (*.mp4)'
        )

        self.videoFile = getVideoFile[0]
        file = self.videoFile.split('/')
        self.show = file[-1]
        #self.searchBox.setText(self.show)

        self.file = str(self.show)


        if  '.mp4' in self.file:

            #fileGet = self.file.replace('.mp4', '.mp3')
            self.searchBox.setText(self.show)
        else :
            self.searchBox.setText('File not supported try selecting .mp4 file')





    def convert(self):
        time.sleep(0.100)
        self.saveTo = QFileDialog.getSaveFileName(
            caption='Save to',
            filter = '*.mp3',

        )
        videoPath = self.videoFile
        audio = self.saveTo[0]+'audio.mp3'
        videoClip = VideoFileClip(videoPath)
        audioClip = videoClip.audio
        audioClip.write_audiofile(audio)
        audioClip.close()
        videoClip.close()



def prograssStatus(self):
    w = prograssBarScreen()
    w.show()


if __name__ == "__main__":
    import sys
    app = QtWidgets.QApplication(sys.argv)
    window = QtWidgets.QWidget()
    ui = Ui_window()
    ui.setupUi(window)
    window.show()
    sys.exit(app.exec_())

# -*- coding: utf-8 -*- # Form implementation generated from reading ui file 'mush_converter.ui' # # Created by: PyQt5 UI code generator 5.15.4 # # WARNING: Any manual changes made to this file will be lost when pyuic5 is # run again.  Do not edit this file unless you know what you are doing. #=================================================================================================================================================== #===================================================================================================================================================== self.progressBar = QtWidgets.QProgressBar(window)
         self.progressBar.setGeometry(QtCore.QRect(300, 360, 300, 23))
         self.progressBar.setStyleSheet("color: rgb(255, 255, 255);")
         self.progressBar.setProperty("value", 0)
         self.progressBar.setObjectName("progressBar") #self.saveFile.clicked.connect(self.Directory) #self.status.setText(_translate("window", "Status:")) #self.searchBox.setText(self.show) #fileGet = self.file.replace('.mp4', '.mp3')