oxlib->ox, oxweb->ox.web

This commit is contained in:
j 2010-07-08 00:46:41 +02:00
parent 3fe22ed624
commit 1bb16bb703
7 changed files with 34 additions and 34 deletions

View file

@ -10,7 +10,7 @@ import time
import warnings
import subprocess
import oxlib
import ox
import Image
import simplejson as json
@ -39,7 +39,7 @@ def frame(videoFile, position, baseFolder, width=128, redo=False):
redo boolean to extract file even if it exists
'''
def frame_path(size):
return os.path.join(baseFolder, "%s.%s.%s" % (oxlib.ms2time(position*1000), size, img_extension))
return os.path.join(baseFolder, "%s.%s.%s" % (ox.ms2time(position*1000), size, img_extension))
#not using input file, to slow to extract frame right now
base_size = 320

View file

@ -6,8 +6,8 @@ import os.path
from django.db import models
from django.contrib.auth.models import User
from oxlib import stripTags, findRe
import oxweb.imdb
from ox import stripTags, findRe
import ox.web.imdb
import models
@ -39,7 +39,7 @@ def loadIMDb(imdbId):
movie = models.Movie()
movie.imdb = imdb
info = oxweb.imdb.getMovieInfo(imdbId)
info = ox.web.imdb.getMovieInfo(imdbId)
for key in ('title',
'tagline',
'year',
@ -60,11 +60,11 @@ def loadIMDb(imdbId):
if key in info:
setattr(movie.imdb, _info_map.get(key, key), info[key])
movie.imdb.plot = oxweb.imdb.getMoviePlot(imdbId)
movie.imdb.plot = ox.web.imdb.getMoviePlot(imdbId)
debug("plot", movie.imdb.plot)
movie.imdb.runtime = oxweb.imdb.getMovieRuntimeSeconds(imdbId)
business = oxweb.imdb.getMovieBusinessSum(imdbId)
movie.imdb.runtime = ox.web.imdb.getMovieRuntimeSeconds(imdbId)
business = ox.web.imdb.getMovieBusinessSum(imdbId)
for key in ('gross', 'profit', 'budget'):
setattr(movie.imdb, key, business[key])
@ -72,7 +72,7 @@ def loadIMDb(imdbId):
movie.oxdbId = "__init__%s" % random.randint(0, 100000)
movie.save()
models.AlternativeTitle.objects.filter(movie=movie, manual=False).delete()
for i in oxweb.imdb.getMovieAKATitles(imdbId):
for i in ox.web.imdb.getMovieAKATitles(imdbId):
t = models.AlternativeTitle()
t.movie = movie
t.title = i[0]
@ -102,7 +102,7 @@ def loadIMDb(imdbId):
#Location
movie.locations_all.filter(manual=False).delete()
locations = oxweb.imdb.getMovieLocations(imdbId)
locations = ox.web.imdb.getMovieLocations(imdbId)
for i in locations:
debug("add location", i)
location, created = models.Location.objects.get_or_create(name=i)
@ -118,7 +118,7 @@ def loadIMDb(imdbId):
#Keyword
movie.keywords_all.filter(manual=False).delete()
keywords = oxweb.imdb.getMovieKeywords(imdbId)
keywords = ox.web.imdb.getMovieKeywords(imdbId)
for g in keywords:
debug("add keyword", g)
keyword, created = models.Keyword.objects.get_or_create(name=g)
@ -126,7 +126,7 @@ def loadIMDb(imdbId):
movie.trivia_all.filter(manual=False).delete()
position = 0
trivia = oxweb.imdb.getMovieTrivia(imdbId)
trivia = ox.web.imdb.getMovieTrivia(imdbId)
for i in trivia:
debug("add trivia", i)
t = models.Trivia()
@ -138,7 +138,7 @@ def loadIMDb(imdbId):
position = 0
models.Cast.objects.filter(movie=movie).filter(manual=False).delete()
credits = oxweb.imdb.getMovieCredits(imdbId)
credits = ox.web.imdb.getMovieCredits(imdbId)
for role in credits:
for p in credits[role]:
name = stripTags(p[0])
@ -151,7 +151,7 @@ def loadIMDb(imdbId):
position += 1
movie.connections_all.filter(manual=False).delete()
connections = oxweb.imdb.getMovieConnections(imdbId)
connections = ox.web.imdb.getMovieConnections(imdbId)
for relation in connections:
for otherId in connections[relation]:
try:
@ -161,7 +161,7 @@ def loadIMDb(imdbId):
except models.Movie.DoesNotExist:
pass
reviews = oxweb.imdb.getMovieExternalReviews(imdbId)
reviews = ox.web.imdb.getMovieExternalReviews(imdbId)
movie.reviews_all.filter(manual=False).delete()
for r in reviews:
debug("add review", r)

View file

@ -13,9 +13,9 @@ from django.utils import simplejson as json
from django.conf import settings
from oxdjango import fields
import oxlib
from oxlib import stripTags
from oxlib.normalize import canonicalTitle, canonicalName
import ox
from ox import stripTags
from ox.normalize import canonicalTitle, canonicalName
from firefogg import Firefogg
import managers
@ -618,7 +618,7 @@ class Person(models.Model):
def save(self, *args, **kwargs):
if not self.name_sort:
self.name_sort = oxlib.normalize.canonicalName(self.name)
self.name_sort = ox.normalize.canonicalName(self.name)
super(Person, self).save(*args, **kwargs)
def get_or_create(model, name, imdbId=None):
@ -823,7 +823,7 @@ class Trivia(models.Model):
def json(self):
trivia = self.trivia
trivia = oxlib.fixAmpersands(trivia)
trivia = ox.fixAmpersands(trivia)
trivia = re.sub('<a name="#tr\d{7}"></a> ', '', trivia)
trivia = re.sub('<a href="(/name/nm.*?)">(.*?)</a>', '<a href="/?f=name&amp;q=\\2">\\2</a>', trivia)
trivia = re.sub('<a href="/title/tt(.*?)/">(.*?)</a>', '<a href="/\\1">\\2</a>', trivia)
@ -947,7 +947,7 @@ def timeline_path(f):
return os.path.join(url_hash[:2], url_hash[2:4], url_hash[4:6], url_hash, name)
def frame_path(f):
position = oxlib.formatDuration(f.position*1000).replace(':', '.')
position = ox.formatDuration(f.position*1000).replace(':', '.')
name = "%s.%s" % (position, 'png')
url_hash = f.file.oshash
return os.path.join(url_hash[:2], url_hash[2:4], url_hash[4:6], url_hash, 'frames', name)

View file

@ -8,9 +8,9 @@ import sys
import re
import hashlib
import oxlib
import oxlib.iso
from oxlib.normalize import normalizeName
import ox
import ox.iso
from ox.normalize import normalizeName
def oxid(title, director, year='', seriesTitle='', episodeTitle='', season=0, episode=0):
oxid_value = u"\n".join([title, director, year])
@ -62,7 +62,7 @@ def oxdb_title(_title, searchTitle = False):
return title
def oxdb_year(data):
return oxlib.findRe(data, '\.(\d{4})\.')
return ox.findRe(data, '\.(\d{4})\.')
def oxdb_series_title(path):
seriesTitle = u''
@ -113,7 +113,7 @@ def oxdb_part(path):
return part
def parsePath(path):
import oxweb.imdb
import ox.web.imdb
search_title = oxdb_title(path, True)
r = {}
r['title'] = oxdb_title(path)
@ -122,6 +122,6 @@ def parsePath(path):
r['season'], r['episode'] = oxdb_season_episode(path)
r['series'] = oxdb_series_title(path)
r['part'] = oxdb_part(path)
r['imdbId'] = oxweb.imdb.guess(search_title, r['director'], timeout=-1)
r['imdbId'] = ox.web.imdb.guess(search_title, r['director'], timeout=-1)
return r

View file

@ -25,7 +25,7 @@ except ImportError:
from oxdjango.decorators import login_required_json
from oxdjango.shortcuts import render_to_json_response, get_object_or_404_json, json_response
from oxdjango.http import HttpFileResponse
import oxlib
import ox
import models
import utils
@ -619,7 +619,7 @@ def api_getImdbId(request):
return {'status': {'code': int, 'text': string},
'data': {imdbId:string }}
'''
imdbId = oxweb.imdb.guess(search_title, r['director'], timeout=-1)
imdbId = ox.web.imdb.guess(search_title, r['director'], timeout=-1)
if imdbId:
response = json_response({'imdbId': imdbId})
else:
@ -688,7 +688,7 @@ def video(request, id, quality):
def frame(request, id, position, size):
movie = get_object_or_404(models.Movie, movieId=id)
position = oxlib.time2ms(position)/1000
position = ox.time2ms(position)/1000
frame = movie.frame(position, int(size))
if not frame:
raise Http404

