Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Serverless api gateway #5

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// Place your settings in this file to overwrite default and user settings.
{
"files.associations": {
"*.src": "perl"
},
"editor.wordWrap": "off",
"files.encoding": "utf8",
"files.autoGuessEncoding": false
}
93 changes: 48 additions & 45 deletions Cover Art#KKBox.src
Original file line number Diff line number Diff line change
Expand Up @@ -6,65 +6,68 @@
# #################################

[Name]=KKbox
[BasedOn]=http://www.kkbox.com
[IndexUrl]=http://www.kkbox.com/tw/tc/search.php?search=album&word=%s
[AlbumUrl]=http://www.kkbox.com
[WordSeperator]=+
[IndexFormat]=%_url%|%album%|%artist%
[BasedOn]=http://localhost:3000/
[IndexUrl]=http://localhost:3000/api/searchAlbum?keyword=%s
[AlbumUrl]=http://localhost:3000/api/albums?id=
[WordSeparator]=%20
[IndexFormat]=%Artist%|%Album%|%_url%|%Year%
[SearchBy]=%album%
[UserAgent]=1
[Encoding]=url-utf-8


[ParserScriptIndex]=...
# ###################################################################
# I N D E X
# ###################################################################
# ##############################
# I N D E X #
# ##############################
debug "on" "c:\\debug_kkbox1.htm"

json "ON"

# debug "on" "d:\\debug_kkbox1.htm"
json_select_object "albums"
json_foreach "data"

findline "class=\"search-group\""
# Artist
json_select_object "artist"
json_select "name"
sayrest
json_unselect_object
say "|"

do
findline "class=\"album\""
findline "class=\"cover\""
# Album
json_select "name"
sayrest
say "|"

# Url
findinline "href=\""
sayuntil "\""
say "|"
# Url
json_select "id"
sayrest
say "|"

# Album
findinline "title=\""
sayuntil "\""
say "|"
# Year
json_select "release_date"
sayuntil "\""

# Artist
findline "playlist-sharer"
findline "<a href"
findinline "title=\""
sayuntil "\""
saynewline
saynewline

findline "<div class" 2
findinline "class=\""
while "album"
json_foreach_end
json_unselect_object


[ParserScriptAlbum]=...
# ###################################################################
# A L B U M
# ###################################################################
#debug "on" "d:\\debug_kkbox2.htm"

# CoverURL
# outputto "Album"
findline "class=\"fa fa-angle-right\""
findline "span"
findinline "span>"
# sayuntil "</span>"

# CoverURL
outputto "coverurl"
findline "<img src=\""
findinline "src=\""
sayuntil "\""
debug "on" "c:\\debug_kkbox2.htm"

json "ON"

json_select_object "meta"

# Cover
json_select_object "image"
json_select "url"
outputto "coverurl"
sayrest
json_unselect_object

json_unselect_object
211 changes: 89 additions & 122 deletions KKBox.src
Original file line number Diff line number Diff line change
Expand Up @@ -6,48 +6,51 @@
# #################################

[Name]=KKbox
[BasedOn]=http://www.kkbox.com
[IndexUrl]=http://www.kkbox.com/tw/tc/search.php?search=album&word=%s
[AlbumUrl]=http://www.kkbox.com
[WordSeperator]=+
[IndexFormat]=%_url%|%Album%|%Artist%
[BasedOn]=http://localhost:3000/
[IndexUrl]=http://localhost:3000/api/searchAlbum?keyword=%s
[AlbumUrl]=http://localhost:3000/api/albums?id=
[WordSeparator]=%20
[IndexFormat]=%Artist%|%Album%|%_url%|%Year%
[SearchBy]=%album%
[UserAgent]=1
[Encoding]=url-utf-8


[ParserScriptIndex]=...
# ###################################################################
# I N D E X
# ###################################################################

# ##############################
# I N D E X #
# ##############################
debug "on" "c:\\debug_kkbox1.htm"

findline "class=\"search-group\""
json "ON"

do
findline "class=\"album\""
findline "class=\"cover\""
json_select_object "albums"
json_foreach "data"

# Url
findinline "href=\""
sayuntil "\""
say "|"
# Artist
json_select_object "artist"
json_select "name"
sayrest
json_unselect_object
say "|"

# Album
findinline "title=\""
sayuntil "\""
say "|"
# Album
json_select "name"
sayrest
say "|"

# Artist
findline "playlist-sharer"
findline "<a href"
findinline "title=\""
sayuntil "\""
saynewline
# Url
json_select "id"
sayrest
say "|"

findline "<div class" 2
findinline "class=\""
while "album"
# Year
json_select "release_date"
sayrest

saynewline

json_foreach_end
json_unselect_object


[ParserScriptAlbum]=...
Expand All @@ -56,97 +59,61 @@ while "album"
# ###################################################################
debug "on" "c:\\debug_kkbox2.htm"

# CoverURL
outputto "coverurl"
findline "class=\"album-pic\""
findline "<img src=\""
findinline "src=\""
sayuntil "\""


# Album
outputto "Album"
# findline "class=\"fa fa-angle-right\""
# findline "span"
findline "<h1"
moveline 1
# sayregexp "[^\n]+"
sayuntil "</"


gotoline 1
findline "class=\"media-tag"

# Artist
outputto "artist"
findline "tit-16"
moveline 1
findline ">"
findinline ">"
sayuntil "<"


# rewind
gotoline 1

findline "class=\"media-tag"
findline "</div"

# Genre
outputto "Genre"
moveline -1
findinline ">"
sayuntil "</"

# Year
outputto "Year"
moveline -3
findinline ">"
saynextnumber

findline "song-list js-song-list"

do
# Track
outputto "track temp"
findline "data-song_idx"
findinline "data-song_idx=\""
saynextnumber
say "|"

outputto "_length"
findline "class=\"time\""
findinline ">"
sayuntil "</"
say "|"

# Title
outputto "title temp"
findline "class=\"song-data"
findline "<a href="
findinline ">"
sayuntil "</"
say "|"

# tracks ++
outputto "tracks"
say "|"

findline "</li"
# findinline "</li "
moveline 2
findinline "<"

if "li class=\"clearfix\""
# outputto "track temp"
# say "|"
# outputto "title temp"
# say "|"
# outputto "tracks"
# say "|"
endif

while "li class=\"clearfix\""
json "ON"

json_select_object "meta"
# Album
json_select "name"
outputto "album"
sayrest

# Artist
json_select_object "artist"
json_select "name"
outputto "artist"
sayrest
json_unselect_object

# Year
json_select "release_date"
outputto "year"
sayrest

# Cover
json_select_object "image"
json_select "url"
outputto "coverurl"
sayrest
json_unselect_object

json_unselect_object

json_select_object "tracks"
json_foreach "data"
# Track number
json_select "track_number"
outputto "track temp"
sayrest
say "|"

# Length
outputto "_length"
json_select "_length"
sayrest
say "|"

# Title
outputto "title temp"
json_select "name"
sayrest
say "|"

# Tracks
outputto "tracks"
say "|"

json_foreach_end
json_unselect_object

outputto "title"
sayoutput "title temp"
Expand Down
Loading