#!/usr/local/bin/ruby # # # ladio playlist aggregator for Pocket PCs # (convert list.csv into .m3u) # # # You can redistribute it and/or modify it under the GPL2. # Copyright 2005 (c) phonondrive # # *) ladio: http://live.ladio.livedoor.com/ # # headline_addr = "http://yp.ladio.livedoor.jp/stats/list.csv" begin require 'open-uri' data = Array.new() csv = open( headline_addr ) {|f| f.read }.gsub(/,\n/, ",0\n").split("\n") (1..(csv.size.to_i - 1)).each do |index| i = csv[index].split(',') # URL,GNL,NAM,TIT,MNT,TIM,TIMS,CLN,CLNS,SRV,PRT,TYP,BIT if ( i.size == 13 ) then data.push [ i[7].to_i, "#{i[2]} #{i[1]}\nhttp://#{i[9]}:#{i[10]}#{i[4]}" ] end end print "EXTM3U\n" data.sort.reverse.each {|item| print "#EXTINF:-1,#{item[1]}\n" } rescue Exception puts 'Content-Type: text/plain\n' puts "#$! (#{$!.class})\n" puts $@.join("\n\n") end