<commit_before>from gui import Ui_MainWindow
from PyQt4 import QtGui
from PyQt4 import QtCore
import sys
import youtube_dl
import os
import time 

class MainWindow(QtGui.QMainWindow):
    def __init__(self, parent=None):
        QtGui.QMainWindow.__init__(self, parent)
        self.ui = Ui_MainWindow()
        self.ui.setupUi(self)
        self.ui.label.setPixmap(QtGui.QPixmap(os.getcwd() + "/logo.png"))
        self.ui.pushButton.clicked.connect(self.handleButton)
        self.ui.lineEdit_2.setText(os.getcwd())
        self.ui.lineEdit_2.textEdited.connect(self.set_dest)

        self.setWindowTitle('youtube-dl v0.1')
        self.show()


    def set_dest(self):
        file = str(QtGui.QFileDialog.getExistingDirectory(self, "Select Directory"))
        self.ui.lineEdit_2.setText(file)
    
    def handleButton(self):
        url = str(self.ui.lineEdit.text())
        if url is '':
            QtGui.QMessageBox.information(self,"Error!","No url given!")
        
        directory = str(self.ui.lineEdit_2.text())
        self.down_thread = Download(url,directory)
        self.down_thread.statusSignal.connect(self.ui.statusbar.showMessage)
        self.down_thread.p_barSignal.connect(self.change_progress)
        self.down_thread.start()

    def change_progress(self,e):
        self.ui.progressBar.setValue(int(e))

class Download(QtCore.QThread):
    statusSignal = QtCore.pyqtSignal(QtCore.QString)
    p_barSignal = QtCore.pyqtSignal(QtCore.QString)

    def __init__(self,url,directory):
        super(Download,self).__init__()
        self.url = url
        self.directory = directory
        if self.directory is not '':
            self.directory = directory + '/'

    def hook(self, li):
        if li.get('downloaded_bytes') is not None:
            self.p_barSignal.emit(str(int((float(li.get('downloaded_bytes')) / float(li.get('total_bytes')))*100.0)))
        else:
            self.statusSignal.emit('Already Downloaded')
            time.sleep(10)
            return
        if li.get('eta') is not None:
            self.statusSignal.emit(self.format_seconds(li.get('eta')))

    def download(self):
        ydl_options = {
            'outtmpl': '{0}%(title)s-%(id)s.%(ext)s'.format(self.directory),
            'continuedl': True,
            'quiet' : True,<commit_msg>connected exit filemenu and added filename show in status bar while downloading<commit_after>from gui import Ui_MainWindow
from PyQt4 import QtGui
from PyQt4 import QtCore
import sys
import youtube_dl
import os
import time 

class MainWindow(QtGui.QMainWindow):
    def __init__(self, parent=None):
        QtGui.QMainWindow.__init__(self, parent)
        self.ui = Ui_MainWindow()
        self.ui.setupUi(self)
        self.ui.label.setPixmap(QtGui.QPixmap(os.getcwd() + "/logo.png"))
        self.ui.pushButton.clicked.connect(self.handleButton)
        self.ui.lineEdit_2.setText(os.getcwd())
        self.ui.lineEdit_2.textEdited.connect(self.set_dest)

        self.connect_menu_action()
        self.setWindowTitle('youtube-dl v0.1')
        self.show()


    def set_dest(self):
        file = str(QtGui.QFileDialog.getExistingDirectory(self, "Select Directory"))
        self.ui.lineEdit_2.setText(file)
    
    def handleButton(self):
        url = str(self.ui.lineEdit.text())
        if url is '':
            QtGui.QMessageBox.information(self,"Error!","No url given!")
        
        directory = str(self.ui.lineEdit_2.text())
        self.down_thread = Download(url,directory)
        self.down_thread.statusSignal.connect(self.ui.statusbar.showMessage)
        self.down_thread.p_barSignal.connect(self.change_progress)
        self.down_thread.start()

    def change_progress(self,e):
        self.ui.progressBar.setValue(int(e))

    def connect_menu_action(self):
        self.ui.actionExit.triggered.connect(QtGui.qApp.quit)

class Download(QtCore.QThread):
    statusSignal = QtCore.pyqtSignal(QtCore.QString)
    p_barSignal = QtCore.pyqtSignal(QtCore.QString)

    def __init__(self,url,directory):
        super(Download,self).__init__()
        self.url = url
        self.directory = directory
        if self.directory is not '':
            self.directory = directory + '/'

    def hook(self, li):
        if li.get('downloaded_bytes') is not None:
            self.p_barSignal.emit(str(int((float(li.get('downloaded_bytes')) / float(li.get('total_bytes')))*100.0)))
        else:
            self.statusSignal.emit('Already Downloaded')
            time.sleep(10)
            return
        if li.get('eta') is not None:
            filename = li.get('filename').split('/')[-1][:13]+'..'
            self.statusSignal.emit('Downloading '+filename+' : '+self.format_seconds(li.get('eta')))

    def download(self):
        ydl_options = {
            'outtmpl': '{0}%(title)s-%(id)s.%(ext)s'.format(self.directory),
            'continuedl': True,
            'quiet' : True,
{'fraction_non_alphanumeric': 0.1307442049613664, 'fraction_numerical': 0.0067100447336315575, 'mean_word_length': 2.772239263803681, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 16, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '838394', 'n_tokens_mistral': 1607, 'n_tokens_neox': 1561, 'n_words': 246}