Commit eb3b8a71 authored by Romain Bignon's avatar Romain Bignon

new frontend. qvideoob

parent baa2fd93
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# vim: ft=python et softtabstop=4 cinoptions=4 shiftwidth=4 ts=4 ai
"""
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.
"""
from weboob.frontends.qvideoob import QVideoob
if __name__ == '__main__':
QVideoob.run()
all:
$(MAKE) -C ui
clean:
$(MAKE) -C ui clean
from .application import QVideoob
# -*- 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.
"""
from weboob.capabilities.video import ICapVideoProvider
from weboob.tools.application import QtApplication
from .main_window import MainWindow
class QVideoob(QtApplication):
def main(self, argv):
self.weboob.load_backends(ICapVideoProvider)
self.main_window = MainWindow(self.weboob)
self.main_window.show()
return self.weboob.loop()
# -*- 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.
"""
from PyQt4.QtCore import SIGNAL
from weboob.capabilities.video import ICapVideoProvider
from weboob.tools.application.qt import QtMainWindow
from weboob.frontends.qvideoob.ui.main_window_ui import Ui_MainWindow
from .video import Video
from .minivideo import MiniVideo
class MainWindow(QtMainWindow):
def __init__(self, weboob, parent=None):
QtMainWindow.__init__(self, parent)
self.ui = Ui_MainWindow()
self.ui.setupUi(self)
self.weboob = weboob
self.minivideos = []
self.connect(self.ui.searchEdit, SIGNAL("returnPressed()"), self.search)
self.connect(self.ui.urlEdit, SIGNAL("returnPressed()"), self.openURL)
def search(self):
pattern = unicode(self.ui.searchEdit.text())
if not pattern:
return
for minivideo in self.minivideos:
self.ui.scrollAreaContent.layout.removeWidget(minivideo)
self.minivideos = []
for backend in self.weboob.iter_backends():
for video in backend.iter_search_results(pattern):
minivideo = MiniVideo(video)
self.ui.scrollAreaContent.layout().addWidget(minivideo)
self.minivideos.append(minivideo)
def openURL(self):
url = unicode(self.ui.urlEdit.text())
if not url:
return
for backend in self.weboob.iter_backends():
video = backend.get_video(url)
if video:
video_widget = Video(video, self)
video_widget.show()
self.ui.urlEdit.clear()
# -*- 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))
UI_FILES = $(wildcard *.ui)
UI_PY_FILES = $(UI_FILES:%.ui=%_ui.py)
PYUIC = pyuic4
all: $(UI_PY_FILES)
%_ui.py: %.ui
$(PYUIC) -o $@ $^
# TODO: ugly hack, because of a usefull import by
# Qt in the nulog_ui.py file.. But we *don't*
# want to use a python resource file!!
sed -i '/import nulog3_rc/D' $@
clean:
rm -f *.pyc
rm -f $(UI_PY_FILES)
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>MainWindow</class>
<widget class="QMainWindow" name="MainWindow">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>800</width>
<height>600</height>
</rect>
</property>
<property name="windowTitle">
<string>QVideoob</string>
</property>
<widget class="QWidget" name="centralwidget">
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QFrame" name="frame_2">
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>Search: </string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="searchEdit"/>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QScrollArea" name="scrollArea">
<property name="styleSheet">
<string notr="true"/>
</property>
<property name="widgetResizable">
<bool>true</bool>
</property>
<widget class="QWidget" name="scrollAreaContent">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>778</width>
<height>425</height>
</rect>
</property>
<property name="styleSheet">
<string notr="true">QWidget#scrollAreaContent {
background-color: rgb(255, 255, 255);
}</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2"/>
</widget>
</widget>
</item>
<item>
<widget class="QFrame" name="frame_3">
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="label_2">
<property name="text">
<string>URL: </string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="urlEdit"/>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<widget class="QMenuBar" name="menubar">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>800</width>
<height>25</height>
</rect>
</property>
</widget>
<widget class="QStatusBar" name="statusbar"/>
</widget>
<resources/>
<connections/>
</ui>
# -*- coding: utf-8 -*-
# Form implementation generated from reading ui file 'main_window.ui'
#
# Created: Sat Apr 17 10:42:00 2010
# by: PyQt4 UI code generator 4.6
#
# WARNING! All changes made in this file will be lost!
from PyQt4 import QtCore, QtGui
class Ui_MainWindow(object):
def setupUi(self, MainWindow):
MainWindow.setObjectName("MainWindow")
MainWindow.resize(800, 600)
self.centralwidget = QtGui.QWidget(MainWindow)
self.centralwidget.setObjectName("centralwidget")
self.verticalLayout = QtGui.QVBoxLayout(self.centralwidget)
self.verticalLayout.setObjectName("verticalLayout")
self.frame_2 = QtGui.QFrame(self.centralwidget)
self.frame_2.setFrameShape(QtGui.QFrame.StyledPanel)
self.frame_2.setFrameShadow(QtGui.QFrame.Raised)
self.frame_2.setObjectName("frame_2")
self.horizontalLayout_2 = QtGui.QHBoxLayout(self.frame_2)
self.horizontalLayout_2.setObjectName("horizontalLayout_2")
self.label = QtGui.QLabel(self.frame_2)
self.label.setObjectName("label")
self.horizontalLayout_2.addWidget(self.label)
self.searchEdit = QtGui.QLineEdit(self.frame_2)
self.searchEdit.setObjectName("searchEdit")
self.horizontalLayout_2.addWidget(self.searchEdit)
self.verticalLayout.addWidget(self.frame_2)
self.scrollArea = QtGui.QScrollArea(self.centralwidget)
self.scrollArea.setWidgetResizable(True)
self.scrollArea.setObjectName("scrollArea")
self.scrollAreaContent = QtGui.QWidget(self.scrollArea)
self.scrollAreaContent.setGeometry(QtCore.QRect(0, 0, 778, 425))
self.scrollAreaContent.setStyleSheet("""QWidget#scrollAreaContent {
background-color: rgb(255, 255, 255);
}""")
self.scrollAreaContent.setObjectName("scrollAreaContent")
self.verticalLayout_2 = QtGui.QVBoxLayout(self.scrollAreaContent)
self.verticalLayout_2.setObjectName("verticalLayout_2")
self.scrollArea.setWidget(self.scrollAreaContent)
self.verticalLayout.addWidget(self.scrollArea)
self.frame_3 = QtGui.QFrame(self.centralwidget)
self.frame_3.setFrameShape(QtGui.QFrame.StyledPanel)
self.frame_3.setFrameShadow(QtGui.QFrame.Raised)
self.frame_3.setObjectName("frame_3")
self.horizontalLayout = QtGui.QHBoxLayout(self.frame_3)
self.horizontalLayout.setObjectName("horizontalLayout")
self.label_2 = QtGui.QLabel(self.frame_3)
self.label_2.setObjectName("label_2")
self.horizontalLayout.addWidget(self.label_2)
self.urlEdit = QtGui.QLineEdit(self.frame_3)
self.urlEdit.setObjectName("urlEdit")
self.horizontalLayout.addWidget(self.urlEdit)
self.verticalLayout.addWidget(self.frame_3)
MainWindow.setCentralWidget(self.centralwidget)
self.menubar = QtGui.QMenuBar(MainWindow)
self.menubar.setGeometry(QtCore.QRect(0, 0, 800, 25))
self.menubar.setObjectName("menubar")
MainWindow.setMenuBar(self.menubar)
self.statusbar = QtGui.QStatusBar(MainWindow)
self.statusbar.setObjectName("statusbar")
MainWindow.setStatusBar(self.statusbar)
self.retranslateUi(MainWindow)
QtCore.QMetaObject.connectSlotsByName(MainWindow)
def retranslateUi(self, MainWindow):
MainWindow.setWindowTitle(QtGui.QApplication.translate("MainWindow", "QVideoob", None, QtGui.QApplication.UnicodeUTF8))
self.label.setText(QtGui.QApplication.translate("MainWindow", "Search: ", None, QtGui.QApplication.UnicodeUTF8))
self.label_2.setText(QtGui.QApplication.translate("MainWindow", "URL: ", None, QtGui.QApplication.UnicodeUTF8))
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>MiniVideo</class>
<widget class="QFrame" name="MiniVideo">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>464</width>
<height>111</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="leftMargin">
<number>9</number>
</property>
<property name="topMargin">
<number>5</number>
</property>
<property name="bottomMargin">
<number>5</number>
</property>
<item>
<widget class="QLabel" name="imageLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
<item>
<layout class="QFormLayout" name="formLayout">
<property name="fieldGrowthPolicy">
<enum>QFormLayout::ExpandingFieldsGrow</enum>
</property>
<item row="0" column="0">
<widget class="QLabel" name="label_5">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Title</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLabel" name="titleLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<weight>50</weight>
<italic>true</italic>
<bold>false</bold>
</font>
</property>
<property name="text">
<string>TextLabel</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_8">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Duration</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLabel" name="durationLabel">
<property name="text">
<string>TextLabel</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_4">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Author</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLabel" name="authorLabel">
<property name="text">
<string>TextLabel</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_2">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Date</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QLabel" name="dateLabel">
<property name="text">
<string>TextLabel</string>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="label_3">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Rating</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QLabel" name="ratingLabel">
<property name="text">
<string>TextLabel</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>
# -*- coding: utf-8 -*-
# Form implementation generated from reading ui file 'minivideo.ui'
#
# Created: Sat Apr 17 11:04:00 2010
# by: PyQt4 UI code generator 4.6
#
# WARNING! All changes made in this file will be lost!
from PyQt4 import QtCore, QtGui
class Ui_MiniVideo(object):
def setupUi(self, MiniVideo):
MiniVideo.setObjectName("MiniVideo")
MiniVideo.resize(464, 111)
MiniVideo.setFrameShape(QtGui.QFrame.StyledPanel)
MiniVideo.setFrameShadow(QtGui.QFrame.Raised)
self.horizontalLayout = QtGui.QHBoxLayout(MiniVideo)
self.horizontalLayout.setContentsMargins(9, 5, -1, 5)
self.horizontalLayout.setObjectName("horizontalLayout")
self.imageLabel = QtGui.QLabel(MiniVideo)
sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Preferred)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.imageLabel.sizePolicy().hasHeightForWidth())
self.imageLabel.setSizePolicy(sizePolicy)
self.imageLabel.setObjectName("imageLabel")
self.horizontalLayout.addWidget(self.imageLabel)
self.formLayout = QtGui.QFormLayout()
self.formLayout.setFieldGrowthPolicy(QtGui.QFormLayout.ExpandingFieldsGrow)
self.formLayout.setObjectName("formLayout")
self.label_5 = QtGui.QLabel(MiniVideo)
font = QtGui.QFont()
font.setWeight(75)
font.setBold(True)
self.label_5.setFont(font)
self.label_5.setObjectName("label_5")
self.formLayout.setWidget(0, QtGui.QFormLayout.LabelRole, self.label_5)
self.titleLabel = QtGui.QLabel(MiniVideo)
sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.MinimumExpanding, QtGui.QSizePolicy.Preferred)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.titleLabel.sizePolicy().hasHeightForWidth())
self.titleLabel.setSizePolicy(sizePolicy)
font = QtGui.QFont()
font.setWeight(50)
font.setItalic(True)
font.setBold(False)
self.titleLabel.setFont(font)
self.titleLabel.setObjectName("titleLabel")
self.formLayout.setWidget(0, QtGui.QFormLayout.FieldRole, self.titleLabel)
self.label_8 = QtGui.QLabel(MiniVideo)
font = QtGui.QFont()
font.setWeight(75)
font.setBold(True)
self.label_8.setFont(font)
self.label_8.setObjectName("label_8")
self.formLayout.setWidget(1, QtGui.QFormLayout.LabelRole, self.label_8)
self.durationLabel = QtGui.QLabel(MiniVideo)
self.durationLabel.setObjectName("durationLabel")
self.formLayout.setWidget(1, QtGui.QFormLayout.FieldRole, self.durationLabel)
self.label_4 = QtGui.QLabel(MiniVideo)
font = QtGui.QFont()
font.setWeight(75)
font.setBold(True)
self.label_4.setFont(font)
self.label_4.setObjectName("label_4")
self.formLayout.setWidget(2, QtGui.QFormLayout.LabelRole, self.label_4)
self.authorLabel = QtGui.QLabel(MiniVideo)
self.authorLabel.setObjectName("authorLabel")
self.formLayout.setWidget(2, QtGui.QFormLayout.FieldRole, self.authorLabel)
self.label_2 = QtGui.QLabel(MiniVideo)
font = QtGui.QFont()
font.setWeight(75)
font.setBold(True)
self.label_2.setFont(font)
self.label_2.setObjectName("label_2")
self.formLayout.setWidget(3, QtGui.QFormLayout.LabelRole, self.label_2)
self.dateLabel = QtGui.QLabel(MiniVideo)
self.dateLabel.setObjectName("dateLabel")
self.formLayout.setWidget(3, QtGui.QFormLayout.FieldRole, self.dateLabel)
self.label_3 = QtGui.QLabel(MiniVideo)
font = QtGui.QFont()
font.setWeight(75)
font.setBold(True)
self.label_3.setFont(font)
self.label_3.setObjectName("label_3")
self.formLayout.setWidget(4, QtGui.QFormLayout.LabelRole, self.label_3)
self.ratingLabel = QtGui.QLabel(MiniVideo)
self.ratingLabel.setObjectName("ratingLabel")
self.formLayout.setWidget(4, QtGui.QFormLayout.FieldRole, self.ratingLabel)
self.horizontalLayout.addLayout(self.formLayout)
self.retranslateUi(MiniVideo)
QtCore.QMetaObject.connectSlotsByName(MiniVideo)
def retranslateUi(self, MiniVideo):
MiniVideo.setWindowTitle(QtGui.QApplication.translate("MiniVideo", "Form", None, QtGui.QApplication.UnicodeUTF8))
self.label_5.setText(QtGui.QApplication.translate("MiniVideo", "Title", None, QtGui.QApplication.UnicodeUTF8))
self.titleLabel.setText(QtGui.QApplication.translate("MiniVideo", "TextLabel", None, QtGui.QApplication.UnicodeUTF8))
self.label_8.setText(QtGui.QApplication.translate("MiniVideo", "Duration", None, QtGui.QApplication.UnicodeUTF8))
self.durationLabel.setText(QtGui.QApplication.translate("MiniVideo", "TextLabel", None, QtGui.QApplication.UnicodeUTF8))
self.label_4.setText(QtGui.QApplication.translate("MiniVideo", "Author", None, QtGui.QApplication.UnicodeUTF8))
self.authorLabel.setText(QtGui.QApplication.translate("MiniVideo", "TextLabel", None, QtGui.QApplication.UnicodeUTF8))
self.label_2.setText(QtGui.QApplication.translate("MiniVideo", "Date", None, QtGui.QApplication.UnicodeUTF8))
self.dateLabel.setText(QtGui.QApplication.translate("MiniVideo", "TextLabel", None, QtGui.QApplication.UnicodeUTF8))
self.label_3.setText(QtGui.QApplication.translate("MiniVideo", "Rating", None, QtGui.QApplication.UnicodeUTF8))
self.ratingLabel.setText(QtGui.QApplication.translate("MiniVideo", "TextLabel", None, QtGui.QApplication.UnicodeUTF8))
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>Video</class>
<widget class="QDialog" name="Video">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>647</width>
<height>404</height>
</rect>
</property>
<property name="windowTitle">
<string>Video</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QLabel" name="titleLabel">
<property name="font">
<font>
<pointsize>12</pointsize>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="frameShape">
<enum>QFrame::Box</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<property name="text">
<string>TextLabel</string>
</property>
</widget>
</item>