summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
2753826)
The downloaded files now get the air date as last modification date.
The timezone mangling requires python 3.3
more error catches when the cdn dies
import requests
import sys, os
import socket
import requests
import sys, os
import socket
+import feedparser
+from datetime import datetime, timezone
class Video(dict):
def __init__(self, *args, **kwargs):
self.update(dict(*args, **kwargs)) # use the free update to set keys
class Video(dict):
def __init__(self, *args, **kwargs):
self.update(dict(*args, **kwargs)) # use the free update to set keys
rtmp = flashvars['pathflv'][0]
filename = video['title']+".flv"
print(Popen(["mplayer","-dumpstream","-dumpfile",filename, rtmp], stdout=PIPE).communicate()[0])
rtmp = flashvars['pathflv'][0]
filename = video['title']+".flv"
print(Popen(["mplayer","-dumpstream","-dumpfile",filename, rtmp], stdout=PIPE).communicate()[0])
+ if not 'timestamp' in video:
+ if soup.find_all(datetime=True):
+ xmldate_str = soup.find_all(datetime=True)[0].attrs['datetime']
+ video['timestamp'] = datetime(*feedparser._parse_date_w3dtf(xmldate_str)[:6]) #naive in utc
+ video['timestamp'] = video['timestamp'].replace(tzinfo=timezone.utc).astimezone(tz=None) #convert to local time
if 'video' in flashvars:
for reference in flashvars['video']['videoReferences']:
if 'm3u8' in reference['url']:
if 'video' in flashvars:
for reference in flashvars['video']['videoReferences']:
if 'm3u8' in reference['url']:
while(True):
try:
buf = ufile.read(4096)
while(True):
try:
buf = ufile.read(4096)
- except socket.error as e:
+ except (socket.error, TypeError) as e:
print("Error reading, skipping file")
print(e)
return
print("Error reading, skipping file")
print(e)
return
os.mkdir(video['genre'])
video['path'] = os.path.join(video['genre'],basename+'.mkv')
else:
os.mkdir(video['genre'])
video['path'] = os.path.join(video['genre'],basename+'.mkv')
else:
- video['path'] = basename+'.mkv'
+ video['path'] = basename+'.mkv'
command = ["mkvmerge","-o",video['path'], '--title',video['title']]
if xml:
command = ["mkvmerge","-o",video['path'], '--title',video['title']]
if xml:
os.unlink(fname)
except:
pass
os.unlink(fname)
except:
pass
+ if 'timestamp' in video:
+ os.utime(video['path'], times=(video['timestamp'].timestamp(),video['timestamp'].timestamp()))
+
def mkv_metadata(video):
root = BeautifulSoup(features='xml')
def mkv_metadata(video):
root = BeautifulSoup(features='xml')
args = parser.parse_args()
if args.rss:
args = parser.parse_args()
if args.rss:
d = feedparser.parse(args.rss)
for e in d.entries:
print(("Downloading: %s"%e.title))
d = feedparser.parse(args.rss)
for e in d.entries:
print(("Downloading: %s"%e.title))