Hi Gemeinde,
ich wuerde gerne audio-pod-casts per kommandozeile speichern.
Ich habe schon einge programme ausprobiert und am besten bin ich mit "podget" und "newsbeuter(podbeuter )" zurechtgekommen. Ich habe schon viel eine suchemaschiene meiner wahlt benutzt, aber komme nichtmehr weiter.
Das Problem das ich nun bei beiden habe ist, dass die gedownlaodeten podcast nach dem dateinamen auf dens erver benannt werden, obwohl man gerade bei newsbeuter gut sehen kann dass der folgenname uebertragen wird oft mit inhaltsangabe etc.
Nun zu meiner Frage kennt jemand eine einstellung fuer eines der programme die das bewirkt, oder ein weiteres programm das die informationen gleich mit aufnimmt.
Oder ist es moeglich die informationen nach dem download automatisch weiterzugeben und der audiodatei anzufuegen?
mfg
[geloest] audio podcast grabber fuer kommandozeile einstellen/gesucht
[geloest] audio podcast grabber fuer kommandozeile einstellen/gesucht
Zuletzt geändert von Mentore am 22.10.2017 17:40:44, insgesamt 1-mal geändert.
Re: audio podcast grabber fuer kommandozeile einstellen/gesucht
auch das ist etwas aelter hust
jedenfalls hatte ich mir dann selbst ein podcastgrabber geschrieben
jedenfalls hatte ich mir dann selbst ein podcastgrabber geschrieben
Code: Alles auswählen
#!/usr/bin/python
# -*- coding: utf-8 -*-
import sqlite3 as lite
import sys
import feedparser
import re #fuer replace string
import argparse #startparameter
import urllib #downlaoder
import os #ordnerersteller
from time import gmtime, strftime
mypodcasts = [
'error dummy',
'http://www.c3d2.de/pentacast.xml',
'http://www.c3d2.de/pentacast-archiv.xml',
'http://chaosradio.ccc.de/chaosradio-latest.rss',
'http://www.die-drei-vogonen.de/feed/mp3/',
'http://resonator-podcast.de/feed/mp3/'
]
#declare where to download
if os.name == 'nt':
# Windows
downloadpfad = 'C:\\downloads\\'
thefuckingslash = '\\'
else:
# Alle anderen, Linux, Mac, ...
downloadpfad = '/home/user/podcasts/'
thefuckingslash = '/'
if not os.path.exists(downloadpfad):
# Verzeichnis erstellen, falls nicht existent
os.mkdir(downloadpfad)
i = 0
i2 = 0
anzahlanfeeds = len(mypodcasts)
dbname = 'fallbackdbname'
#strftime("%a, %d %b %Y %H:%M:%S +0000", gmtime())
#'Thu, 28 Jun 2001 14:17:15 +0000'
mon = strftime("%b", gmtime())
year = strftime("%Y", gmtime())
parser = argparse.ArgumentParser(description="Technical right under moral purpose Grabber")
parser.add_argument("-a", '--all', help='Erstellt tables, updated und downlaoded den aktuellen monat',dest="all", action='store_true')
parser.add_argument("-c", '--create', help='Erstellt/updated tables',dest="create", action='store_true')
parser.add_argument("-del", '--delete', help='Loescht alle tables',dest="delete", action='store_true')
parser.add_argument("-u", '--update', help='update only der vorhandenen tabellen',dest="update", action='store_true')
parser.add_argument("-o", '--output', help='output von tablname', dest="table")
parser.add_argument("-d", '--download', help='Downlaod der inhalte per like suche durch die released column ',dest="dlzeitraum", action='store')
args = parser.parse_args()
con = lite.connect('podcast.db')
#entfernt alle sonderzeichen benoetigt fuer feedtitel_2_tablename
def replace222(tablename):
tablename = (" ".join(re.findall(r"[A-Za-z0-9]*", tablename))).replace(" ","")
return tablename
#table erstellen mit podcastnamen benoetigt fuer feedtitel_2_tablename
def erstelle_table(dbname):
with con:
cur = con.cursor()
cur.execute("CREATE TABLE IF NOT EXISTS %s (Id INTEGER, title varchar[200], released varchar[200],podcastnamet varchar[200], downloadurl varchar[200] UNIQUE)" % dbname)
#nimmt alle feeds aus dem array mypodcasts und schreibt tables mit feed title name ohene sonderzeichen
def feedtitel_2_tablename():
i =0
podcasturl = 'fallback for error' , i
while i < anzahlanfeeds:
try:
podcasturl = mypodcasts[i]
zwischenspeicherpodcastsurl = feedparser.parse(podcasturl)
feed = zwischenspeicherpodcastsurl['feed']
title = feed['title']
titletable = replace222(title)
erstelle_table(titletable)
print i
print titletable
i += 1
except:
print "Fehler in ", podcasturl
i += 1
#feedtitel_2_tablename()
#loescht die tables
def tableloeschenall():
cursor = con.cursor()
tables = list(cursor.execute("select name from sqlite_master where type is 'table'"))
cursor.executescript(';'.join(["drop table if exists %s" %i for i in tables]))
#tableloeschenall()
#geht das array mit podcasts durch und schreibt die inhalte in die tables
def fill_or_update_podcast_sql_tables():
with con:
i = 0
i2 = 0
while i < anzahlanfeeds:
try:
tableohneszeichen = 'fallback for error' , i
podcasturl = mypodcasts[i]
zwischenspeicherpodcastsurl = feedparser.parse(podcasturl)
anzahlanfeedszwpeicher = len(zwischenspeicherpodcastsurl['entries'])
titletable = zwischenspeicherpodcastsurl['feed']['title']
tableohneszeichen = replace222(titletable)
print "update", tableohneszeichen
while i2 < anzahlanfeedszwpeicher:
status = 0
title = 'this'
published = 'is not'
dllink = 'important'
e=zwischenspeicherpodcastsurl.entries[i2]
title = zwischenspeicherpodcastsurl.entries[i2]['title']
published = zwischenspeicherpodcastsurl['entries'][i2]['published']
dllink = e.enclosures[0]['href']
titletable = zwischenspeicherpodcastsurl['feed']['title']
tableohneszeichen = replace222(titletable)
podcast = tableohneszeichen
cur = con.cursor()
cur.execute("INSERT OR IGNORE into %s (Id, title, released,podcastnamet, downloadurl) values (?, ?, ?, ?, ?)" % podcast ,
(status, title, published, podcast, dllink))
i2 += 1
i += 1
i2 = 0
except:
print "Fehler in ", tableohneszeichen
i += 1
#fill_or_update_podcast_sql_tables()
#gibt table dbname aus
def output_content(dbname):
with con:
cur = con.cursor()
for row in cur.execute('select * from {};' .format(dbname) ):
zeileintable = row
print zeileintable
#output_content('WorkingssDrafts')
#sucht in table in column released mit like searchtime und switch status 0/1
def download_content(searchtime):
with con:
cur = con.cursor()
i = 0
cur.execute("SELECT name FROM sqlite_master WHERE type='table';")
anzahltables = len(cur.fetchall())
print anzahltables , 'tables erkannt'
cur.execute("SELECT name FROM sqlite_master WHERE type='table';")
alltablearray = cur.fetchall()
print alltablearray
while i < anzahltables:
try:
tablesignleraw = 'fallback for error' , i
tablesignle = alltablearray[i]
tablesignleraw = tablesignle[0]
print tablesignleraw
for row in cur.execute('select * from {} where Id ="0" and released like "{}";' .format(tablesignleraw, searchtime) ):
status = row[0]
title = row[1]
tablename = row[3]
dllink = row[4]
titleohnesonder = replace222(title)
dlinkende = dllink.split('.')[-1]
print 'downloading', titleohnesonder
zwspeicherpfad = "{}{}" .format(downloadpfad,tablename)
if not os.path.exists(zwspeicherpfad):
os.makedirs(zwspeicherpfad)
urllib.urlretrieve ("%s" % dllink , "{}{}{}{}.{}" .format(downloadpfad,tablename,thefuckingslash,titleohnesonder,dlinkende))
i += 1
cur.execute("UPDATE {} SET Id = '1' where released like '{}';" .format(tablesignleraw, searchtime) )
except:
print "Fehler in ", tablesignleraw
i += 1
#download_content('%15%Sep%2016%')
#startparameter per args bekommen funktionen
if args.all:
print 'option -a'
feedtitel_2_tablename()
fill_or_update_podcast_sql_tables()
thismonth = "%{}%{}%" .format(mon,year)
download_content(thismonth)
elif args.create:
print 'option -c'
feedtitel_2_tablename()
elif args.delete:
print 'option -del'
tableloeschenall()
elif args.update:
print 'option -u'
fill_or_update_podcast_sql_tables()
elif args.table:
print 'option -o'
output_content(args.table)
elif args.dlzeitraum:
string = args.dlzeitraum
print 'option -d {}' .format(string)
download_content('{}' .format(string))
else:
with con:
print 'Aktuelle tables'
cur = con.cursor()
for row in cur.execute("SELECT name FROM sqlite_master WHERE type='table';"):
print row[0]
print 'Aktueller downloadpfad %s' % downloadpfad
start = """
no option chosen
Usage add some pocasts into this file under "mypodcasts" then
-a Erstellt tables, updated und downloaded den aktuellen monat
-c Erstellt/updated tables
-del Loescht alle tables
-u Fill or updates tables
-o Print table exp. -o PuertossPatidas
-d Download content exp. -d %{}%{}%""" .format(mon,year)
print start
print 'Jan/Feb/Mar/Apr/May/Jun/Jul/Aug/Sep/Oct/Nov/Dec'
con.close()