kbl 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +69 -9
- data/kbl.gemspec +1 -1
- data/lib/kbl.rb +1 -5
- data/lib/kbl/package.rb +1 -1
- data/lib/kbl/playlist.rb +1 -1
- data/lib/kbl/serializable.rb +26 -0
- data/lib/kbl/song.rb +1 -1
- data/lib/kbl/templates/package.haml +13 -0
- data/lib/kbl/templates/playlist.haml +7 -0
- data/lib/kbl/templates/song.haml +13 -0
- data/lib/kbl/version.rb +1 -1
- metadata +9 -8
- data/lib/kbl/serializable/package.rb +0 -37
- data/lib/kbl/serializable/playlist.rb +0 -24
- data/lib/kbl/serializable/song.rb +0 -26
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e852e61e09bff3e8f49b0b67999c00f03c748dc6
|
4
|
+
data.tar.gz: 011283369cf6e2aca80718485037472c6dcf46ab
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 613a8f0deac003c24877f13ee87b87e4244a2af4917a1da4317f9f02aa5162062bc6c01db555b53a033b14acbab31afc30c1a08567173d9beab42de4bbdbd19d
|
7
|
+
data.tar.gz: bafdad4ab784c08a475e80f5d41bc8f36c33841bebab12a38c0c73144a1449c84774f2e2d1d396d38f80ed2fd61d76e3e1b59b4fa3364b2f737132ea813156a9
|
data/README.md
CHANGED
@@ -42,20 +42,80 @@ end
|
|
42
42
|
puts kbl.to_kbl #=> the KBL source code (in XML)
|
43
43
|
```
|
44
44
|
|
45
|
-
|
45
|
+
## CLI Tool
|
46
46
|
|
47
47
|
This gem provides a CLI tool `kbl` that simplifies playlist importing / dumping via Song IDs (pathname).
|
48
48
|
|
49
|
-
|
49
|
+
### Import
|
50
50
|
|
51
|
-
|
52
|
-
# Import KKBOX Songs from a list of IDs through [FILENAME] or STDIN.
|
53
|
-
kbl import [INPUT_FILE or STDIN]
|
51
|
+
Import KKBOX Songs from a list of IDs in a file or STDIN.
|
54
52
|
|
55
|
-
|
56
|
-
|
53
|
+
**Important**: this will add songs to your Temporary Playlist and after running, your Now Playing will become the last song in the list.
|
54
|
+
|
55
|
+
```shell-session
|
56
|
+
$ kbl import [INPUT_FILE or STDIN]
|
57
57
|
```
|
58
58
|
|
59
|
+
Sample Input:
|
60
|
+
|
61
|
+
17645049
|
62
|
+
22021717
|
63
|
+
38369455
|
64
|
+
30772971
|
65
|
+
30772977
|
66
|
+
|
67
|
+
Which maps to these songs:
|
68
|
+
|
69
|
+
| Song ID | Artist | Song Name | Album |
|
70
|
+
|---------|--------|-----------|-------|
|
71
|
+
| 17645049 | 日笠陽子 | 美しき残酷な世界 | 美しき残酷な世界 |
|
72
|
+
| 22021717 | 水樹奈々×T.M.Revolution | 革命デュアリズム | 革命デュアリズム |
|
73
|
+
| 38369455 | 喜多村英梨 | Birth | 証×明 -SHOMEI- |
|
74
|
+
| 30772971 | 藍井エイル | サンビカ | AUBE |
|
75
|
+
| 30772977 | 藍井エイル | シリウス | AUBE |
|
76
|
+
|
77
|
+
Result:
|
78
|
+
|
79
|
+
* The above songs will be added to the bottom of Temporary Playlist.
|
80
|
+
* Your Now Playing song will become シリウス by 藍井エイル from AUBE album.
|
81
|
+
|
82
|
+
### Dump
|
83
|
+
|
84
|
+
Dump meta data of KKBOX songs from your local KKBOX client database.
|
85
|
+
|
86
|
+
**Important:** You have to run `dump` immediately after `import` command. If you ran `import` and start playing another album or artist hot songs within KKBOX, your Temporary Playlist will be cleaned up and you'll lose the meta data, unless you have other playlists containing those songs.
|
87
|
+
|
88
|
+
```shell-session
|
89
|
+
$ kbl dump [INPUT_FILE or STDIN] [-o=OUTPUT_FILE or STDOUT] [-f=tsv]
|
90
|
+
```
|
91
|
+
|
92
|
+
The default output format is TSV (Tab-Separated Values, the Tab version of CSV.)
|
93
|
+
|
94
|
+
For tabular output like TSV and CSV, the order of columns will be:
|
95
|
+
|
96
|
+
* Song ID (pathname)
|
97
|
+
* Song Name
|
98
|
+
* Artist ID
|
99
|
+
* Artist Name
|
100
|
+
* Album ID
|
101
|
+
* Album Name
|
102
|
+
|
103
|
+
Sample Input:
|
104
|
+
|
105
|
+
17645049
|
106
|
+
22021717
|
107
|
+
38369455
|
108
|
+
30772971
|
109
|
+
30772977
|
110
|
+
|
111
|
+
Sample Output (TSV):
|
112
|
+
|
113
|
+
17645049 美麗殘酷的世界 (「進擊的巨人」片尾曲) 945776 日笠陽子(Hikasa Yoko) 1685970 美麗殘酷的世界
|
114
|
+
22021717 革命 Dualism 1176631 水樹奈奈 × T.M.Revolution 2084207 革命 Dualism (特別盤)
|
115
|
+
38369455 Birth 830288 喜多村英梨 (Eri Kitamura) 3847501 証×明-SHOMEI-
|
116
|
+
30772971 聖歌(動畫『雙斬少女KILL la KILL』插曲) 475589 藍井艾露 (Eir Aoi) 2828979 Aube初回限定盤
|
117
|
+
30772977 天狼星(動畫『雙斬少女KILL la KILL』片頭曲) 475589 藍井艾露 (Eir Aoi) 2828979 Aube初回限定盤
|
118
|
+
|
59
119
|
## Required Song Meta Data
|
60
120
|
|
61
121
|
To generate a working KBL file, the following data for every song must be provided.
|
@@ -102,9 +162,9 @@ Can exist multiple times across multiple playlists.
|
|
102
162
|
|
103
163
|
## TODO
|
104
164
|
|
105
|
-
* Make a CLI tool for generating KBL files.
|
106
|
-
* Scraping meta data from KKBOX client database from given Song IDs.
|
107
165
|
* A workflow for how to build a KBL file from Song IDs.
|
166
|
+
* More output formats for `kbl dump` command, e.g. CSV, JSON.
|
167
|
+
* In Dump command, warn when there are some IDs returns 0, which means it is required to remove those songs from Library and import again.
|
108
168
|
|
109
169
|
## License
|
110
170
|
|
data/kbl.gemspec
CHANGED
@@ -18,7 +18,7 @@ Gem::Specification.new do |spec|
|
|
18
18
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
19
|
spec.require_paths = ["lib"]
|
20
20
|
|
21
|
-
spec.add_dependency '
|
21
|
+
spec.add_dependency 'haml', '~> 4.0.5'
|
22
22
|
spec.add_dependency 'thor', '~> 0.19.1'
|
23
23
|
spec.add_dependency 'sqlite3', '~> 1.3.9'
|
24
24
|
|
data/lib/kbl.rb
CHANGED
@@ -5,9 +5,5 @@ module KBL
|
|
5
5
|
autoload :Playlist, "kbl/playlist"
|
6
6
|
autoload :Song, "kbl/song"
|
7
7
|
|
8
|
-
|
9
|
-
autoload :Package, "kbl/serializable/package"
|
10
|
-
autoload :Playlist, "kbl/serializable/playlist"
|
11
|
-
autoload :Song, "kbl/serializable/song"
|
12
|
-
end
|
8
|
+
autoload :Serializable, "kbl/serializable"
|
13
9
|
end
|
data/lib/kbl/package.rb
CHANGED
data/lib/kbl/playlist.rb
CHANGED
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'haml'
|
2
|
+
|
3
|
+
module KBL::Serializable
|
4
|
+
def self.included(base)
|
5
|
+
base.send :extend, ClassMethods
|
6
|
+
end
|
7
|
+
|
8
|
+
def to_xml
|
9
|
+
self.class.template.render(self)
|
10
|
+
end
|
11
|
+
|
12
|
+
module ClassMethods
|
13
|
+
def template
|
14
|
+
@template ||= load_template
|
15
|
+
end
|
16
|
+
|
17
|
+
def load_template
|
18
|
+
filename = File.expand_path("templates/#{template_name}.haml", File.dirname(__FILE__))
|
19
|
+
template = Haml::Engine.new(File.read(filename))
|
20
|
+
end
|
21
|
+
|
22
|
+
def template_name
|
23
|
+
self.to_s.downcase.split("::").last
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
data/lib/kbl/song.rb
CHANGED
@@ -0,0 +1,13 @@
|
|
1
|
+
%utf-8_data
|
2
|
+
%kkbox_package
|
3
|
+
%kkbox_ver= self.kkbox_version
|
4
|
+
|
5
|
+
- @playlists.each do |playlist|
|
6
|
+
= playlist.to_xml
|
7
|
+
|
8
|
+
%package
|
9
|
+
%ver 1.0
|
10
|
+
%descr 包裝說明
|
11
|
+
%packdate= self.date.strftime("%Y%m%d%H%M%S")
|
12
|
+
%playlistcnt= self.playlists.size
|
13
|
+
%songcnt= self.total_songs
|
@@ -0,0 +1,13 @@
|
|
1
|
+
%song_data
|
2
|
+
%song_name= self.name
|
3
|
+
%song_artist= self.artist
|
4
|
+
%song_album= self.album
|
5
|
+
%song_genre= self.genre
|
6
|
+
%song_preference= self.preference
|
7
|
+
%song_playcnt= self.play_count
|
8
|
+
%song_pathname= self.pathname
|
9
|
+
%song_type= self.type
|
10
|
+
%song_lyricsexist= self.has_lyrics
|
11
|
+
%song_artist_id= self.artist_id
|
12
|
+
%song_album_id= self.album_id
|
13
|
+
%song_song_idx= self.song_index
|
data/lib/kbl/version.rb
CHANGED
metadata
CHANGED
@@ -1,29 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kbl
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yu-Cheng Chuang
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-05-
|
11
|
+
date: 2014-05-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: haml
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
17
|
- - ~>
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: 4.0.5
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - ~>
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
26
|
+
version: 4.0.5
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: thor
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -99,10 +99,11 @@ files:
|
|
99
99
|
- lib/kbl/cli.rb
|
100
100
|
- lib/kbl/package.rb
|
101
101
|
- lib/kbl/playlist.rb
|
102
|
-
- lib/kbl/serializable
|
103
|
-
- lib/kbl/serializable/playlist.rb
|
104
|
-
- lib/kbl/serializable/song.rb
|
102
|
+
- lib/kbl/serializable.rb
|
105
103
|
- lib/kbl/song.rb
|
104
|
+
- lib/kbl/templates/package.haml
|
105
|
+
- lib/kbl/templates/playlist.haml
|
106
|
+
- lib/kbl/templates/song.haml
|
106
107
|
- lib/kbl/version.rb
|
107
108
|
homepage: ''
|
108
109
|
licenses:
|
@@ -1,37 +0,0 @@
|
|
1
|
-
module KBL::Serializable
|
2
|
-
module Package
|
3
|
-
def to_kbl
|
4
|
-
to_kbl_node.to_xml({
|
5
|
-
:encoding => 'UTF-8',
|
6
|
-
:indent => 2,
|
7
|
-
:indent_text => " "
|
8
|
-
}).gsub(/<(.+)\/>/, '<\1></\1>')
|
9
|
-
end
|
10
|
-
|
11
|
-
def to_kbl_node
|
12
|
-
doc = Nokogiri::XML.parse(<<-XML, nil, nil, Nokogiri::XML::ParseOptions::NOBLANKS)
|
13
|
-
<utf-8_data><kkbox_package></kkbox_package></utf-8_data>
|
14
|
-
XML
|
15
|
-
|
16
|
-
package_node = doc.css("kkbox_package").first
|
17
|
-
|
18
|
-
package_node << "<kkbox_ver>#{self.kkbox_version}</kkbox_ver>"
|
19
|
-
|
20
|
-
@playlists.each do |playlist|
|
21
|
-
package_node << playlist.to_kbl_node
|
22
|
-
end
|
23
|
-
|
24
|
-
package_node << Nokogiri::XML.parse(<<-XML, nil, nil, Nokogiri::XML::ParseOptions::NOBLANKS).root
|
25
|
-
<package>
|
26
|
-
<ver>1.0</ver>
|
27
|
-
<descr>包裝說明</descr>
|
28
|
-
<packdate>#{ self.date.strftime("%Y%m%d%H%M%S") }</packdate>
|
29
|
-
<playlistcnt>#{ self.playlists.size }</playlistcnt>
|
30
|
-
<songcnt>#{ self.total_songs }</songcnt>
|
31
|
-
</package>
|
32
|
-
XML
|
33
|
-
|
34
|
-
doc.root
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
@@ -1,24 +0,0 @@
|
|
1
|
-
require 'nokogiri'
|
2
|
-
|
3
|
-
module KBL::Serializable
|
4
|
-
module Playlist
|
5
|
-
def to_kbl_node
|
6
|
-
node = Nokogiri::XML.parse(<<-XML, nil, nil, Nokogiri::XML::ParseOptions::NOBLANKS)
|
7
|
-
<playlist>
|
8
|
-
<playlist_id>#{ self.id }</playlist_id>
|
9
|
-
<playlist_name>#{ self.name }</playlist_name>
|
10
|
-
<playlist_descr>#{ self.description }</playlist_descr>
|
11
|
-
<playlist_data></playlist_data>
|
12
|
-
</playlist>
|
13
|
-
XML
|
14
|
-
|
15
|
-
data_node = node.css("playlist_data").first
|
16
|
-
|
17
|
-
@songs.each do |song|
|
18
|
-
data_node << song.to_kbl_node
|
19
|
-
end
|
20
|
-
|
21
|
-
node.root
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
@@ -1,26 +0,0 @@
|
|
1
|
-
require 'nokogiri'
|
2
|
-
|
3
|
-
module KBL::Serializable
|
4
|
-
module Song
|
5
|
-
def to_kbl_node
|
6
|
-
doc = Nokogiri::XML.parse(<<-XML, nil, nil, Nokogiri::XML::ParseOptions::NOBLANKS)
|
7
|
-
<song_data>
|
8
|
-
<song_name>#{ self.name }</song_name>
|
9
|
-
<song_artist>#{ self.artist }</song_artist>
|
10
|
-
<song_album>#{ self.album }</song_album>
|
11
|
-
<song_genre>#{ self.genre }</song_genre>
|
12
|
-
<song_preference>#{ self.preference }</song_preference>
|
13
|
-
<song_playcnt>#{ self.play_count }</song_playcnt>
|
14
|
-
<song_pathname>#{ self.pathname }</song_pathname>
|
15
|
-
<song_type>#{ self.type }</song_type>
|
16
|
-
<song_lyricsexist>#{ self.has_lyrics }</song_lyricsexist>
|
17
|
-
<song_artist_id>#{ self.artist_id }</song_artist_id>
|
18
|
-
<song_album_id>#{ self.album_id }</song_album_id>
|
19
|
-
<song_song_idx>#{ self.song_index }</song_song_idx>
|
20
|
-
</song_data>
|
21
|
-
XML
|
22
|
-
|
23
|
-
doc.root
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|