Skip to content

Commit

Permalink
release v0.0.11, i18n and bilidan parameters support
Browse files Browse the repository at this point in the history
  • Loading branch information
marguerite committed Dec 13, 2014
1 parent d78262b commit 0220fee
Show file tree
Hide file tree
Showing 17 changed files with 428 additions and 36 deletions.
8 changes: 5 additions & 3 deletions BiliConfig.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,18 @@ def initialize(name="biligui.conf", path=$configPath)
@name = name
@path = path

unless Dir.exists?(@path) then
unless Dir.exist?(@path) then
Dir.mkdir @path
end

unless Dir.exists?(File.join(@path,"playlist")) then
unless Dir.exist?(File.join(@path,"playlist")) then
Dir.mkdir(File.join(@path,"playlist"))
end

@config = File.join(path, name)
@configEntries = {}

unless File.exists?(@config) then
unless File.exist?(@config) then
biliTouch(@config)
else
io = File.open(@config, "r")
Expand All @@ -35,6 +35,8 @@ def initialize(name="biligui.conf", path=$configPath)
key = line.gsub(/=.*/,"")
if line.index("mpvflags") then
value = line.gsub(/mpvflags=/,"")
elsif line.index("danmaku2assflags") then
value = line.gsub(/danmaku2assflags=/,"")
else
value = line.gsub(/.+=/,"")
end
Expand Down
2 changes: 1 addition & 1 deletion BiliGui.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/ruby
#!/usr/bin/env ruby
require_relative 'BiliWidgets'
app = Qt::Application.new ARGV
open("data/style.qss",'r') {|f| app.setStyleSheet(f.read)}
Expand Down
3 changes: 1 addition & 2 deletions BiliPlaylist.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
module BiliPlaylist

require 'fileutils'
require_relative 'BiliConfig'

class BiliPlaylist
Expand Down Expand Up @@ -60,8 +61,6 @@ def hash

def save(filename="")

require 'fileutils'

playlist = filename

default_playlist = "#{$configPath}/playlist/biliplaylist.m3u8"
Expand Down
2 changes: 1 addition & 1 deletion BiliWeb.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ module BiliWeb

$cachePath = File.join($configPath, 'cache')

Dir.mkdir($cachePath) unless Dir.exists?($cachePath)
Dir.mkdir($cachePath) unless Dir.exist?($cachePath)

class BiliParser

Expand Down
54 changes: 29 additions & 25 deletions BiliWidgets.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
require 'Qt'
require 'qtwebkit'
require 'open3'
require 'gettext'
require_relative 'BiliConfig'
require_relative 'BiliPlaylist'
require_relative 'BiliWeb'
Expand All @@ -10,6 +12,9 @@ class BiliGui < Qt::MainWindow
include BiliPlaylist
include BiliWeb

include GetText
bindtextdomain("BiliGui")

slots 'clear()'
slots 'bilidanChoose()'
slots 'bilidanAutoSave()'
Expand All @@ -28,7 +33,7 @@ class BiliGui < Qt::MainWindow
def initialize
super

setWindowTitle "BiliGui"
setWindowTitle _("BiliGui")
setWindowIcon(Qt::Icon.new("data/bilibili.svgz"))

@central = Qt::Widget.new self
Expand Down Expand Up @@ -66,9 +71,9 @@ def init_ui
webTab = Qt::Widget.new
settingsTab = Qt::Widget.new

biliTabs.addTab playlistTab, "BiliGui Playlist"
biliTabs.addTab webTab, "Bilibili.tv"
biliTabs.addTab settingsTab, "BiliGui Settings"
biliTabs.addTab playlistTab, _("BiliGui Playlist")
biliTabs.addTab settingsTab, _("BiliGui Settings")
biliTabs.addTab webTab, _("Bilibili.tv")

@messageLabel = Qt::Label.new
@messageLabel.setStyleSheet("color: #ff0000;")
Expand All @@ -81,13 +86,13 @@ def init_ui
# Playlist Tab
grid_Playlist = Qt::GridLayout.new playlistTab

