oxdata/karagarga/cache.py
2009-07-13 12:29:32 +02:00

33 lines
749 B
Python

# -*- coding: UTF-8 -*-
# vi:si:et:sw=4:sts=4:ts=4
import os
import hashlib
from django.conf import settings
from oxlib.cache import getUrlUnicode
from oxlib import findRe
import oxlib.net
import oxweb.movieposterdb
def getPosterFilename(id, url):
id = str(id)
dirname = os.path.join(settings.DATA_ROOT, 'karagarga.net', id[:1], id)
url_hash = hashlib.sha1(url).hexdigest()
filename = os.path.join(dirname, '%s.jpg' % url_hash)
filename = os.path.normpath(filename)
return filename
def getPoster(id, url):
filename = getPosterFilename(id, url)
oxlib.net.saveUrl(url, filename)
return filename
def archivePosters(init=False):
return
def cron():
archivePosters()
def init():
archivePosters(True)