summaryrefslogtreecommitdiffstats
path: root/zx2c4support/thumblisting.py
blob: 7524e9c9e357e24c7df0a703c864b2294f3888ca (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#!/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