1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272
|
%% Copyright (C) 2005 Tycho Softworks.
%%
%% This file is free software; as a special exception the author gives
%% unlimited permission to copy and/or distribute it, with or without
%% modifications, as long as this notice is preserved.
%%
%% This program is distributed in the hope that it will be useful, but
%% WITHOUT ANY WARRANTY, to the extent permitted by law; without even the
%% implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
%%
%% This is url script definitions
use url
%% play a file from a url
macro url-play
keywords from
define %convert:96 %cookies:96 %path:96
const %temp "tmp:url-" %session.index
if !defined %from
then
error "url-missing"
return
endif
urlextension %from au al gsm wav mp3 ogg
return
@url:extension-missing
@url:extension-invalid
const %extension {.auto}
throw @url:process
@url:extension-au
const %extension {.au}
throw @url:process
@url:extension-al
const %extension {.al}
throw @url:process
@url:extension-gsm
const %extension {.gsm}
throw @url:process
@url:extension-wav
const %extension {.wav}
throw @url:process
@url:extension-mp3
const %extension {.mp3}
throw @url:process
@url:extension-ogg
const %extension {.ogg}
throw @url:process
@url:process
writepath %convert %temp extension=%session.extension
const %file "tmp:tmp-" %session.index %extension
writepath %path %file
const %encoding %session.encoding
if !defined %session.cookies
then
const %cfile "tmp:url-" %session.index {.dat}
writepath %cookies %cfile
const %session.cookies %cookies
erase %cfile
endif
urlprotocol %from http https ftp
error "url-invalid"
return
@url:playfile
play %temp
erase %temp
return
@url:protocol-missing
string %url size=512
url %url url.prefix / %from
libexec limit=$url.limit lib::url_fetch.sh %url \
%path %session.cookies %convert %encoding
throw @url:playfile
@url:protocol-http
@url:protocol-https
@url:protocol-ftp
const %url %from
libexec limit=$url.limit lib::url_fetch.sh %url \
%path %session.cookies %convert %encoding
throw @url:playfile
%% play a file from a url
macro url-prompt
keywords from
define %convert:96 %cookies:96 %path:96
const %temp "tmp:url-" %session.index
if !defined %from
then
error "url-missing"
return
endif
urlextension %from au al gsm wav mp3 ogg
return
@url:extension-missing
@url:extension-invalid
const %extension {.auto}
throw @url:process
@url:extension-au
const %extension {.au}
throw @url:process
@url:extension-al
const %extension {.al}
throw @url:process
@url:extension-gsm
const %extension {.gsm}
throw @url:process
@url:extension-wav
const %extension {.wav}
throw @url:process
@url:extension-mp3
const %extension {.mp3}
throw @url:process
@url:extension-ogg
const %extension {.ogg}
throw @url:process
@url:process
writepath %convert %temp extension=%session.extension
const %file "tmp:tmp-" %session.index %extension
writepath %path %file
const %encoding %session.encoding
if !defined %session.cookies
then
const %cfile "tmp:url-" %session.index {.dat}
writepath %cookies %cfile
const %session.cookies %cookies
erase %cfile
endif
urlprotocol %from http https ftp
error "url-invalid"
return
@url:playfile
prompt %temp
erase %temp
return
@url:protocol-missing
string %url size=512
url %url url.prefix / %from
libexec limit=$url.limit lib::url_fetch.sh %url \
%path %session.cookies %convert %encoding
throw @url:playfile
@url:protocol-http
@url:protocol-https
@url:protocol-ftp
const %url %from
libexec limit=$url.limit lib::url_fetch.sh %url \
%path %session.cookies %convert %encoding
throw @url:playfile
^dtmf
return
%% file a file from a url
macro url-fetch
keywords from file extension prefix
define %extension="" %prefix="" %cookies:96
begin
case !defined %from
error "url-missing"
return
case !defined %file
error "file-missing"
return
case !defined %session.cookies
const %cfile "tmp:url-" %session.index {.dat}
writepath %cookies %cfile
const %session.cookies %cookies
erase %cfile
endcase
writepath %test %file prefix=%prefix extension=%extension
if -empty %test then return
urlextension %test au gsm al ul wav
const %path %test
urlprotocol %from http https ftp
error "url-invalid"
return
@url:protocol-missing
string %url size=512
url %url $url.prefix / %from
libexec limit=$url.limit lib::url_fetch.sh %url %path %session.cookies
return
@url:protocol-http
@url:protocol-https
@url:protocol-ftp
const %url %from
libexec limit=$url.limit lib::url_fetch.sh %url %path %session.cookies
return
@url:extension-missing
@url:extension-au
@url:extension-wav
@url:extension-al
@url:extension-ul
@url:extension-gsm
goto url-audio encoding=%session.encoding
%% local macro to perform audio convert
local url-audio
writepath %convert %file prefix=%prefix extension=%extension
if -empty %convert then return
urlextension %from au al gsm wav mp3 ogg ul
return
@url:extension-missing
@url:extension-invalid
const %audioext {.auto}
throw @url:process
@url:extension-au
const %audioext {.au}
throw @url:process
@url:extension-al
const %audioext {.al}
throw @url:process
@url:extension-ul
const %audioext {.ul}
throw @url:process
@url:extension-gsm
const %audioext {.gsm}
throw @url:process
@url:extension-wav
const %audioext {.wav}
throw @url:process
@url:extension-mp3
const %audioext {.mp3}
throw @url:process
@url:extension-ogg
const %audioext {.ogg}
throw @url:process
@url:process
const %temp "tmp:tmp-" %session.index %audioext
writepath %path %temp
urlprotocol %from http https ftp
error "url-invalid"
return
@url:protocol-http
@url:protocol-https
@url:protocol-ftp
const %url %from
libexec limit=$url.limit lib::url_fetch.sh %url \
%path %session.cookies %convert %encoding
return
@url:protocol-missing
string %url size=512
url %url url.prefix / %from
libexec limit=$url.limit lib::url_fetch.sh %url \
%path %session.cookies %convert %encoding
return
|