[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: [kubeplayer] lib: add video download option
From: Robert Riemann <robert.riemann () physik ! hu-berlin ! de>
Date: 2011-11-25 0:32:12
Message-ID: 20111125003212.DE469A60B9 () git ! kde ! org
[Download RAW message or body]
Git commit 9d6e6fff5799d4598e2d13a87c886784cd74a276 by Robert Riemann.
Committed on 19/11/2011 at 16:48.
Pushed by rriemann into branch 'master'.
add video download option
M +16 -2 lib/MainWindow.rb
M +2 -0 lib/Video.rb
M +3 -1 lib/provider/youtube/Youtube.rb
http://commits.kde.org/kubeplayer/9d6e6fff5799d4598e2d13a87c886784cd74a276
diff --git a/lib/MainWindow.rb b/lib/MainWindow.rb
index 95576d7..47b8478 100644
--- a/lib/MainWindow.rb
+++ b/lib/MainWindow.rb
@@ -104,6 +104,19 @@ class MainWindow < KDE::MainWindow
action.default_widget = @seekSlider
controlBar.add_action action
+ @resolutionLabel = Qt::Label.new self
+ controlBar.add_widget @resolutionLabel
+
+ action = collection.add_action 'download', KDE::Action.new( KDE::Icon.new( \
'download' ), i18n( 'Download' ), self ) + action.connect( SIGNAL( :triggered ) ) \
do + if @video
+ STDERR.puts @video.filename
+ saveTo = KDE::FileDialog::getSaveUrl(KDE::Url.new, \
"*.#{@video.fileextension.to_s}") + KIO::file_copy(@video.video_url, saveTo)
+ end
+ end
+ controlBar.add_action action
+
end
def initialize
@@ -176,8 +189,9 @@ class MainWindow < KDE::MainWindow
video = Video::get_type kurl
if video
connect(video, SIGNAL('got_video_url(QVariant)')) do |variant|
- video = variant.value
- @videoPlayer.play Phonon::MediaSource.new video.video_url
+ @video = variant.value
+ @videoPlayer.play Phonon::MediaSource.new @video.video_url
+ @resolutionLabel.text = "#{@video.resolution}p"
end
video.request_video_url
@listDock.hide
diff --git a/lib/Video.rb b/lib/Video.rb
index 29be192..ac7e244 100644
--- a/lib/Video.rb
+++ b/lib/Video.rb
@@ -117,6 +117,7 @@ class Video < Qt::Object
attr_reader :video_url
attr_reader :filename
+ attr_reader :fileextension
attr_reader :resolution
@@ -132,6 +133,7 @@ class Video < Qt::Object
@duration = nil
@resolution = nil
@filename = nil
+ @fileextension = nil
end
def to_s
diff --git a/lib/provider/youtube/Youtube.rb b/lib/provider/youtube/Youtube.rb
index 6c2c1d1..f8d4cfd 100644
--- a/lib/provider/youtube/Youtube.rb
+++ b/lib/provider/youtube/Youtube.rb
@@ -98,8 +98,10 @@ class Video < KubePlayer::Video
# STDERR.puts "available formats: #{@fmtUrlMap.keys.map {|k| \
NUMBER2FORMAT[k]}.join(' ')}" fmtUrlMap_by_Resolution = {}
@fmtUrlMap.each {|k,v| fmtUrlMap_by_Resolution[NUMBER2RESOLUTION[k]] = [k, \
v] } + # STDERR.puts fmtUrlMap_by_Resolution.inspect
@resolution, video = fmtUrlMap_by_Resolution.max
- @filename = "#{metaInfo[:title].gsub('+','_')}.#{NUMBER2FORMAT[video[0]]}"
+ @fileextension = NUMBER2FORMAT[video[0]]
+ @filename = "#{metaInfo[:title].gsub('+','_')}.#{@fileextension}"
# STDERR.puts "#{resolution}p, #{@filename}"
@video_url = KDE::Url.new video[1]
emit got_video_url(Qt::Variant.from_value(self))
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic