Browse Source

more coding style adjusted according to PEP-8 and analysis by pylint

Helmut Pozimski 9 years ago
parent
commit
d4f8fc163b
4 changed files with 394 additions and 426 deletions
  1. 1 1
      lib_stov/database.py
  2. 2 2
      lib_stov/subscription.py
  3. 18 15
      lib_stov/youtube.py
  4. 373 408
      stov

+ 1 - 1
lib_stov/database.py

@@ -132,7 +132,7 @@ class Db(object):
         cursor = self._execute_statement(video_query, (subscription_id,))
         result = cursor.fetchall()
         for video in result:
-            videos_list.append(youtube.video(id=video[0], title=video[1],
+            videos_list.append(youtube.Video(video_id=video[0], title=video[1],
                                              description=video[2],
                                              ytid=video[3],
                                              downloaded=video[4],

+ 2 - 2
lib_stov/subscription.py

@@ -94,8 +94,8 @@ class Sub(object):
         if not self.disabled:
             for video in self._video_list:
                 if video.downloaded == 0:
-                    if video.DownloadVideo(self._directory, itag_value,
-                                           self._conf.values["videocodec"]):
+                    if video.download_video(self._directory, itag_value,
+                                            self._conf.values["videocodec"]):
                         self.downloaded_videos.append(video)
                     else:
                         self.failed_videos_count += 1

+ 18 - 15
lib_stov/youtube.py

@@ -16,6 +16,8 @@
 
 # -*- coding: utf8 -*-
 
+"""This module takes care of managing and downloading single videos."""
+
 import os
 import sys
 import subprocess
@@ -23,10 +25,13 @@ import subprocess
 from lib_stov import stov_exceptions
 
 
-class video(object):
+class Video(object):
+    """This class stores all the attributes of a single youtube video and is
+    also able to download it using youtube-dl.
+    """
     def __init__(self, title, description, ytid, conf, downloaded, failcount=0,
-                 id=0):
-        self.__ID = id
+                 video_id=0):
+        self._id = video_id
         self.title = title
         self.description = description
         self.ytid = ytid
@@ -34,7 +39,7 @@ class video(object):
         self.downloaded = downloaded
         self.failcnt = int(failcount)
 
-    def DownloadVideo(self, directory, itag_value, video_codec):
+    def download_video(self, directory, itag_value, video_codec):
         """Downloads the video by calling youtube-dl as an external process"""
         targetdir = self.__conf.values["downloaddir"] + "/" + directory
         if os.access(targetdir, os.F_OK) is False:
@@ -48,22 +53,22 @@ class video(object):
             try:
                 if self.__conf.outputlevel == "default":
                     subprocess.check_call(["youtube-dl", "-f %s/%s"
-                                          % (itag_value, video_codec), "-t",
+                                           % (itag_value, video_codec), "-t",
                                            "http://www.youtube.com/watch?v=%s"
                                            % self.ytid],
                                           stderr=sys.stderr,
                                           stdout=open("/dev/null", "w"))
                 elif self.__conf.outputlevel == "verbose":
                     subprocess.check_call(["youtube-dl", "-f %s/%s"
-                                          % (itag_value, video_codec), "-t",
-                                          "http://www.youtube.com/watch?v=%s"
+                                           % (itag_value, video_codec), "-t",
+                                           "http://www.youtube.com/watch?v=%s"
                                            % self.ytid],
                                           stderr=sys.stderr, stdout=sys.stdout)
                 elif self.__conf.outputlevel == "quiet":
                     subprocess.check_call(["youtube-dl", "-f %s/%s"
-                                          % (itag_value, video_codec), "-t",
-                                          "http://www.youtube.com/watch?v=%s"
-                                          % self.ytid],
+                                           % (itag_value, video_codec), "-t",
+                                           "http://www.youtube.com/watch?v=%s"
+                                           % self.ytid],
                                           stderr=open("/dev/null", "w"),
                                           stdout=open("/dev/null", "w"))
             except subprocess.CalledProcessError:
@@ -73,8 +78,6 @@ class video(object):
                 self.downloaded = 1
                 return True
 
-    def AssignDBID(self, id):
-        self.__ID = id
-
-    def GetID(self):
-        return self.__ID
+    def get_id(self):
+        """Resturns the id attribute assigned to the object."""
+        return self._id

File diff suppressed because it is too large
+ 373 - 408
stov


Some files were not shown because too many files changed in this diff