Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding resume function #2

Open
Zerokami opened this issue Jun 4, 2016 · 2 comments
Open

Adding resume function #2

Zerokami opened this issue Jun 4, 2016 · 2 comments

Comments

@Zerokami
Copy link

Zerokami commented Jun 4, 2016

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.

@yasoob
Copy link
Owner

yasoob commented Jun 6, 2016

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.

@Zerokami
Copy link
Author

Zerokami commented Jun 15, 2016

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)



Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants