a jig to convert new youtube playlists into TSE text file

53 views
Skip to first unread message

Larry

unread,
Apr 16, 2012, 3:15:59 PM4/16/12
to GoogleSemWare TSE, tse...@freelists.org
/*** jigtube.s
Since Youtube changed its look, the text structure of the playlists also
changed. This macro should work on the current new look of the
playlists. If anything changes in the future, the macro can be altered
to reflect the changes.
***/
/***
This macro will convert a YouTube playlist webpage into a column
formatted TSE text file.
***/

//jigtube.s - make list of youtube playlist songs

<ctrlshift y> execmacro("jigtube")

/***
Usage hints:
1. inspect and change macro when the playlist text changes
2. copy an entire playlist webpage to the Windows Clipboard
3. if more than one webpage for the playlist, copy and paste all of them
into the work file
4. you can also copy and paste portions of the playlist
5. paste the webpage into an empty TSE file
6. execute this macro on it
7. the result will be all of the undeleted song times and titles in columns
8. save the file if desired


add uploader's youtube name

New youtube format apr 2012
***/

proc main()

string xs[100]=splitpath(currfilename(),_name_)+":"
string a[255]="" // uploader name

// look for webpage identifier to remove top portion of page
if lfind(" Play All"+" Share Like Loading...","ig")
markline(1,currline())
delblock()
endif

// look for a playlist identifier to remove bottom portion of page
if lfind(" views"+" About GeesePa's YouTube","igb")
markline(currline(),numlines())
delblock()
endif

// strip out unnecessary text and format
begfile()
repeat
if lfind(":[0-9][0-9]watch","icgx")
// remove beginning of line
lfind(" ","bc")
markstream()
begline()
delblock()

// get the uploader name
down()
lfind("by","icg")
wordright()
a=getword()

// add uploader name to title line
up()
endline()
inserttext(" ("+a+")")
begline()
else // remove extraneous lines
delline()
up()
endif
until not down()

// clean up odd text
begfile()
lreplace("watch later ","","ing")
lreplace("error ","","ing")
lreplace("watched ","","ing")

// get the playlist name to use in the chart
if ask("Playlist Name",xs,_edit_history_) and length(xs)
else
xs=splitpath(currfilename(),_name_)
endif

// add playlist name to each line in chart
repeat
begline()
inserttext(format("":3-length(str(val(gettext(1,3)))):" "),_insert_)
begline()
inserttext(xs,_insert_)
until not down()

goto ending
ending:

sound(9000,30)

end

Reply all
Reply to author
Forward
0 new messages