Пример #1
0
def validate_output(path, vid_name, one_video=True):
    fullpath = vid_name

    if os.path.exists(path):
        # path can exist and be a file or a directory
        if os.path.isdir(path):
            fullpath = os.path.join(path, vid_name)
        elif one_video:  # file already exists and it's only one file
            fullpath = get_new_file(path, vid_name)
        else:  # if there are many videos, get the path, forget the name
            fullpath = os.path.split(path)[0]

    else:  # if it's the path to a non-existant file

        if os.path.exists(os.path.split(path)[0]):
            # if the path to the file exists and the file doesn't
            # it means it's a valid path
            if one_video:
                # if only one video, copy all the path
                fullpath = path
            else:
                # if more than one video, get the path, forget the name
                fullpath = os.path.split(path)[0]

    return fullpath
Пример #2
0
    def __init__(self, name="", url="", dl_url="", down=True, folder=c.HOME_FOLDER, after_dl=0,
                 overwrite=False):
        self._name = name
        self.url = url
        self.dl_url = dl_url
        self.down = down
        self._folder = folder
        self.after_complete = after_dl
        self.m_description = ""
        self.m_published = ""
        self.thumbnail = ""
        self.tree_widget_item = None

        if self._name:
          if overwrite is False:
              self.filepath = main.get_new_file(self._folder, self._name)
              self._name = os.path.split(self.filepath)[1]
          else:
              self.filepath = os.path.join(self._folder, self._name)
Пример #3
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)
Пример #4
0
 def copyAfterComplete(self, path, name):
     new_dest = get_new_file(path, name)
     if self.completed:
         shutil.copy(self.dest_file, new_dest)
     else:
         self.new_path = new_dest
Пример #5
0
 def setTitle(self, title):
     self._name = title
     self.filepath = main.get_new_file(tempfile.gettempdir(), self._name)
Пример #6
0
 def setName(self, name):
     self._name = name
     self.filepath = main.get_new_file(self._folder, self._name)
Пример #7
0
 def setFolder(self, folder):
     self._folder = folder
     self.filepath = main.get_new_file(self._folder, self._name)