make systems without imdb work
This commit is contained in:
parent
1014bc8a89
commit
ec28dc05e1
10 changed files with 76 additions and 36 deletions
|
@ -4,6 +4,8 @@ from __future__ import division, with_statement
|
|||
|
||||
from django.db import models
|
||||
from django.contrib.auth.models import User
|
||||
import ox
|
||||
|
||||
|
||||
import utils
|
||||
|
||||
|
|
|
@ -30,7 +30,4 @@ def site_config():
|
|||
site_config['keys'] = {}
|
||||
for key in site_config['itemKeys']:
|
||||
site_config['keys'][key['id']] = key
|
||||
site_config['_findKeys'] = {}
|
||||
for key in site_config['findKeys']:
|
||||
site_config['_findKeys'][key['id']] = key
|
||||
return site_config
|
||||
|
|
|
@ -52,7 +52,10 @@ def getPage(request):
|
|||
name = data
|
||||
else:
|
||||
name = data['name']
|
||||
page = get_object_or_404_json(models.Page, name=name)
|
||||
page, created = models.Page.objects.get_or_create(name=name)
|
||||
if created:
|
||||
page.body = 'Insert text here'
|
||||
page.save()
|
||||
response = json_response({'name': page.name, 'body': page.body})
|
||||
return render_to_json_response(response)
|
||||
actions.register(getPage)
|
||||
|
|
|
@ -77,7 +77,8 @@ class File(models.Model):
|
|||
for key in ('duration', 'size'):
|
||||
setattr(self, key, self.info.get(key, 0))
|
||||
|
||||
if 'video' in self.info and self.info['video']:
|
||||
if 'video' in self.info and self.info['video'] and \
|
||||
'width' in self.info['video'][0]:
|
||||
video = self.info['video'][0]
|
||||
self.video_codec = video['codec']
|
||||
self.width = video['width']
|
||||
|
|
|
@ -6,6 +6,7 @@ from celery.decorators import task
|
|||
|
||||
from item.utils import parse_path
|
||||
from item.models import get_item
|
||||
from django.conf import settings
|
||||
|
||||
import models
|
||||
|
||||
|
@ -55,7 +56,10 @@ def update_files(user, volume, files):
|
|||
#new oshash, add to database
|
||||
else:
|
||||
if not i:
|
||||
item_info = parse_path(folder)
|
||||
if settings.USE_IMDB:
|
||||
item_info = parse_path(folder)
|
||||
else:
|
||||
item_info = parse_path(path)
|
||||
i = get_item(item_info)
|
||||
file_object = models.File()
|
||||
file_object.oshash = oshash
|
||||
|
|
|
@ -6,6 +6,8 @@ from datetime import datetime
|
|||
import os.path
|
||||
import subprocess
|
||||
from glob import glob
|
||||
import uuid
|
||||
import unicodedata
|
||||
|
||||
from django.db import models
|
||||
from django.db.models import Sum
|
||||
|
@ -76,12 +78,15 @@ def get_item(info):
|
|||
except Item.DoesNotExist:
|
||||
item.save()
|
||||
else:
|
||||
try:
|
||||
item = Item.objects.get(itemId=info['itemId'])
|
||||
except Item.DoesNotExist:
|
||||
item = Item(itemId=info['itemId'])
|
||||
qs = Item.objects.filter(find__key='title', find__value=info['title'])
|
||||
if qs.count() == 1:
|
||||
item = qs[0]
|
||||
else:
|
||||
item = Item()
|
||||
item.data = {
|
||||
'title': info['title']
|
||||
}
|
||||
item.save()
|
||||
|
||||
return item
|
||||
|
||||
|
||||
|
@ -195,13 +200,20 @@ class Item(models.Model):
|
|||
def __unicode__(self):
|
||||
year = self.get('year')
|
||||
if year:
|
||||
return u'%s (%s)' % (self.get('title'), self.get('year'))
|
||||
return self.get('title')
|
||||
return u'%s (%s)' % (self.get('title', 'Untitled'), self.get('year'))
|
||||
return self.get('title', u'Untitled')
|
||||
|
||||
def get_absolute_url(self):
|
||||
return '/%s' % self.itemId
|
||||
|
||||
def save(self, *args, **kwargs):
|
||||
if not self.id:
|
||||
if not self.itemId:
|
||||
self.itemId = str(uuid.uuid1())
|
||||
super(Item, self).save(*args, **kwargs)
|
||||
if not settings.USE_IMDB:
|
||||
self.itemId = ox.to32(self.id)
|
||||
|
||||
self.oxdbId = self.oxdb_id()
|
||||
|
||||
if self.poster:
|
||||
|
@ -367,6 +379,8 @@ class Item(models.Model):
|
|||
|
||||
|
||||
def oxdb_id(self):
|
||||
if not settings.USE_IMDB:
|
||||
return self.itemId
|
||||
return utils.oxdb_id(self.get('title', ''), self.get('director', []), str(self.get('year', '')),
|
||||
self.get('season', ''), self.get('episode', ''),
|
||||
self.get('episode_title', ''), self.get('episode_director', []), self.get('episode_year', ''))
|
||||
|
@ -388,7 +402,8 @@ class Item(models.Model):
|
|||
f.delete()
|
||||
|
||||
#FIXME: use site_config
|
||||
save('title', '\n'.join([self.get('title'), self.get('original_title', '')]))
|
||||
save('title', u'\n'.join([self.get('title', 'Untitled'),
|
||||
self.get('original_title', '')]))
|
||||
|
||||
for key in self.facet_keys:
|
||||
if key == 'character':
|
||||
|
@ -466,7 +481,7 @@ class Item(models.Model):
|
|||
|
||||
if name not in base_keys:
|
||||
if sort_type == 'title':
|
||||
value = utils.sort_title(canonicalTitle(self.get(source)))
|
||||
value = utils.sort_title(canonicalTitle(self.get(source, u'Untitled')))
|
||||
value = utils.sort_string(value)
|
||||
set_value(s, name, value)
|
||||
elif sort_type == 'person':
|
||||
|
@ -577,7 +592,11 @@ class Item(models.Model):
|
|||
'''
|
||||
|
||||
def frame(self, position, width=128):
|
||||
stream = self.streams.filter(profile=settings.VIDEO_PROFILE+'.webm')[0]
|
||||
stream = self.streams.filter(profile=settings.VIDEO_PROFILE+'.webm')
|
||||
if stream.count()>0:
|
||||
stream = stream[0]
|
||||
else:
|
||||
return None
|
||||
path = os.path.join(settings.MEDIA_ROOT, self.path(),
|
||||
'frames', "%d"%width, "%s.jpg"%position)
|
||||
if not os.path.exists(path):
|
||||
|
@ -739,9 +758,12 @@ class Item(models.Model):
|
|||
'-l', timeline,
|
||||
'-p', poster
|
||||
]
|
||||
if settings.USE_IMDB and len(self.itemId) == 7:
|
||||
if settings.USE_IMDB:
|
||||
if len(self.itemId) == 7:
|
||||
cmd += ['-i', self.itemId]
|
||||
cmd += ['-o', self.oxdbId]
|
||||
else:
|
||||
cmd += ['-i', self.itemId]
|
||||
cmd += ['-o', self.oxdbId]
|
||||
p = subprocess.Popen(cmd)
|
||||
p.wait()
|
||||
return posters.keys()
|
||||
|
|
|
@ -8,6 +8,7 @@ import re
|
|||
import hashlib
|
||||
import unicodedata
|
||||
|
||||
from django.conf import settings
|
||||
import ox
|
||||
import ox.iso
|
||||
from ox.normalize import normalizeName, normalizeTitle
|
||||
|
@ -166,11 +167,13 @@ def parse_path(path):
|
|||
M/McCarthy, Thomas/The Visitor (2007)
|
||||
G/Godard, Jean-Luc/Histoire(s) du cinema_ Toutes les histoires (1988)
|
||||
'''
|
||||
import ox.web.imdb
|
||||
search_title = oxdb_title(path, True)
|
||||
r = {}
|
||||
r['title'] = oxdb_title(path)
|
||||
r['director'] = oxdb_directors(path)
|
||||
if not settings.USE_IMDB:
|
||||
return r
|
||||
import ox.web.imdb
|
||||
search_title = oxdb_title(path, True)
|
||||
r['directors'] = oxdb_directors(path)
|
||||
year = ox.findRe(path, '\((\d{4})\)')
|
||||
if year:
|
||||
r['year'] = year
|
||||
|
|
|
@ -51,7 +51,7 @@ def render_poster(id, title, frame, timeline, poster):
|
|||
else:
|
||||
pixel = list(poster_image.getpixel((x, y)))
|
||||
for c in range(3):
|
||||
pixel[c] = (pixel[c] + poster_color[c]) / 4
|
||||
pixel[c] = int((pixel[c] + poster_color[c]) / 4)
|
||||
poster_image.putpixel((x, y), tuple(pixel))
|
||||
drawText(poster_image, ((poster_width - text_size[0]) / 2, text_top + (text_height - text_size[1]) / 2), text, font_file, font_size, poster_color)
|
||||
poster_image.save(poster)
|
||||
|
@ -60,6 +60,8 @@ def main():
|
|||
parser = OptionParser()
|
||||
parser.add_option('-i', '--id', dest='id', help='Pad.ma Id')
|
||||
parser.add_option('-t', '--title', dest='title', help='Title', default='')
|
||||
parser.add_option('-d', '--director', dest='director', help='Director', default='')
|
||||
parser.add_option('-y', '--year', dest='year', help='Year', default='')
|
||||
parser.add_option('-f', '--frame', dest='frame', help='Poster frame (image file to be read)')
|
||||
parser.add_option('-l', '--timeline', dest='timeline', help='Timeline (image file to be read)')
|
||||
parser.add_option('-p', '--poster', dest='poster', help='Poster (image file to be written)')
|
||||
|
|
|
@ -132,6 +132,7 @@ INSTALLED_APPS = (
|
|||
'timeline',
|
||||
'user',
|
||||
'api',
|
||||
'urlalias',
|
||||
)
|
||||
|
||||
AUTH_PROFILE_MODULE = 'user.UserProfile'
|
||||
|
|
|
@ -527,7 +527,7 @@ var pandora = new Ox.App({
|
|||
},
|
||||
backButton: function() {
|
||||
var that = Ox.Button({
|
||||
title: 'Back to Movies',
|
||||
title: 'Back to ' + app.config.itemName.plural,
|
||||
width: 96
|
||||
}).css({
|
||||
float: 'left',
|
||||
|
@ -725,7 +725,7 @@ var pandora = new Ox.App({
|
|||
elements: $.merge(app.user.ui.list ? [
|
||||
app.$ui.findListSelect = new Ox.Select({
|
||||
items: [
|
||||
{id: 'all', title: 'Find: All Movies'},
|
||||
{id: 'all', title: 'Find: All ' + app.config.itemName.plural},
|
||||
{id: 'list', title: 'Find: This List'}
|
||||
],
|
||||
overlap: 'right',
|
||||
|
@ -1725,7 +1725,7 @@ var pandora = new Ox.App({
|
|||
} else if (app.user.ui.itemView == 'player') {
|
||||
var video = result.data.item.stream,
|
||||
subtitles = result.data.item.layers.subtitles;
|
||||
video.height = 96;
|
||||
video.height = video.profiles[0]
|
||||
video.width = parseInt(video.height * video.aspectRatio / 2) * 2;
|
||||
video.url = video.baseUrl + '/' + video.height + 'p.' + ($.support.video.webm ? 'webm' : 'mp4');
|
||||
app.$ui.contentPanel.replace(1, app.$ui.player = new Ox.VideoPanelPlayer({
|
||||
|
@ -1766,7 +1766,7 @@ var pandora = new Ox.App({
|
|||
'out': 10,
|
||||
'text': 'This subtitle is just a test...'
|
||||
}];
|
||||
video.height = 96;
|
||||
video.height = video.profiles[0]
|
||||
video.width = parseInt(video.height * video.aspectRatio / 2) * 2;
|
||||
video.url = video.baseUrl + '/' + video.height + 'p.' + ($.support.video.webm ? 'webm' : 'mp4');
|
||||
that.replace(0, app.$ui.editor = new Ox.VideoEditor({
|
||||
|
@ -2260,7 +2260,7 @@ var pandora = new Ox.App({
|
|||
if (data.ids.length == 1) {
|
||||
$still = $('<img>')
|
||||
.attr({
|
||||
src: 'http://0xdb.org/' + data.ids[0] + '/still.jpg'
|
||||
src: '/' + data.ids[0] + '/icon.jpg'
|
||||
})
|
||||
.one('load', function() {
|
||||
if (data.ids[0] != app.ui.selectedMovies[0]) {
|
||||
|
@ -2397,7 +2397,7 @@ var pandora = new Ox.App({
|
|||
] },
|
||||
{ id: 'listMenu', title: 'List', items: [
|
||||
{ id: 'history', title: 'History', items: [
|
||||
{ id: 'allmovies', title: 'All Movies' }
|
||||
{ id: 'allmovies', title: 'All ' + app.config.itemName.plural }
|
||||
] },
|
||||
{ id: 'lists', title: 'View List', items: [
|
||||
{ id: 'favorites', title: 'Favorites' }
|
||||
|
@ -2412,7 +2412,7 @@ var pandora = new Ox.App({
|
|||
{ id: 'newsmartlist', title: 'New Smart List...', keyboard: 'alt control n' },
|
||||
{ id: 'newsmartlistfromresults', title: 'New Smart List from Results...', keyboard: 'shift alt control n' },
|
||||
{},
|
||||
{ id: 'addmovietolist', title: ['Add Selected Movie to List...', 'Add Selected Movies to List...'], disabled: true },
|
||||
{ id: 'addmovietolist', title: ['Add Selected ' + app.config.itemName.singular + ' to List...', 'Add Selected ' + app.config.itemName.plural + ' to List...'], disabled: true },
|
||||
{},
|
||||
{ id: 'setposterframe', title: 'Set Poster Frame', disabled: true }
|
||||
]},
|
||||
|
@ -2430,7 +2430,7 @@ var pandora = new Ox.App({
|
|||
{ id: 'invertselection', title: 'Invert Selection', disabled: true, keyboard: 'alt control a' }
|
||||
] },
|
||||
{ id: 'viewMenu', title: 'View', items: [
|
||||
{ id: 'movies', title: 'View Movies', items: [
|
||||
{ id: 'movies', title: 'View ' + app.config.itemName.plural, items: [
|
||||
{ group: 'viewmovies', min: 0, max: 1, items: $.map(app.config.listViews, function(view, i) {
|
||||
return $.extend({
|
||||
checked: app.user.ui.lists[app.user.ui.list].listView == view.id,
|
||||
|
@ -2447,7 +2447,7 @@ var pandora = new Ox.App({
|
|||
{ id: 'video', title: 'Video' }
|
||||
] },
|
||||
{},
|
||||
{ id: 'openmovie', title: ['Open Movie', 'Open Movies'], disabled: true, items: [
|
||||
{ id: 'openmovie', title: ['Open ' + app.config.itemName.singular, 'Open ' + app.config.itemName.plural], disabled: true, items: [
|
||||
{ group: 'movieview', min: 0, max: 1, items: $.map(app.config.itemViews, function(view, i) {
|
||||
return $.extend({
|
||||
checked: app.user.ui.itemView == view.id,
|
||||
|
@ -2458,17 +2458,17 @@ var pandora = new Ox.App({
|
|||
{ id: 'lists', title: 'Hide Lists', keyboard: 'shift l' },
|
||||
{ id: 'info', title: 'Hide Info', keyboard: 'shift i' },
|
||||
{ id: 'groups', title: 'Hide Groups', keyboard: 'shift g' },
|
||||
{ id: 'movies', title: 'Hide Movies', disabled: true, keyboard: 'shift m' }
|
||||
{ id: 'movies', title: 'Hide ' + app.config.itemName.plural, disabled: true, keyboard: 'shift m' }
|
||||
]},
|
||||
{ id: 'sortMenu', title: 'Sort', items: [
|
||||
{ id: 'sortmovies', title: 'Sort Movies by', items: [
|
||||
{ id: 'sortmovies', title: 'Sort ' + app.config.itemName.plural + ' by', items: [
|
||||
{ group: 'sortmovies', min: 1, max: 1, items: $.map(app.ui.sortKeys, function(key, i) {
|
||||
return $.extend({
|
||||
checked: app.user.ui.lists[app.user.ui.list].sort[0].key == key.id,
|
||||
}, key);
|
||||
}) }
|
||||
] },
|
||||
{ id: 'ordermovies', title: 'Order Movies', items: [
|
||||
{ id: 'ordermovies', title: 'Order ' + app.config.itemName.plural, items: [
|
||||
{ group: 'ordermovies', min: 1, max: 1, items: [
|
||||
{ id: 'ascending', title: 'Ascending', checked: app.user.ui.lists[app.user.ui.list].sort[0].operator === '' },
|
||||
{ id: 'descending', title: 'Descending', checked: app.user.ui.lists[app.user.ui.list].sort[0].operator == '-' }
|
||||
|
@ -2945,6 +2945,9 @@ var pandora = new Ox.App({
|
|||
|
||||
}
|
||||
});
|
||||
pandora.api.getPage(app.user.ui.sitePage, function(result) {
|
||||
that.html(result.data.body).css({'overflow-y':'auto'});
|
||||
});
|
||||
} else if (app.user.ui.section == 'items') {
|
||||
that = new Ox.SplitPanel({
|
||||
elements: [
|
||||
|
@ -3692,7 +3695,7 @@ var pandora = new Ox.App({
|
|||
item: ''
|
||||
});
|
||||
},
|
||||
'^(|about|archives|faq|help|home|news|preferences|software|terms|tour)$': function(url) {
|
||||
'^(|about|archives|faq|help|license|home|news|preferences|software|terms|tour)$': function(url) {
|
||||
UI.set({
|
||||
section: 'site',
|
||||
sitePage: url || 'home'
|
||||
|
@ -3775,6 +3778,8 @@ var pandora = new Ox.App({
|
|||
URL.parse();
|
||||
if (app.user.ui.section != old.user.ui.section) {
|
||||
app.$ui.appPanel.replace(1, app.$ui.mainPanel = ui.mainPanel());
|
||||
} else if (app.user.ui.sitePage != old.user.ui.sitePage) {
|
||||
app.$ui.mainPanel.replace(1, app.$ui.rightPanel = ui.rightPanel());
|
||||
} else if (!app.user.ui.item || !old.user.ui.item) {
|
||||
app.$ui.mainPanel.replace(1, app.$ui.rightPanel = ui.rightPanel());
|
||||
} else {
|
||||
|
@ -3838,4 +3843,4 @@ var pandora = new Ox.App({
|
|||
|
||||
load();
|
||||
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue