Exemplo n.º 1
0
 def add(self):
     if not os.path.exists(self.ui.ledit_destFolder.text()):
         gui_utils.warning(self, title=self.tr("Warning"), 
         msg=self.tr("The given download folder doesn't exist!"))
         return
         
     download = self.ui.rb_download.isChecked()
     dest_folder = self.ui.ledit_destFolder.text()
     after_dl = self.ui.combo_options.currentIndex()
     videos = []
     
     for i in xrange(self.ui.tree_validLinks.topLevelItemCount()):
         item = self.ui.tree_validLinks.topLevelItem(i)
         
         if item.checkState(0):
             combobox = self.ui.tree_validLinks.itemWidget(item, 1)
             medium = item.getMedium()
             format = self.mediums[medium][combobox.currentIndex()]
             name = item.text(0)
             overwrite = True
             
             
             if main.file_exists(dest_folder, name):
                 answer = gui_utils.confirm(self, title=self.tr("Overwrite"),
                 msg=self.tr("Do you wish to overwrite this file?") + '\n' + name)
                 
                 if answer == QtGui.QMessageBox.No:
                     filepath = main.get_new_file(dest_folder, name)
                     name = os.path.split(filepath)[1]
                     overwrite = False
             
             videos.append(VideoInfo(name, medium.url, format.url,
             download, dest_folder, after_dl, overwrite))
             
     if not videos or self.ui.tree_validLinks.topLevelItemCount() == 0:
         gui_utils.warning(self, msg=self.tr("There are no valid links to add!"))
     else:
         self.close()
         self.parent.addNewDownloads(videos)
Exemplo n.º 2
0
    def saveSettings(self):
        """Saves the settings."""
        
        try:
            self.settings.media_player = self.ui.ledit_player.text()
        except ValueError:
            gui_utils.warning(self, self.tr("Media Player"), self.tr("Given media player is not valid"))
            return 0
        
        self.settings.use_builtin_player = self.ui.cb_builtinPlayer.checkState()
        self.settings.download_folder = self.ui.edit_folder.text()
        self.settings.after_download = self.ui.combo_options.currentIndex()
        self.settings.play_downloaded = self.ui.combo_dc.currentIndex()
        if self.ui.cb_applyToAll.isChecked():
            if self.ui.rb_all_ask.isChecked():
                self.settings.global_video_quality = "ask"
            elif self.ui.rb_all_low_quality.isChecked():
                self.settings.global_video_quality = "low"
            elif self.ui.rb_all_high_quality.isChecked():
                self.settings.global_video_quality = "high"
        elif self.settings.global_video_quality:
            self.settings.remove("global_video_quality")

        for i in range(self.ui.tree_quality.topLevelItemCount()):
            item = self.ui.tree_quality.topLevelItem(i)
            cb = self.ui.tree_quality.itemWidget(item, 1)
            self.settings.set_quality(item.text(0), cb.currentIndex())

        self.settings.notify_done = self.ui.s_notifyDone.checkState()
        self.settings.notify_error = self.ui.s_notifyError.checkState()
        self.settings.check_links_auto = self.ui.cb_checkLinksAuto.checkState()
        
        self.settings.sync()
        
        if self.settings.global_quality != self.parent.global_quality:
          self.parent.switchQuality(next=False)

        self.close()