mirror of https://github.com/falsovsky/RTPapd.git
Update to conform with latest RTP site changes
This commit is contained in:
parent
29beeba864
commit
8b9d315dd0
14
rtp.py
14
rtp.py
|
@ -35,18 +35,23 @@ def removeDisallowedFilenameChars(filename):
|
||||||
|
|
||||||
def parseRTMP(url,title,progId):
|
def parseRTMP(url,title,progId):
|
||||||
url = 'http://www.rtp.pt' + url
|
url = 'http://www.rtp.pt' + url
|
||||||
|
|
||||||
|
match = re.search(r"play/p\d+/(e\d+)/", url)
|
||||||
|
episode_id = match.group(1)
|
||||||
|
|
||||||
programpath = scriptpath+"/"+progId
|
programpath = scriptpath+"/"+progId
|
||||||
if os.path.isdir(programpath) == False:
|
if os.path.isdir(programpath) == False:
|
||||||
os.makedirs(programpath)
|
os.makedirs(programpath)
|
||||||
destfn = programpath+"/"+title+'.mp3'
|
destfn = programpath + "/" + title + "_" + episode_id + '.mp3'
|
||||||
page = urllib2.urlopen(url)
|
page = urllib2.urlopen(url)
|
||||||
match = re.search('wavrss(.+?)"', page.read())
|
|
||||||
|
match = re.search('"hls_url": "(.+?)",', page.read())
|
||||||
if match:
|
if match:
|
||||||
if os.path.isfile(destfn):
|
if os.path.isfile(destfn):
|
||||||
print "- Ja downloadada... a ignorar"
|
print "- Ja downloadada... a ignorar"
|
||||||
return False
|
return False
|
||||||
print "- A sacar..."
|
print "- A sacar..."
|
||||||
cmd = 'wget "http://rsspod.rtp.pt/podcasts/' + match.group(1) + '" -O "'+destfn+'"'
|
cmd = 'wget "' + match.group(1) + '" -O "' + destfn + '"'
|
||||||
os.system(cmd + "> /dev/null 2>&1")
|
os.system(cmd + "> /dev/null 2>&1")
|
||||||
print "- Done"
|
print "- Done"
|
||||||
return True
|
return True
|
||||||
|
@ -64,8 +69,9 @@ c = 1
|
||||||
while True:
|
while True:
|
||||||
print "--- Pagina " + str(c)
|
print "--- Pagina " + str(c)
|
||||||
url = "http://www.rtp.pt/play/bg_l_ep/?stamp=" + str(int(time.time())) + "&listDate=&listQuery=&listProgram=" + str(id) + "&listcategory=&listchannel=&listtype=recent&page=" + str(c) + "&type=all"
|
url = "http://www.rtp.pt/play/bg_l_ep/?stamp=" + str(int(time.time())) + "&listDate=&listQuery=&listProgram=" + str(id) + "&listcategory=&listchannel=&listtype=recent&page=" + str(c) + "&type=all"
|
||||||
|
|
||||||
page = urllib2.urlopen(url)
|
page = urllib2.urlopen(url)
|
||||||
soup = BeautifulSoup(page.read())
|
soup = BeautifulSoup(page.read(), "html.parser")
|
||||||
|
|
||||||
if (soup.find('div') == None):
|
if (soup.find('div') == None):
|
||||||
sys.exit("ultima pagina")
|
sys.exit("ultima pagina")
|
||||||
|
|
Loading…
Reference in New Issue