Permalink
Browse files

added some debug info to the output when stuff goes wrong and handled…

… invalid usernames

also added a note on that last bit to readme
  • Loading branch information...
1 parent 2a29746 commit d5857202809acfd5b9b09e2c82ac3286bba8c561 @RobinRamael committed Jun 3, 2013
Showing with 16 additions and 6 deletions.
  1. +2 −2 README.md
  2. +14 −4 youtube.py
View
@@ -15,11 +15,11 @@ Download a specific video to your directory:
## setup and requirements
-All commands require you to have filled out the `youtube.properties.example` file and moved it to `youtube.properties`
+All commands require you to have filled out the `youtube.properties.example` file and moved it to `youtube.properties`. Note that username is the original youtube username and not your google username.
For now this project requires [youtube-dl](http://rg3.github.com/youtube-dl/), which is a great project in itself. to be installed and on your path. this is also written in python so I might just include it in the project one day, but I'm not sure how. youtube-dl does not support importing and isn't on pip, so...
-Unless you delete the `videos.db` file, a video you already downloaded will not be downloaded again, even if you deleted it from the folder.
+Unless you delete the `videos.db` file, a video you already downloaded will not be downloaded again, even if you deleted it from the folder to save diskspace.
## License
View
@@ -27,22 +27,22 @@
proppath = os.path.dirname(os.path.realpath(__file__)) + '/youtube.properties'
propfile = file(proppath, 'r')
except:
- print("No propertiesfile found, please copy the youtube.properties.example file and fill out the fields.")
+ error_out("No propertiesfile found, please copy the youtube.properties.example file and fill out the fields.")
exit(1)
try:
props = dict([tuple(l.strip().split('=')) for l in propfile.readlines()])
except Exception as e:
- print("malformed properties file, please see the example provided")
+ error_out("malformed properties file, please see the example provided")
print e
exit(1)
+
try:
VIDEODIR = props['video_dir']
USERNAME = props['username']
except:
- print("malformed properties file: video_dir or username missing. Please see the example provided.")
- exit(1)
+ error_out("malformed properties file: video_dir or username missing. Please see the example provided.")
DBDIR = props['db_dir'] if 'db_dir' in props else VIDEODIR
@@ -99,6 +99,9 @@ def download_no_check(self, connection):
def download_all_in_feed():
feed = feedparser.parse(FEEDURL)
+ if feed['feed'] == {}:
+ error_out("something went wrong while getting your videos, is your username correct?")
+
db = sqlite3.connect(DBFILE)
c = db.cursor()
@@ -115,6 +118,13 @@ def download_all_in_feed():
db.close()
+def error_out(msg):
+ sys.stderr.write(msg + "\n")
+ sys.stderr.write("feed: " + FEEDURL + "\n")
+ sys.stderr.write("properties:" + str(props) + "\n")
+ exit(1)
+
+
def main():
if not os.path.exists(VIDEODIR):
os.makedirs(VIDEODIR)

0 comments on commit d585720

Please sign in to comment.