Skip to content

Commit

Permalink
release 0.0.7
Browse files Browse the repository at this point in the history
  • Loading branch information
marguerite committed Nov 16, 2014
1 parent c377200 commit 2651a54
Show file tree
Hide file tree
Showing 6 changed files with 69 additions and 27 deletions.
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
marguerite <[email protected]>
69 changes: 42 additions & 27 deletions BiliWidgets.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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()'
Expand All @@ -65,7 +68,6 @@ def initialize

setWindowTitle "BiliGui"
setWindowIcon(Qt::Icon.new("bilibili.svgz"))
#setStyleSheet "QWidget {color: #ff3d6a;}"

init_ui

Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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()
Expand All @@ -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
Expand Down
21 changes: 21 additions & 0 deletions COPYING
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (c) <2014> <[email protected]>

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.
3 changes: 3 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -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
Expand Down
1 change: 1 addition & 0 deletions THANKS
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Yichao Yu (yyc): gave me a link, from therre I learned how to multithread (Big help really)
1 change: 1 addition & 0 deletions TODO
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
* more error detection (use raise maybe)
* custom look and feel
* play history
* http and bangou mixed paste

future:

Expand Down

0 comments on commit 2651a54

Please sign in to comment.