From 2651a54011f2ed25934ef5f98a65bff94d14bb39 Mon Sep 17 00:00:00 2001 From: marguerite Date: Mon, 17 Nov 2014 00:19:54 +0800 Subject: [PATCH] release 0.0.7 --- AUTHORS | 1 + BiliWidgets.rb | 69 ++++++++++++++++++++++++++++++-------------------- COPYING | 21 +++++++++++++++ ChangeLog | 3 +++ THANKS | 1 + TODO | 1 + 6 files changed, 69 insertions(+), 27 deletions(-) create mode 100644 AUTHORS create mode 100644 COPYING create mode 100644 THANKS diff --git a/AUTHORS b/AUTHORS new file mode 100644 index 0000000..bc7b8d6 --- /dev/null +++ b/AUTHORS @@ -0,0 +1 @@ +marguerite diff --git a/BiliWidgets.rb b/BiliWidgets.rb index 40c8257..4308ee6 100644 --- a/BiliWidgets.rb +++ b/BiliWidgets.rb @@ -48,9 +48,12 @@ def load(playlist="") class BiliGui < Qt::Widget - slots 'bilidan()' slots 'clear()' slots 'bilidanChoose()' + slots 'bilidanPlay()' + slots 'bilidanLogOut()' + slots 'bilidanLogErr()' + slots 'bilidanPlyButtonCtl()' slots 'biliWeb()' slots 'biliSave()' slots 'biliLoad()' @@ -65,7 +68,6 @@ def initialize setWindowTitle "BiliGui" setWindowIcon(Qt::Icon.new("bilibili.svgz")) - #setStyleSheet "QWidget {color: #ff3d6a;}" init_ui @@ -98,7 +100,7 @@ def init_ui biliTabs.addTab webTab, "Bilibili.tv" biliTabs.addTab settingsTab, "BiliGui Settings" - @messageLabel = Qt::Label.new "" + @messageLabel = Qt::Label.new @messageLabel.setStyleSheet("color: #ff0000;") grid_biliTabs = Qt::GridLayout.new self @@ -113,20 +115,20 @@ def init_ui biliWebButton = Qt::PushButton.new 'Visit bilibili.tv (experimental)', playlistTab @urlArea = Qt::TextEdit.new playlistTab ctlPanel = Qt::Widget.new playlistTab - okButton = Qt::PushButton.new 'Play', playlistTab + @playButton = Qt::PushButton.new 'Play', playlistTab clearButton = Qt::PushButton.new 'Clear', playlistTab grid_Playlist.addWidget biliUrlLabel, 0, 0, 1, 1 grid_Playlist.addWidget biliWebButton, 0, 1, 1, 1 grid_Playlist.addWidget @urlArea, 1, 0, 1, 4 grid_Playlist.addWidget ctlPanel, 1, 4, 1, 1 - grid_Playlist.addWidget okButton, 2, 2, 1, 1 + grid_Playlist.addWidget @playButton, 2, 2, 1, 1 grid_Playlist.addWidget clearButton, 2, 3, 1, 1 grid_Playlist.setColumnStretch 0, 0 connect biliWebButton, SIGNAL('clicked()'), self, SLOT('biliWeb()') - connect okButton, SIGNAL('clicked()'), self, SLOT('bilidan()') + connect @playButton, SIGNAL('clicked()'), self, SLOT('bilidanPlay()') connect clearButton, SIGNAL('clicked()'), self, SLOT('clear()') ## controlPanel layout @@ -158,10 +160,21 @@ def init_ui grid_Settings.setColumnStretch 0, 0 connect bilidanButton, SIGNAL('clicked()'), self, SLOT('bilidanChoose()') + + # player thread + @thread = Qt::Process.new + + connect @thread, SIGNAL('readyReadStandardOutput()'), self, SLOT('bilidanLogOut()') + connect @thread, SIGNAL('readyReadStandardError()'), self, SLOT('bilidanLogErr()') + connect @thread, SIGNAL('finished(int, QProcess::ExitStatus)'), self, SLOT('bilidanPlyButtonCtl()') + end - def bilidan + def clear + @urlArea.clear + end + def bilidanPlay require 'open3' urlText = @urlArea.toPlainText() @@ -179,38 +192,40 @@ def bilidan end unless urlHash.empty? then - - urlHash.each_value do |value| + # play all videos + urlHash.each_value do |value| p "Now Playing: #{value}" command = "#{pathText} #{value}" - Open3.popen3(command) do |stdin, stdout, stderr, wait_thr| - stderr.each_line do |line| - # common error - unless line.index("Cache") then - @messageLabel.setText(line) - end - - #stdout.each_line {|line| p line} - - end - - unless wait_thr.value.success?() then - break - end - end - + @thread.start(command) + end else error = "[ERR] you have to paste an URL!" @messageLabel.setText(error) end + + # disable Play button here + @playButton.setEnabled false + end - def clear - @urlArea.clear() + def bilidanLogOut + stdout = @thread.readAllStandardOutput.to_s.chomp! + p stdout + end + + # bilidan? why buffer message redirected to stderr?! + def bilidanLogErr + stderr = @thread.readAllStandardError.to_s.chomp! + p stderr + end + + def bilidanPlyButtonCtl + # release Play button + @playButton.setEnabled true end def bilidanChoose diff --git a/COPYING b/COPYING new file mode 100644 index 0000000..d06aa5c --- /dev/null +++ b/COPYING @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) <2014> + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/ChangeLog b/ChangeLog index 632a958..4c9e292 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,6 @@ +0.0.8 +* Asynchronously play (Qt::Process), GUI won't freeze anymore! +* fix issue#2, disable playButton when there's something playing 0.0.7 * fix: BiliPlaylist::BiliSave can't override old file * bangou (avXXXXXX) paste support diff --git a/THANKS b/THANKS new file mode 100644 index 0000000..f6ef256 --- /dev/null +++ b/THANKS @@ -0,0 +1 @@ +Yichao Yu (yyc): gave me a link, from therre I learned how to multithread (Big help really) diff --git a/TODO b/TODO index 5d063ac..098c54f 100644 --- a/TODO +++ b/TODO @@ -4,6 +4,7 @@ * more error detection (use raise maybe) * custom look and feel * play history +* http and bangou mixed paste future: