#!/usr/bin/env python # -*- coding: iso-8859-1 -*- from ftplib import FTP import os import os.path print "Content-Type: text/plain" print if not os.path.exists("framedcache"): os.mkdir("framedcache") ftp = FTP("ftp2.edgecastcdn.net") ftp.login("chris@anyclip.com", "ChrisEdge1234") for movie in ftp.nlst("thumbnails"): movieCode = movie[movie.find("/") + 1:] if os.path.exists("framedcache/%s" % movieCode): cache = open("framedcache/%s" % movieCode, "r") print movieCode, print cache.read() cache.close() continue biggest = -1 for thumb in ftp.nlst(movie): try: timeCode = int(thumb[thumb.find("_") + 1:thumb.rfind("_")]) except: timeCode = -1 if timeCode > biggest: biggest = timeCode if biggest > -1: cache = open("framedcache/%s" % movieCode, "w") cache.write(str(biggest)) cache.close() print movieCode, print biggest