View file

@ -7,7 +7,7 @@ import base64
from subprocess import Popen
from django.conf import settings
import oxlib.torrent
import ox.torrent
import transmissionrpc
def connect():
@ -32,7 +32,7 @@ def add(torrent_file):
download_dir = os.path.dirname(torrent_file)
with open(torrent_file) as f:
torrent_data = base64.b64encode(f.read())
info_hash = oxlib.torrent.getInfoHash(torrent_file)
info_hash = ox.torrent.getInfoHash(torrent_file)
try:
tc = connect()
if not is_seeding(info_hash):

View file

@ -1,8 +1,8 @@
-e svn+http://code.djangoproject.com/svn/django/trunk#egg=django
-e hg+http://bitbucket.org/andrewgodwin/south/#egg=south
chardet
-e bzr+http://code.0x2620.org/python-oxlib/#egg=python-oxlib
-e bzr+http://code.0x2620.org/python-oxweb/#egg=python-oxweb
-e bzr+http://code.0x2620.org/python-ox/#egg=python-ox
-e bzr+http://code.0x2620.org/python-ox.web/#egg=python-ox.web
-e bzr+http://code.0x2620.org/python-oxdjango/#egg=python-oxdjango
simplejson
-e hg+https://django-ajax-filtered-fields.googlecode.com/hg/#egg=django-ajax-filtered-fields