Skip to content

Commit

Permalink
release 0.0.10
Browse files Browse the repository at this point in the history
  • Loading branch information
marguerite committed Nov 19, 2014
1 parent c16157e commit ba2e5ca
Show file tree
Hide file tree
Showing 6 changed files with 89 additions and 26 deletions.
2 changes: 0 additions & 2 deletions BiliFile.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ def biliMove(file, newfile=file, condition)

tmp = file + ".tmp"

p condition

open(file, 'r') do |f0|
open(tmp, 'w') do |f1|
f0.each_line do |line|
Expand Down
60 changes: 60 additions & 0 deletions BiliPlaylist.rb
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
module BiliPlaylist

require_relative 'BiliConfig'

class BiliPlaylist

def initialize(videos="")
@videos = videos
@hash = {}

@historyfile = File.join($configPath,"biligui.history")
@lastfile = File.join($configPath,"biligui.last")

split
end

Expand Down Expand Up @@ -134,6 +139,61 @@ def load(playlist="")

end

def history

io = open(@lastfile, 'w')
@hash.each_value { |item| io.puts item }
io.close

open(@lastfile,'r') do |f|
open(@historyfile, 'a') do |f1|
f.each_line do |line|
f1.puts line
end
end
end

duplicate([@lastfile,@historyfile])

end

def duplicate(files)

files.each do |file|
array = []
i = 0

open(file,'r') do |f|
f.each_line do |line|
line.chomp!
array[i] = line
i+=1
end
end

new = array.uniq

io = open(file, 'w')
new.each {|value| io.puts value}
io.close
end
end

def last

str = ""

open(@lastfile,'r') do |f|
f.each_line do |line|
str += line
end
end

p str
return str

end

end

end
12 changes: 6 additions & 6 deletions BiliWeb.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@ class BiliParser
include BiliConfig
include BiliFile

@@index = "bilibili.tv.html"
@@indexfile = File.join($cachePath,@@index)

def initialize(array=["http://bilibili.tv"])

@filename = {}
Expand All @@ -25,6 +22,9 @@ def initialize(array=["http://bilibili.tv"])

@pool = Queue.new

@index = "bilibili.tv.html"
@indexfile = File.join($cachePath,@index)

get

end
Expand All @@ -51,7 +51,7 @@ def clean
Thread.new {
file = @pool.pop

if file.index(@@index) then
if file.index(@index) then
biliMove(file,"line.index('/video/') && ! line.index('av271')")
else
p "[WARN] Don't know what to do!"
Expand All @@ -65,9 +65,9 @@ def clean
def parse

hash1 = {}
lev1 = @@indexfile + ".l1"
lev1 = @indexfile + ".l1"

biliMove(@@indexfile,lev1,"line.index('i-link')")
biliMove(@indexfile,lev1,"line.index('i-link')")

# parse level 1 pair
open(lev1) do |f|
Expand Down
26 changes: 20 additions & 6 deletions BiliWidgets.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,10 @@ class BiliGui < Qt::MainWindow
slots 'biliWeb()'
slots 'biliSave()'
slots 'biliLoad()'
slots 'biliHistory()'

Width = 800
Height = 550
@@configw = BiliConf.new
@@config = @@configw.load

def initialize
super
Expand All @@ -36,6 +35,10 @@ def initialize
@central.setObjectName("centralwidget")
setCentralWidget @central

@configw = BiliConf.new
@config = @configw.load
@last = BiliPlaylist.new.last

init_ui

resize Width, Height
Expand Down Expand Up @@ -81,6 +84,7 @@ def init_ui
biliUrlLabel = Qt::Label.new "Please paste Bilibili URL 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
Expand All @@ -95,6 +99,7 @@ def init_ui


connect biliWebButton, SIGNAL('clicked()'), self, SLOT('biliWeb()')
connect @urlArea, SIGNAL('textChanged()'), self, SLOT('biliHistory()')
connect @playButton, SIGNAL('clicked()'), self, SLOT('bilidanPlay()')
connect clearButton, SIGNAL('clicked()'), self, SLOT('clear()')

Expand Down Expand Up @@ -124,7 +129,7 @@ def init_ui
# Settings Tab
grid_Settings = Qt::GridLayout.new settingsTab
bilidanPathLabel = Qt::Label.new "Please enter your bilidan's path:", settingsTab
@bilidanPath = Qt::LineEdit.new @@config["BilidanPath"], settingsTab
@bilidanPath = Qt::LineEdit.new @config["BilidanPath"], settingsTab
bilidanButton = Qt::PushButton.new 'Choose', settingsTab

grid_Settings.addWidget bilidanPathLabel, 0, 0, 1, 1
Expand Down Expand Up @@ -207,7 +212,6 @@ def bilidanChoose
unless bilidanBin == nil then
if bilidanBin.index("bilidan.py") then
@bilidanPath.setText(bilidanBin)
@@configw.put("BilidanPath", bilidanBin)
else
@messageLabel.setText("[WARN] You didn't choose bilidan.py!")
end
Expand All @@ -216,8 +220,10 @@ def bilidanChoose

def bilidanAutoSave

p @bilidanPath.text
@@configw.put("BilidanPath", @bilidanPath.text)
# avoid waste resource
if @bilidanPath.text.index("bilidan.py") then
@configw.put("BilidanPath", @bilidanPath.text)
end

end

Expand Down Expand Up @@ -253,4 +259,12 @@ def biliSave
end
end

def biliHistory

if @urlArea.toPlainText.index("av") then
BiliPlaylist.new(@urlArea.toPlainText).history
end

end

end
3 changes: 3 additions & 0 deletions doc/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
0.0.10
* autosave bilidan path in input area
* regression: can not set biligui config
* autosave paste history & last pasted
* load last pasted URLs by default
* fix: don't use class variable, use local variable instead
0.0.9
* make it themeable (external stylesheet .qss)
* clean module usage, don't need to create wrapper classes
Expand Down
12 changes: 0 additions & 12 deletions doc/TODO
Original file line number Diff line number Diff line change
@@ -1,18 +1,6 @@
* let error message fade out
* autoload playlists
* capture more useful informations from console output (to fill BiliPlaylist metadata)
* more error detection (use raise maybe)
* custom look and feel
* play history
* query url to get title & author
* BiliDaemon.rb to run background tasks
* Playlist merge
** find all saved playlists
** merge into a temp big one
** and autoload in init_ui
** simulate "history" function, can also load "BiliPlaylist.history"

* thread safe!
* handle exceptions

future:
Expand Down

0 comments on commit ba2e5ca

Please sign in to comment.