def __init__(self):
        print 'started'
        metapath = xbmc.translatePath('special://profile/addon_data/' + sys.argv[7])
        iconpath = xbmc.translatePath('special://home/addons/' + sys.argv[7] + '/icon.png')
        cookiepath = sys.argv[4]

        cookies = cookielib.MozillaCookieJar()



        crumbs = cookies

        auth.login(sys.argv[1], sys.argv[2], cookies, sys.argv[5], sys.argv[6])
        #def login(username, password, cookies, callstackpath, maxcalls):





        requestUrl = "http://www.netflix.com/QueueDelete?movieid={0}&authURL={2}"

        #Get new authURL
        response = utils.makeGetRequest("http://www.netflix.com", cookies, sys.argv[5], sys.argv[6])

        # find matches - should return <input type="hidden" name="authURL" value="[the_value]" /> instances
        match = re.compile('a.*?authURL=(.*?)["&]', re.DOTALL).findall(str(response))

        # use the last instance found (there should only be one anyway...)
        authURL = ""
        for found in match:
        	if found != "":
        		authURL = found

        requestUrl = requestUrl.format(sys.argv[9], sys.argv[10], authURL, safe='')


        response = utils.makeGetRequest(requestUrl, cookies, sys.argv[5], str(sys.argv[6]))


        #def scrapeMyList(cookies, callstackpath, maxrequestsperminute, metapath):
        scraper.scrapeMyList(cookies, sys.argv[5], sys.argv[6], sys.argv[8])
        xbmc.executebuiltin('Notification("Netflix", "Title Removed From MyList", 5000, ' + iconpath + ')')


	def ensureFolders(self):
		metapath = xbmc.translatePath('special://profile/addon_data/' + sys.argv[7] + '/meta')

		if not os.path.isdir(metapath):
			os.mkdir(metapath)

		if not os.path.isdir(os.path.join(metapath, "Genres")):
			os.mkdir(os.path.join(metapath, "Genres"))
		if not os.path.isdir(os.path.join(metapath, "Titles")):
			os.mkdir(os.path.join(metapath, "Titles"))
	def __init__(self):
		metapath = xbmc.translatePath('special://profile/addon_data/' + sys.argv[7])
		iconpath = xbmc.translatePath('special://home/addons/' + sys.argv[7] + '/icon.png')
		cookiepath = sys.argv[4]

		cookies = cookielib.MozillaCookieJar()
		if os.path.exists(cookiepath):
			cookies.load(cookiepath)

		auth.login(sys.argv[1], sys.argv[2], cookies, sys.argv[5], sys.argv[6])
		#def login(username, password, cookies, callstackpath, maxcalls):

		self.ensureFolders()

		#def scrapeTitle(cookies, callstackpath, maxrequestsperminute, metapath, titleid, trackid):
		scraper.scrapeTitle(cookies, sys.argv[5], sys.argv[6], sys.argv[8], sys.argv[9], sys.argv[10])
	def __init__(self):
		metapath = xbmc.translatePath('special://profile/addon_data/' + sys.argv[7])
		iconpath = xbmc.translatePath('special://home/addons/' + sys.argv[7] + '/icon.png')
		cookiepath = sys.argv[4]

		cookies = cookielib.MozillaCookieJar()
		if os.path.exists(cookiepath):
			cookies.load(cookiepath)

		auth.login(sys.argv[1], sys.argv[2], cookies, sys.argv[5], sys.argv[6])

		self.ensureFolders()

		scraper.scrapeGenres(cookies, sys.argv[5], sys.argv[6], sys.argv[8], sys.argv[3])

		xbmc.executebuiltin('Notification("Netflix", "Genres Updated", 5000, ' + iconpath + ')')
	def __init__(self):
		metapath = xbmc.translatePath('special://profile/addon_data/' + sys.argv[7])
		iconpath = xbmc.translatePath('special://home/addons/' + sys.argv[7] + '/icon.png')
		cookiepath = sys.argv[4]

		cookies = cookielib.MozillaCookieJar()
		if os.path.exists(cookiepath):
			cookies.load(cookiepath)

		auth.login(sys.argv[1], sys.argv[2], cookies, sys.argv[5], sys.argv[6])
		#def login(username, password, cookies, callstackpath, maxcalls):

		self.ensureFolders()


		scraper.scrapeGenres(cookies, sys.argv[5], sys.argv[6], sys.argv[8])
		#scrapeGenres(cookies, callstackpath, maxrequestsperminute, metapath):


		xbmc.executebuiltin('Notification("Netflix", "Genres Updated", 5000, ' + iconpath + ')')
		print 'done'
	def __init__(self):
		print "Netflix: Updating Genre Titles (" + sys.argv[10] + ")"
		metapath = xbmc.translatePath('special://profile/addon_data/' + sys.argv[7])
		iconpath = xbmc.translatePath('special://home/addons/' + sys.argv[7] + '/icon.png')
		cookiepath = sys.argv[4]

		cookies = cookielib.MozillaCookieJar()
		if os.path.exists(cookiepath):
			cookies.load(cookiepath)

		auth.login(sys.argv[1], sys.argv[2], cookies, sys.argv[5], sys.argv[6])
		#def login(username, password, cookies, callstackpath, maxcalls):

		cookies.save(cookiepath)

		self.ensureFolders()

		#   def scrapeGenreTitles(cookies, callstackpath, maxrequestsperminute, metapath, genreid, cacheage, genrename):
		scraper.scrapeGenreTitles(cookies, sys.argv[5], sys.argv[6], sys.argv[8], sys.argv[9], sys.argv[3], sys.argv[10])

		print "Netflix: " + sys.argv[10] + " Titles Updated"
		xbmc.executebuiltin('Notification("Netflix", "' + sys.argv[10] + ' Titles Updated", 5000, ' + iconpath + ')')
        print "Netflix: MyList data is not available"
        UpdateMyList = True

        # don't re-cache if already in progress - this will cause weird bounce on the available titles
    if os.path.exists(os.path.join(metaroot, "active", "scrape_mylist")):
        UpdateMyList = False

        # update genres
    if UpdateGenres:

        if addon.getSetting("promptforcache") == "true":
            dialog = xbmcgui.Dialog()
            ret = dialog.yesno("Netflix", utils.translation(addon, 30200))
            if ret:
                # make sure we can login to the Netflix website
                while not auth.login(username, password, cookiejar, callstackpath, maxrequestsperminute):
                    d = xbmcgui.Dialog()
                    addon.setSetting("username", d.input(utils.translation(addon, 30004)))
                    addon.setSetting(
                        "password",
                        d.input(
                            utils.translation(addon, 30005),
                            type=xbmcgui.INPUT_ALPHANUM,
                            option=xbmcgui.ALPHANUM_HIDE_INPUT,
                        ),
                    )
                    username = addon.getSetting("username")
                    password = addon.getSetting("password")
                xbmc.executebuiltin(
                    "xbmc.runscript(special://home/addons/"
                    + addonID
def seasons(addon, addonID, pluginhandle, metapath, viewpath, callstackpath, maxrequestsperminute, cookiepath, seriesid, metaroot):
	#metapath = os.path.join(metapath, "titles", seriesid, "seasondata.json")


	cookies = cookielib.MozillaCookieJar()
	if os.path.exists(cookiepath):
		cookies.load(cookiepath)

	auth.login(addon.getSetting("username"), addon.getSetting("password"), cookies, callstackpath, maxrequestsperminute)

	scraper.scrapeSeasonData(cookies, callstackpath, maxrequestsperminute, metaroot, seriesid)

	if os.path.exists(os.path.join(metapath, "seasondata.json")):
		xbmcplugin.setContent(pluginhandle, 'seasons')

		fh = open(os.path.join(metapath, "seasondata.json"), 'r')
		content = fh.read()
		fh.close()

		seasondata = json.loads(content)

		for season in seasondata["episodes"]:
			syno = ""
			title = "Season " + str(season[0]["season"])
			url = viewpath + "?mode=listepisodes&series=" + seriesid + "&season=" + str(season[0]["season"]) + "&seasonid=" + str(season[0]["seasonId"])
			if os.path.exists(os.path.join(metapath, "Season " + str(season[0]["season"]), "synopsis")):
				fh = open(os.path.join(metapath, "Season " + str(season[0]["season"]), "synopsis"), 'r')
				syno = fh.read()
				fh.close
			year = seasondata["year"]
			watched = 0
			episodecount = 0
			for episode in season:
				#episodeexpr = '{"title":".*?","season":(.*?),"seasonYear":.*?,"episode":.*?,"synopsis":".*?","seasonId":.*?,"episodeId":.*?,"videoId":.*?,"nonMemberViewable":.*?,"runtime":(.*?),"availableForED":.*?,"availabilityMessage":.*?,"stills":\[.*?\],"bookmarkPosition":(.*?),"lastModified":".*?"}'
				episodecount += 1
				if episode["bookmarkPosition"]:
					if float(episode["bookmarkPosition"])/float(episode["runtime"]) >= 0.9:
						watched += 1
				year = episode["seasonYear"]

			li = xbmcgui.ListItem(title)

			if (episodecount - watched) == 0:
				playcount = 1
			elif watched == 0:
				playcount = 0
			else:
				li.setProperty('TotalTime', '100')
				li.setProperty('ResumeTime', '50')

			li.setProperty('TotalEpisodes', str(episodecount))
			li.setProperty('WatchedEpisodes', str(watched))
			li.setProperty('UnWatchedEpisodes', str(episodecount-watched))


			info = {'plot': syno, 'year': int(year)}

			li.setInfo('video', infoLabels=info)

			xbmcplugin.addDirectoryItem(handle=pluginhandle, url=url, listitem=li, isFolder=True)

		xbmcplugin.endOfDirectory(pluginhandle)