#!/usr/bin/env python
import sys, os
import ncutils

#check syntax
import optparse
parser = optparse.OptionParser()
opts, args = parser.parse_args()
assert len(args) == 1

#config check
import json
confpath = os.path.expanduser(os.path.join( "~", ".ncutils"))
with open(confpath) as f:
    conf = json.load(f)

#do the work
assert ncutils.login(conf["username"], conf["password"])

mlist = ncutils.Mylist(args[0])
for video in mlist.videolist:
    try:
        video.download()
    except:
        pass
