Esempio n. 1
0
for arg in files:
    title = ''
    if 'http' in arg:
        if '.mp3' in arg:
            filename, title = download_base_file(arg, podcast.folder)
            description = ''
        else:
            filename, title, description = download_file(arg, podcast.folder)
    else:
        filename = arg
        description = ''

    if len(title)==0:
        try:
            audio = EasyID3(podcast.folder + '/' + filename)
            title = audio.get('title', [''])[0]
        except:
            None

    if len(title) == 0 and prompt:
        title = raw_input(filename + "? ")
    if len(title) <= 1:
        title = os.path.splitext(filename)[0]
    if prompt:
        description = raw_input('Description for %s? '%title)

    podcast.add_episode(title, filename, description)

podcast.write_to_file()
Esempio n. 2
0
config_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), '.creds')
config = json.load(open(config_path))

for key, entry in retrieve(config, verbose=True).iteritems():
    if 'podcast' in entry.get('tags', {}):
        continue
    try:
        url = entry.get('resolved_url', entry.get('given_url', None))
        if url is None:
            continue
        for pattern in PATTERNS:
            if not pattern.URL_PATT.search(url):
                continue
            page = urllib2.urlopen(url).read()
            m = pattern.M_PAT.search(page)
            if not m:
                continue

            fn = download_base_file(m.group(1))
            m2 = pattern.T_PAT.search(page)
            if m2:
                title = m2.group(1)
            else:
                title = m.group(1)
            podcast.add_episode(title, fn, '')
            add_tags(config, [key], 'podcast')
    except:
        None

podcast.write_to_file()