duration is a time delta
This commit is contained in:
parent
118c26fe31
commit
b86e9d8a00
7 changed files with 16 additions and 18 deletions
|
|
@ -32,7 +32,7 @@ class MiniVideo(QFrame):
|
||||||
self.video = video
|
self.video = video
|
||||||
self.ui.titleLabel.setText(video.title)
|
self.ui.titleLabel.setText(video.title)
|
||||||
self.ui.backendLabel.setText(backend.name)
|
self.ui.backendLabel.setText(backend.name)
|
||||||
self.ui.durationLabel.setText('%d:%02d:%02d' % (video.duration/3600, (video.duration%3600)/60, video.duration%60))
|
self.ui.durationLabel.setText(unicode(video.duration))
|
||||||
self.ui.authorLabel.setText(unicode(video.author))
|
self.ui.authorLabel.setText(unicode(video.author))
|
||||||
self.ui.dateLabel.setText(video.date and unicode(video.date) or '')
|
self.ui.dateLabel.setText(video.date and unicode(video.date) or '')
|
||||||
if video.rating_max:
|
if video.rating_max:
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,7 @@ class Video(QDialog):
|
||||||
self.setWindowTitle("Video - %s" % video.title)
|
self.setWindowTitle("Video - %s" % video.title)
|
||||||
self.ui.urlEdit.setText(video.url)
|
self.ui.urlEdit.setText(video.url)
|
||||||
self.ui.titleLabel.setText(video.title)
|
self.ui.titleLabel.setText(video.title)
|
||||||
self.ui.durationLabel.setText('%d:%02d:%02d' % (video.duration/3600, (video.duration%3600)/60, video.duration%60))
|
self.ui.durationLabel.setText(unicode(video.duration))
|
||||||
self.ui.authorLabel.setText(unicode(video.author))
|
self.ui.authorLabel.setText(unicode(video.author))
|
||||||
self.ui.dateLabel.setText(unicode(video.date))
|
self.ui.dateLabel.setText(unicode(video.date))
|
||||||
if video.rating_max:
|
if video.rating_max:
|
||||||
|
|
|
||||||
|
|
@ -59,7 +59,8 @@ class VideoPage(BasePage):
|
||||||
if m:
|
if m:
|
||||||
day, month, year = [int(s) for s in m.group(1).split('/')]
|
day, month, year = [int(s) for s in m.group(1).split('/')]
|
||||||
date = datetime.datetime(year, month, day)
|
date = datetime.datetime(year, month, day)
|
||||||
return date, int(m.group(2)) * 60 + int(m.group(3))
|
duration = datetime.timedelta(minutes=m.group(3), seconds=m.group(2))
|
||||||
|
return date, duration
|
||||||
else:
|
else:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,7 @@
|
||||||
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
|
||||||
|
|
||||||
|
import datetime
|
||||||
import re
|
import re
|
||||||
import urllib
|
import urllib
|
||||||
from logging import warning
|
from logging import warning
|
||||||
|
|
@ -62,13 +63,12 @@ class YoujizzBrowser(BaseBrowser):
|
||||||
m = re.search(r'<strong>.*Runtime.*</strong>(.+)<br.*>', data)
|
m = re.search(r'<strong>.*Runtime.*</strong>(.+)<br.*>', data)
|
||||||
if m:
|
if m:
|
||||||
minutes, seconds = (int(v) for v in unicode(m.group(1).strip()).split(':'))
|
minutes, seconds = (int(v) for v in unicode(m.group(1).strip()).split(':'))
|
||||||
duration = minutes * 60 + seconds
|
|
||||||
else:
|
else:
|
||||||
duration = 0
|
minutes = seconds = 0
|
||||||
video._id = _id
|
video._id = _id
|
||||||
video.title = title
|
video.title = title
|
||||||
video.url = _get_url()
|
video.url = _get_url()
|
||||||
video.duration = duration
|
video.duration = datetime.timedelta(minutes=minutes, seconds=seconds)
|
||||||
return video
|
return video
|
||||||
|
|
||||||
@check_domain
|
@check_domain
|
||||||
|
|
|
||||||
|
|
@ -68,13 +68,13 @@ class VideoPage(PornPage):
|
||||||
value = span.tail.strip()
|
value = span.tail.strip()
|
||||||
|
|
||||||
if name == 'Duration:':
|
if name == 'Duration:':
|
||||||
duration = 0
|
seconds = minutes = 0
|
||||||
for word in value.split():
|
for word in value.split():
|
||||||
if word.endswith('min'):
|
if word.endswith('min'):
|
||||||
duration += 60 * int(word[:word.find('min')])
|
minutes = int(word[:word.find('min')])
|
||||||
elif word.endswith('sec'):
|
elif word.endswith('sec'):
|
||||||
duration += int(word[:word.find('sec')])
|
seconds = int(word[:word.find('sec')])
|
||||||
v.duration = duration
|
v.duration = datetime.timedelta(minutes=minutes, seconds=seconds)
|
||||||
elif name == 'Submitted:':
|
elif name == 'Submitted:':
|
||||||
author = li.find('i')
|
author = li.find('i')
|
||||||
if author is None:
|
if author is None:
|
||||||
|
|
|
||||||
|
|
@ -63,8 +63,9 @@ class YoutubeBackend(BaseBackend, ICapVideo):
|
||||||
yield YoutubeVideo(entry.id.text.split('/')[-1].decode('utf-8'),
|
yield YoutubeVideo(entry.id.text.split('/')[-1].decode('utf-8'),
|
||||||
title=entry.media.title.text.decode('utf-8').strip(),
|
title=entry.media.title.text.decode('utf-8').strip(),
|
||||||
author=author,
|
author=author,
|
||||||
duration=int(entry.media.duration.seconds.decode('utf-8').strip()),
|
duration=datetime.timedelta(seconds=entry.media.duration.seconds.decode('utf-8').strip()),
|
||||||
thumbnail_url=entry.media.thumbnail[0].url.decode('utf-8').strip())
|
thumbnail_url=entry.media.thumbnail[0].url.decode('utf-8').strip(),
|
||||||
|
)
|
||||||
|
|
||||||
def iter_page_urls(self, mozaic_url):
|
def iter_page_urls(self, mozaic_url):
|
||||||
raise NotImplementedError()
|
raise NotImplementedError()
|
||||||
|
|
|
||||||
|
|
@ -23,13 +23,13 @@ __all__ = ['BaseVideo', 'ICapVideo']
|
||||||
|
|
||||||
|
|
||||||
class BaseVideo(object):
|
class BaseVideo(object):
|
||||||
def __init__(self, _id, title=None, url=None, author=None, duration=0, date=None,
|
def __init__(self, _id, title=None, url=None, author=None, duration=None, date=None,
|
||||||
rating=0.0, rating_max=0.0, thumbnail_url=None, nsfw=False):
|
rating=0.0, rating_max=0.0, thumbnail_url=None, nsfw=False):
|
||||||
self.id = unicode(_id)
|
self.id = unicode(_id)
|
||||||
self.title = title
|
self.title = title
|
||||||
self.url = url
|
self.url = url
|
||||||
self.author = author
|
self.author = author
|
||||||
self.duration = int(duration)
|
self.duration = duration
|
||||||
self.date = date
|
self.date = date
|
||||||
self.rating = float(rating)
|
self.rating = float(rating)
|
||||||
self.rating_max = float(rating_max)
|
self.rating_max = float(rating_max)
|
||||||
|
|
@ -41,10 +41,6 @@ class BaseVideo(object):
|
||||||
"""Overloaded in child classes provided by backends."""
|
"""Overloaded in child classes provided by backends."""
|
||||||
raise NotImplementedError()
|
raise NotImplementedError()
|
||||||
|
|
||||||
@property
|
|
||||||
def formatted_duration(self):
|
|
||||||
return '%d:%02d:%02d' % (self.duration / 3600, (self.duration % 3600 / 60), self.duration % 60)
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def page_url(self):
|
def page_url(self):
|
||||||
return self.id2url(self.id)
|
return self.id2url(self.id)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue