def import_podcasts(self, args): log.debug('import_podcasts(filter=%s, input_path=%s)' % (args.filter, args.path)) with get_fh_or(sys.stdin, args.path, 'r') as f: data = json.load(f) for podcast_dict in data: try: p = Podcast.from_dict(podcast_dict) log.debug('import_podcasts: examining: %s' % p.title) path = self.get_podcast_path(p) if os.path.exists(path): raise(Exception('already exists: %s for %s' % (path, p.title))) p.path = path if p.matches_filter(args.filter): log.debug('import_podcasts: Podcast matches filter, saving... %s' % p.title) p.save() except Exception as e: log.warning('import_podcasts: exception while importing podcast: %s' % e)
def has_status(self, s): if s not in ['new', 'skipped', 'downloaded', 'listened', 'any']: log.warning('unknown status: %s' % s) status = self.status() return(s == status or s == 'any')