dec -z won't count in seconds - 01/02/15 09:22 PM
So this is for my songrequest script, and uses my browser to open up the youtube video. Using sockets I have retrieved and documented the length of the video and the link to the video. For the system to work the %y_t value must decrease in seconds to follow the video length but it runs too fast! Why is this happening?
For reference here is my video length retrieval link.
Code:
on *:TEXT:!play &:#: { if ($2 == start) { set %y_ss $ini(songrequest.ini,0) while (%y_ss) { var %y_s $ini(songrequest.ini,1) var %y_t 0 if (%y_t == 0) { url -a www.youtube.com/watch?v= $+ %y_s set %y_t $ini(songrequest.ini,%y_s,1) while (%y_t) { dec -z %y_t echo -a %y_t } remini songrequest.ini %y_s dec %y_ss } } } }
For reference here is my video length retrieval link.
Code:
on *:TEXT:!yt &:#: { if ($sock(YTube)) .sockclose YTube if (*www.youtube.com* iswm $2) { set %y_l $right($2,11) } else { set %y_l $2 } if ($ini(songrequest.ini,%y_l,0) == 1) { msg # This song is already in my playlist. unset %y_l } else { set %y_d 1 set %y_n $nick set %y_newb $chan sockopen -e YTube gdata.youtube.com 443 } } on *:SOCKOPEN:YTube: { sockwrite -nt $sockname GET /feeds/api/videos/ $+ %y_l HTTP/1.1 sockwrite -nt $sockname Host: gdata.youtube.com $+ $str($crlf,2) } on *:SOCKREAD:YTube: { if (!$sockerr) { var %sockreader | sockread %sockreader if (*duration='*'* iswm %sockreader) { set %y_len $gettok(%sockreader,46,39) if (%y_len > 240) { msg %y_newb Videos cannot be longer than 4 minutes. unset %y_* } else { writeini -n Dinocoins.ini $+(%y_newb,.,%y_n) dinocoins $calc($readini(Dinocoins.ini,$+(%y_newb,.,%y_n),dinocoins) - %y_d) writeini songrequest.ini %y_l %y_len %y_n msg %y_newb Your song has been added, you now have $readini(Dinocoins.ini,$+(%y_newb,.,%y_n),dinocoins) $+ . unset %y_* } } } else { msg %y_newb There was an error unset y_* } }