def get_storage_dir(self, media, filename): if self._style == BYDATE: return os.path.join(self._media_dir, utils.get_dated_dir(), filename) elif self._style == BYNAME: return os.path.join(self._media_dir, utils.make_pathsafe(media['feedname']), filename) else: logging.error("Bad storage style (not 0 or 1): %i" % self._style) assert False
def show_downloads(self): if self._style==BYDATE: url = "file://"+self._media_dir+"/"+utils.get_dated_dir() else: url = "file://"+self._media_dir if HAS_GNOME: gnome.url_show(url) else: import webbrowser webbrowser.open_new_tab(url)
def show_downloads(self): if self._style == BYDATE: url = "file://" + self._media_dir + "/" + utils.get_dated_dir() else: url = "file://" + self._media_dir if HAS_GNOME: gnome.url_show(url) else: import webbrowser webbrowser.open_new_tab(url)
def _chooseFile(self, default, size, saveas, dir): self.total_size = size dated_dir = utils.get_dated_dir() change = 0 if self.media["size"] != self.total_size: self.media["size"] = self.total_size change = 1 if self.media["file"] != os.path.join(self._media_dir, dated_dir, str(default)): self.media["file"] = os.path.join(self._media_dir, dated_dir, str(default)) change = 1 if change: db = ptvDB.ptvDB() db.set_media_filename(self.media["media_id"], self.media["file"]) db.set_media_size(self.media["media_id"], self.media["size"]) db.finish() del db return os.path.join(self._media_dir, dated_dir, str(default))
def generate_playlist(self): if utils.RUNNING_SUGAR: return if self._style == BYDATE: import glob dated_dir = utils.get_dated_dir() try: os.stat(os.path.join(self._media_dir, dated_dir)) except: os.mkdir(os.path.join(self._media_dir, dated_dir)) f = open(os.path.join(self._media_dir, dated_dir, "playlist.m3u"),'w') f.write('#EXTM3U\n') for item in glob.glob(os.path.join(self._media_dir, dated_dir, "*")): filename = os.path.split(item)[1] if filename != "playlist.m3u": f.write(filename+"\n") f.close()
def _chooseFile(self, default, size, saveas, dir): self.total_size = size dated_dir = utils.get_dated_dir() change = 0 if self.media['size'] != self.total_size: self.media['size'] = self.total_size change = 1 if self.media['file'] != os.path.join(self._media_dir, dated_dir, str(default)): self.media['file'] = os.path.join(self._media_dir, dated_dir, str(default)) change = 1 if change: db = ptvDB.ptvDB() db.set_media_filename(self.media['media_id'], self.media['file']) db.set_media_size(self.media['media_id'], self.media['size']) db.finish() del db return os.path.join(self._media_dir, dated_dir, str(default))
def generate_playlist(self): if utils.RUNNING_SUGAR: return if self._style == BYDATE: import glob dated_dir = utils.get_dated_dir() try: os.stat(os.path.join(self._media_dir, dated_dir)) except: os.mkdir(os.path.join(self._media_dir, dated_dir)) f = open(os.path.join(self._media_dir, dated_dir, "playlist.m3u"), 'w') f.write('#EXTM3U\n') for item in glob.glob(os.path.join(self._media_dir, dated_dir, "*")): filename = os.path.split(item)[1] if filename != "playlist.m3u": f.write(filename + "\n") f.close()