biliUrlLabel = Qt::Label.new "Please paste Bilibili URL below", playlistTab
biliWebButton = Qt::PushButton.new 'Visit bilibili.tv (experimental)', playlistTab
biliUrlLabel = Qt::Label.new _("Please paste Bilibili URL/bangou below"), playlistTab
biliWebButton = Qt::PushButton.new _("Visit bilibili.tv (experimental)"), playlistTab
@urlArea = Qt::TextEdit.new playlistTab
@urlArea.setText(@last)
ctlPanel = Qt::Widget.new playlistTab
@playButton = Qt::PushButton.new 'Play', playlistTab
clearButton = Qt::PushButton.new 'Clear', 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
Expand All @@ -106,8 +111,8 @@ def init_ui
## controlPanel layout
grid_ctlPanel = Qt::GridLayout.new ctlPanel

ctlLoadButton = Qt::PushButton.new 'Load', ctlPanel
ctlSaveButton = Qt::PushButton.new 'Save', ctlPanel
ctlLoadButton = Qt::PushButton.new _("Load"), ctlPanel
ctlSaveButton = Qt::PushButton.new _("Save"), ctlPanel
ctlBlank = Qt::Label.new ctlPanel

grid_ctlPanel.addWidget ctlLoadButton, 0, 0, 1, 1
Expand All @@ -129,14 +134,14 @@ def init_ui
# Settings Tab
grid_Settings = Qt::GridLayout.new settingsTab

bilidanPathLabel = Qt::Label.new "Please enter your bilidan's path:", settingsTab
bilidanPathLabel = Qt::Label.new _("Please enter your bilidan's path:"), settingsTab
@bilidanPath = Qt::LineEdit.new @config["BilidanPath"], settingsTab
bilidanButton = Qt::PushButton.new 'Choose', settingsTab
bilidanButton = Qt::PushButton.new _("Choose"), settingsTab

bilidanMpvFlagsLabel = Qt::Label.new "mpv flags for bilidan:", settingsTab
bilidanMpvFlagsLabel = Qt::Label.new _("mpv flags for bilidan:"), settingsTab
@bilidanMpvFlags = Qt::LineEdit.new @config["mpvflags"], settingsTab

bilidanD2AFlagsLabel = Qt::Label.new "danmaku2ass flags for bilidan:", settingsTab
bilidanD2AFlagsLabel = Qt::Label.new _("danmaku2ass flags for bilidan:"), settingsTab
@bilidanD2AFlags = Qt::LineEdit.new @config["danmaku2assflags"], settingsTab

grid_Settings.addWidget bilidanPathLabel, 0, 0, 1, 1
Expand Down Expand Up @@ -167,7 +172,6 @@ def clear
end

def bilidanPlay
require 'open3'

urlText = @urlArea.toPlainText()
urlHash = BiliPlaylist.new(urlText).hash
Expand All @@ -177,11 +181,11 @@ def bilidanPlay
parameter = "#{mpvflagsText} #{d2aflagsText}"

# validate bilidan.py path
unless ! pathText.empty? && File.exists?(pathText) then
if File.exists?('./bilidan.py') then
unless ! pathText.empty? && File.exist?(pathText) then
if File.exist?('./bilidan.py') then
pathText = "./bilidan.py"
else
error = "[ERR] you need to choose bilidan.py!"
error = _("[ERR] you need to choose bilidan.py!")
@messageLabel.setText(error)
end
end
Expand All @@ -190,15 +194,15 @@ def bilidanPlay

# play all videos
urlHash.each_value do |value|
p "Now Playing: #{value}"
print _("Now Playing: ") + value

command = "#{pathText} #{parameter} #{value}"
@thread.start(command)

end

else
error = "[ERR] you have to paste an URL!"
error = _("[ERR] you have to paste at least one URL/bangou!")
@messageLabel.setText(error)
end

Expand All @@ -224,12 +228,12 @@ def bilidanPlyButtonCtl
end

def bilidanChoose
bilidanBin = Qt::FileDialog.getOpenFileName(self, "Please choose your bilidan.py", "#{$userHome}", "Python files (*.py)")
bilidanBin = Qt::FileDialog.getOpenFileName(self, _("Please choose your bilidan.py"), "#{$userHome}", _("Python files (*.py)"))
unless bilidanBin == nil then
if bilidanBin.index("bilidan.py") then
@bilidanPath.setText(bilidanBin)
else
@messageLabel.setText("[WARN] You didn't choose bilidan.py!")
@messageLabel.setText(_("[WARN] You didn't choose bilidan.py!"))
end
end
end
Expand Down Expand Up @@ -260,7 +264,7 @@ def biliWeb
end

