forked from 0x2620/pandora
match places/events in any case, update url-list in torrent to match current url
This commit is contained in:
parent
7140d4c3f5
commit
06069b71e2
4 changed files with 19 additions and 10 deletions
|
@ -29,7 +29,6 @@ def get_matches(obj, model, layer_type):
|
|||
if name in othername:
|
||||
super_matches.append(othername)
|
||||
|
||||
|
||||
exact = [l['id'] for l in filter(lambda l: l['type'] == layer_type, settings.CONFIG['layers'])]
|
||||
if exact:
|
||||
q = Q(value__iexact=obj.name)
|
||||
|
|
|
@ -15,7 +15,7 @@ def update_matching_events(id):
|
|||
for i in ids:
|
||||
e = Event.objects.get(pk=i)
|
||||
for name in [e.name] + list(e.alternativeNames):
|
||||
if name in annotation.value:
|
||||
if name.lower() in annotation.value.lower():
|
||||
e.update_matches()
|
||||
break
|
||||
|
||||
|
@ -29,6 +29,6 @@ def update_matching_places(id):
|
|||
for i in ids:
|
||||
e = Place.objects.get(pk=i)
|
||||
for name in [e.name] + list(e.alternativeNames):
|
||||
if name in annotation.value:
|
||||
if name.lower() in annotation.value.lower():
|
||||
e.update_matches()
|
||||
break
|
||||
|
|
|
@ -901,6 +901,14 @@ class Item(models.Model):
|
|||
self.update_timeline()
|
||||
break
|
||||
|
||||
def get_torrent(self, request):
|
||||
if self.torrent:
|
||||
self.torrent.seek(0)
|
||||
data = ox.torrent.bdecode(self.torrent.read())
|
||||
url = request.build_absolute_uri("%s/torrent/"%self.get_absolute_url())
|
||||
data['url-list'] = ['%s%s' % (url, u.split('torrent/')[1]) for u in data['url-list']]
|
||||
return ox.torrent.bencode(data)
|
||||
|
||||
def make_torrent(self):
|
||||
streams = self.streams()
|
||||
if streams.count() == 0:
|
||||
|
|
|
@ -723,7 +723,7 @@ def torrent(request, id, filename=None):
|
|||
if not item.torrent:
|
||||
raise Http404
|
||||
if not filename or filename.endswith('.torrent'):
|
||||
response = HttpFileResponse(item.torrent.path,
|
||||
response = HttpResponse(item.get_torrent(request),
|
||||
content_type='application/x-bittorrent')
|
||||
filename = "%s.torrent" % item.get('title')
|
||||
response['Content-Disposition'] = 'attachment; filename="%s"' % filename.encode('utf-8')
|
||||
|
@ -906,18 +906,20 @@ def atom_xml(request):
|
|||
el.text = u"1:1"
|
||||
|
||||
if settings.CONFIG['video'].get('download'):
|
||||
if item.torrent:
|
||||
el = ET.SubElement(entry, "link")
|
||||
el.attrib['rel'] = 'enclosure'
|
||||
el.attrib['type'] = 'application/x-bittorrent'
|
||||
el.attrib['href'] = '%s/torrent/' % page_link
|
||||
el.attrib['length'] = '%s' % ox.getTorrentSize(item.torrent.path)
|
||||
#FIXME: loop over streams
|
||||
#for s in item.streams().filter(resolution=max(settings.CONFIG['video']['resolutions'])):
|
||||
for s in item.streams().filter(source=None):
|
||||
el = ET.SubElement(entry, "link")
|
||||
el.attrib['rel'] = 'enclosure'
|
||||
el.attrib['type'] = 'video/%s' % s.format
|
||||
el.attrib['href'] = '%s/%sp.%s' % (page_link, s.resolution, s.format)
|
||||
el.attrib['length'] = '%s'%s.video.size
|
||||
el = ET.SubElement(entry, "link")
|
||||
el.attrib['rel'] = 'enclosure'
|
||||
el.attrib['type'] = 'application/x-bittorrent'
|
||||
el.attrib['href'] = '%s/torrent/' % page_link
|
||||
#el.attrib['length'] = unicode(item.size)
|
||||
|
||||
el = ET.SubElement(entry, "media:thumbnail")
|
||||
thumbheight = 96
|
||||
|
|
Loading…
Reference in a new issue