vp-fora (1486B)
1 #!/usr/bin/env rc 2 # 3 # Pattern: ^http://fora.tv/ 4 # 5 # TODO: Fallback to rtmp stream when mp4 is unavailable. 6 7 . vp-base $0 $* 8 9 vp_data $* | vp_awk ' 10 /full_program_clipid =/ { 11 gsub(/;/, ""); 12 set("clipid", $4) 13 exit 0 14 }' 15 16 vp_data 'http://fora.tv/fora/fora_player_full?cid='^$"clipid | 17 sed 's,</[A-Za-z_]+>,&\n,g' | vp_awk ' 18 { 19 match($0, /<[a-zA-Z-_]+/) 20 tag = substr($0, RSTART+1, RLENGTH-1) 21 str = substr($0, RSTART + RLENGTH + 1) 22 match(str, "</" tag) 23 tags[tag] = substr(str, 1, RSTART - 1) 24 } 25 END { 26 if (ENVIRON["vp_format"] == "high" && tags["encode_url_high_available"] == 1) 27 tags["encode_url"] = tags["encode_url_high"] 28 sub(/\.flv$/, "", tags["encode_url"]) 29 30 setary("vp_rtmpresult", \ 31 "-s http://fora.tv/FORA_Player_5.ver_1_51.swf " \ 32 "-r rtmp://" tags["encode_origin"] "/" tags["encode_application"] "/" tags["encode_url"] " " \ 33 "-t rtmp://" tags["encode_origin"] "/" tags["encode_application"] " " \ 34 "-y " tags["encode_url"]) 35 }' 36 37 vp_rtmpresult $vp_rtmpresult 38 39 if (false) { 40 vp_data 'http://fora.tv/fora/fora_player_full?cid='^$"clipid | vp_awk ' 41 { 42 match($0, /<[a-zA-Z-_]+/) 43 tag = substr($0, RSTART+1, RLENGTH-1) 44 str = substr($0, RSTART + RLENGTH + 1) 45 match(str, "</" tag) 46 tags[tag] = substr(str, 1, RSTART - 1) 47 } 48 END { 49 name = tags["encode_url"] 50 sub(/-[^-]+-[0-9]+.flv$/, "", name) 51 set("vp_result", "http://foratv.vo.llnwd.net/o33/mp4/" name "-" ENVIRON["clipid"] "-new_download.mp4") 52 }' 53 }