def biliLoad
playlist = Qt::FileDialog.getOpenFileName(self, "Please choose your playlist", "#{$configPath}/playlist", "Playlist file (*.m3u8)")
playlist = Qt::FileDialog.getOpenFileName(self, _("Please choose your playlist"), "#{$configPath}/playlist", _("Playlist file (*.m3u8)"))
unless playlist == nil then
hash = BiliPlaylist.new.load(playlist)
str = ""
Expand All @@ -273,9 +277,9 @@ def biliLoad

def biliSave
if @urlArea.toPlainText().empty? then
p "No video URL can be saved at all!"
print _("No video URL/bangou can be saved at all!")
else
filename = Qt::FileDialog.getSaveFileName(self, "Please choose save location", "#{$configPath}/playlist", "Playlist file (*.m3u8)")
filename = Qt::FileDialog.getSaveFileName(self, _("Please choose save location"), "#{$configPath}/playlist", _("Playlist file (*.m3u8)"))
unless filename == nil then
playlist = BiliPlaylist.new(@urlArea.toPlainText())
playlist.save(filename)
Expand Down
33 changes: 29 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

## BiliGui

BiliGui is an All-in-one frontend for all the Bilibili black magic in Linux world.
BiliGui is an all-in-one frontend for all the Bilibili black magic in Linux world.

It's written in `ruby` + `Qt` and highly modular, eg: using [BiliDan](https://github.com/m13253/BiliDan)
as player backend (further callback `mpv`), [Biligrab](https://github.com/cnbeining/Biligrab) as download module
Expand All @@ -12,21 +12,38 @@ and a lot more.

### Features

* It's the 1st GUI program for bilibili.tv under Linux!
* No more Flash!
* Callback a powerful media player (`mpv`) to actually play videos, so hardware decoding is possible
* You can place your bilidan elsewhere
* Multi URL/bangou support
* Mix-paste URL/bangou, as you like
* Load/save playlists (in m3u8, a popular format) so you can share w/ friends or backup yourself
* Continously play, so you can paste once and watch a looooong time, and don't need to bother switch tabs (like what you do in a browser)
* Autosave, you don't need to worry about losing anything!
* Theming support
* I18n ready

### Installation

You need ruby and `qtbindings` gem.
You need ruby, `qtbindings` and `gettext` gems.

If you have rvm, run

rvm install ruby-2.1.4
gem install qtbindings (need libqt4-devel and libQtWebKit-devel installed)
gem install gettext

If you're using openSUSE, which is the best distribution ever, just add `devel:languages:ruby:extensions` repo
and run:

sudo zypper in rubygem-qtbindings (ruby is already installed because of YaST installtion)
sudo zypper in rubygem-qtbindings rubygem-gettext (ruby is already installed because of YaST installtion)

bilidan, danmaku2ass are also required (because we're just a `GUI`), please refer to their github pages to see related dependencies.

#### Optional
### Optional

#### Destkop integration

Place BiliGui.desktop anywhere that is easy to you.

Expand All @@ -44,6 +61,14 @@ If you're using system ruby and qtbindings gem, you should change it to:

Or the .desktop file will not run.

#### I18N

If you're using rvm, please put the mo file(s) to path like:

~/.rvm/gems/ruby-2.1.4/gems/gettext-3.1.4/locale/zh/LC_MESSAGES/BiliGui.mo

instead of system-wide directory like /usr/share/locale/zh_CN/LC_MESSAGES, or you won't see language changed.

### License

MIT
Binary file modified data/screenshot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions doc/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
0.0.11
* add support for bilidan parameters (some)
* fix BiliGui.rb's shebang (rvm friendly)
* i18n support
0.0.10
* autosave bilidan path in input area
* regression: can not set biligui config
Expand Down
Loading

0 comments on commit 0220fee

Please sign in to comment.