Permalink
Browse files

made db commit after each video and removed unecessary code

without the commit, interrupting the script would not mark videos
as downloaded even if they were fully downloaded before the script 
was stopped.
  • Loading branch information...
1 parent ed0e6b0 commit 2a2974692a6872cabed75d35cfbc07dfd97a7eeb @RobinRamael committed Jun 3, 2013
Showing with 1 addition and 8 deletions.
  1. +1 −8 youtube.py
View
@@ -92,6 +92,7 @@ def download_no_check(self, connection):
date_as_str = str(self.publishdate)
else: date_as_str = ""
c.execute("INSERT INTO videos values (?, ?);", (self.id, date_as_str))
+ connection.commit()
else: print 'download of', self.id, 'failed'
@@ -103,21 +104,13 @@ def download_all_in_feed():
c = db.cursor()
c.execute('''CREATE TABLE IF NOT EXISTS videos(id text, pubdate text)''')
- c.execute('''SELECT count(*) FROM videos''')
- if c.fetchone()[0] > 0:
- c.execute("SELECT max(pubdate) FROM videos where pubdate not like ''")
- last_download_date = c.fetchone()[0]
- #print last_download_date
- else: last_download_date = None
-
videos_in_feed = [YTVideo(item) for item in feed['items']]
os.chdir(VIDEODIR)
for video in videos_in_feed:
video.download(db)
-
db.commit()
db.close()

0 comments on commit 2a29746

Please sign in to comment.