Ejemplo n.º 1
0
            files.append(base)
    return files

yaml = '/home/dlu/public_html/podcast/david_misc.yaml'
files = []
prompt = True
for arg in sys.argv[1:]:
    if arg[-4:]=='yaml':
        yaml = arg
    elif arg=='-p':
        prompt = False
    else:
        files.append(arg)


podcast = YamlPodcast(yaml)

files += static_files()

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 = ''
Ejemplo n.º 2
0
class WBUR:
    URL_PATT = re.compile('wbur\.org')
    T_PAT = re.compile('<title>(.*)</title>')
    M_PAT = re.compile('<a href="([^"]*)" class="article-audio-dl" title="Download the audio"')

class WESA:
    URL_PATT = re.compile('wesa\.fm')
    T_PAT = re.compile('<title>(.*) | 90.5 WESA</title>')
    M_PAT = re.compile('<a href="([^"]+)" title="[^"]+" class="jp-play"></a>')


PATTERNS = [NPR, WBUR, WESA]

yaml = '/home/dlu/public_html/podcast/david_misc.yaml'

podcast = YamlPodcast(yaml)

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()
Ejemplo n.º 3
0
class NPR:
    URL_PATT = re.compile('npr\.org')
    T_PAT = re.compile('<title>(.*)</title>')
    M_PAT = re.compile('<li class="audio-tool audio-tool-download">\s*<a href="([^"]*)"')

class WBUR:
    URL_PATT = re.compile('wbur\.org')
    T_PAT = re.compile('<title>(.*)</title>')
    M_PAT = re.compile('<a href="([^"]*)" class="article-audio-dl" title="Download the audio"')

PATTERNS = [NPR, WBUR]

yaml = '/home/dlu/public_html/podcast/david_misc.yaml'

podcast = YamlPodcast(yaml)

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()
Ejemplo n.º 4
0
            files.append(base)
    return files


yaml = '/home/dlu/public_html/podcast/david_misc.yaml'
files = []
prompt = False
for arg in sys.argv[1:]:
    if arg[-4:] == 'yaml':
        yaml = arg
    elif arg == '-p':
        prompt = True
    else:
        files.append(arg)

podcast = YamlPodcast(yaml)

files += static_files()

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 = ''