yasoob / youtube-dl-GUI

This repository contains code for a youtube-dl GUI written in PyQt.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Adding resume function

Zerokami opened this issue · comments

I'm trying to add resume (After close or quit or power failure) function to the app.

I've forked the repo at https://github.com/Logmytech/youtube-dl-QT

Trying to add resume. I have added resume.

But now I don't know where to add the function to remove the URL. i.e; I need to know to download completed function.

I am sorry but I am unable to understand what you want to know. Can you ask the question in a bit more detailed manner? I would love to help you out.

I want to save the ongoing/downloading links, directory, quality options in a list.

I want resume functionality of qutting the app.

i.e if the app is closed I want to resume un-finished downloads when the program is opened again.

def download_url(self, url,  row = None, by_user = True, directory = os.getcwd(), quality = False):
        if row >= 0:
            row = row
        elif row is None:
            row = self.rowcount

#My code start
        if by_user == True:
            directory = str(self.ui.saveToLineEdit.text())
            quality = False
            if self.ui.ConvertCheckBox.isChecked():
                quality = str(self.ui.ConvertComboBox.currentText())
           print row, self.rowcount
        else:
            pass
        options = {
            'url': url,
            'directory': directory,
            'rowcount': row,
            'proxy': '',
            'convert_format': quality,
            'parent':self,
        }

#My code for adding to resume list and writing to json for storage.
       opt_list.append(options)

        with f as open('links_to_resume.json', 'w'):
            json.dump(f)

        print(opt_list)
#My code end

        if not self.ui.DeleteFileCheckBox.isChecked():
            options['keep_file'] = True


        self.thread_pool['thread{}'.format(row)] = Download(options)
        self.thread_pool['thread{}'.format(row)].status_bar_signal.connect(self.ui.statusbar.showMessage)
        self.thread_pool['thread{}'.format(row)].remove_url_signal.connect(self.remove_url)
        self.thread_pool['thread{}'.format(row)].add_update_list_signal.connect(self.add_to_table)
        self.thread_pool['thread{}'.format(row)].remove_row_signal.connect(self.decrease_rowcount)
        self.thread_pool['thread{}'.format(row)].start()

        self.ui.tabWidget.setCurrentIndex(2)
        self.ui.statusbar.showMessage('Extracting information..')

        self.url_list.append(url)
        self.complete_url_list[row] = url

        self.rowcount += 1

        if len(self.url_list) is not 0:
            if len(self.url_list) < 2:
                self.ui.statusbar.showMessage('Downloading {0} file'.format(len(self.url_list)))
            else:
                self.ui.statusbar.showMessage('Downloading {0} files'.format(len(self.url_list)))
        else:
self.ui.statusbar.showMessage("done")


On boot the Youtube-DL-GUI app loads a list of dictionaries of download options like URL, Location, Qulaity.

opt_list = []
with f as open('links_to_resume.json', 'r'):
    opt_list = json.load(f)
    print(opt_list)
print(['{'url' : 'https://www.youtube.com/watch?v=U1fRcfcj5To', 'directory': '/home/use/logmytech#>/youtube', 'convert_format': '720p'}', {'url' : 'https://www.youtube.com/watch?v=_NXrTujMP50',
'location': '/home/use/logmytech/youtube', 'convert_format': '720p'}']) # prints this

def resume_links(opt_list):
    for i in opt_list:
        download_url(self, i['url'],  row = None, by_user = Flase, directory = i['directory'], quality = False) 

resume_links(opt_list)