45 lines
1.7 KiB
Python
45 lines
1.7 KiB
Python
# -*- coding: utf-8 -*-
|
|
|
|
"""
|
|
Copyright(C) 2010 Romain Bignon
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
it under the terms of the GNU General Public License as published by
|
|
the Free Software Foundation, version 3 of the License.
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
GNU General Public License for more details.
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
along with this program; if not, write to the Free Software
|
|
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
"""
|
|
|
|
import urllib2
|
|
from PyQt4.QtGui import QFrame, QImage, QPixmap
|
|
|
|
from weboob.frontends.qvideoob.ui.minivideo_ui import Ui_MiniVideo
|
|
|
|
class MiniVideo(QFrame):
|
|
def __init__(self, video, parent=None):
|
|
QFrame.__init__(self, parent)
|
|
self.ui = Ui_MiniVideo()
|
|
self.ui.setupUi(self)
|
|
|
|
self.video = video
|
|
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.authorLabel.setText(unicode(video.author))
|
|
self.ui.dateLabel.setText(video.date and unicode(video.date) or '')
|
|
if video.rating_max:
|
|
self.ui.ratingLabel.setText('%s / %s' % (video.rating, video.rating_max))
|
|
else:
|
|
self.ui.ratingLabel.setText('%s' % video.rating)
|
|
|
|
if video.preview_url:
|
|
data = urllib2.urlopen(video.preview_url).read()
|
|
img = QImage.fromData(data)
|
|
self.ui.imageLabel.setPixmap(QPixmap.fromImage(img))
|