Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 30 additions & 21 deletions Contents/Code/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
import re

# URLS
EXC_BASEURL = 'http://www.kink.com/'
EXC_SEARCH_MOVIES = EXC_BASEURL + 'search?q=%s'
EXC_MOVIE_INFO = EXC_BASEURL + 'shoot/%s'
EXC_MODEL_INFO = EXC_BASEURL + 'model/%s'
EXC_BASEURL = 'http://www.kink.com'
EXC_SEARCH_MOVIES = EXC_BASEURL + '/search?q=%s'
EXC_MOVIE_INFO = EXC_BASEURL + '/shoot/%s'
EXC_MODEL_INFO = EXC_BASEURL + '/model/%s'

def Start():
HTTP.CacheTime = CACHE_1DAY
Expand Down Expand Up @@ -44,24 +44,25 @@ def update(self, metadata, media, lang):
if link.strip():
metadata.studio = link.strip()
metadata.genres.add(metadata.studio)
metadata.collections.add(metadata.studio)
break
except:
pass

# add channels to genres
# add other tags to collections
metadata.collections.clear()
#metadata.collections.clear()
tags = html.xpath('//div[@class="shoot-info"]//a[starts-with(@href,"/tag/")]')
for tag in tags:
if tag.get('href').endswith(':channel'):
if not metadata.studio:
metadata.studio = tag.text_content().strip()
metadata.genres.add(tag.text_content().strip())
else:
metadata.collections.add(tag.text_content().strip())
else:
metadata.genres.add(tag.text_content().strip())

# set movie title to shoot title
metadata.title = html.xpath('//div[@class="shoot-info"]//h1/text()')[0] + " (" + metadata.id + ")"
metadata.title = html.xpath('//div[@class="shoot-info"]//h1/text()')[0] + " (" + metadata.id + ")"

# set content rating to XXX
metadata.content_rating = 'XXX'
Expand All @@ -76,13 +77,15 @@ def update(self, metadata, media, lang):
metadata.year = metadata.originally_available_at.year
except: pass

# set poster to the image that kink.com chose as preview
# fill poster art with all images, so the vertical images can be used as options
try:
thumbpUrl = html.xpath('//video/@poster')[0]
thumbp = HTTP.Request(thumbpUrl)
metadata.posters[thumbpUrl] = Proxy.Media(thumbp)
imgs = html.xpath('//div[@id="previewImages"]//img')
for img in imgs:
thumbUrl = re.sub(r'/h/[0-9]{3,3}/', r'/h/830/', img.get('src'))
thumb = HTTP.Request(thumbUrl)
metadata.posters[thumbUrl] = Proxy.Media(thumb)
except: pass

# fill movie art with all images, so they can be used as backdrops
try:
imgs = html.xpath('//div[@id="previewImages"]//img')
Expand All @@ -102,19 +105,19 @@ def update(self, metadata, media, lang):
metadata.summary.strip()
except: pass

# director
# director
try:
htmldirector = html.xpath('//p[@class="director"]/a')
metadata.directors.clear()
director_id = html.xpath('//div[@class="shoot-page"]/@data-director')[0]
director_html = HTML.ElementFromURL(EXC_MODEL_INFO % director_id,
headers={'Cookie': 'viewing-preferences=straight%2Cgay'})
director_name = director_html.xpath('//h1[@class="page-title"]')[0].text_content()
for member in htmldirector:
dirname = member.text_content().strip()
try:
director = metadata.directors.new()
director.name = director_name
director.name = dirname
except:
try:
metadata.directors.add(director_name)
director = metadata.directors.new()
metadata.directors.add(dirname)
except: pass
except: pass

Expand All @@ -125,17 +128,23 @@ def update(self, metadata, media, lang):
for member in starring:
role = metadata.roles.new()
lename = member.text_content().strip()
modelurl = EXC_BASEURL + member.attrib['href']
modelhtml = HTML.ElementFromURL(modelurl, headers={'Cookie': 'viewing-preferences=straight%2Cgay'})
model = modelhtml.xpath('//div[@id="modelImage"]/img[@src]')
modelimage = model[0].attrib['src']
try:
role.name = lename
role.photo = modelimage
except:
try:
role.actor = lename
role.photo = modelimage
except: pass
except: pass

# rating
try:
rating_dict = JSON.ObjectFromURL(url=EXC_BASEURL + 'api/ratings/%s' % metadata.id,
headers={'Cookie': 'viewing-preferences=straight%2Cgay'})
metadata.rating = float(rating_dict['avgRating']) * 2
metadata.rating = float(rating_dict['average']) * 2
except: pass