| View previous topic :: View next topic |
| Author |
Message |
ege Voice
Joined: 25 Jul 2013 Posts: 6
|
Posted: Sat Jul 27, 2013 12:46 am Post subject: Youtube tcl - duration option |
|
|
hello,
i have this script by Ford_Lawnmower
https://pastee.org/ht3t7
how to add youtube video duration time spec into it ?
thank you. |
|
| Back to top |
|
 |
WazzaUK Voice
Joined: 02 Jul 2006 Posts: 19
|
Posted: Sun Aug 25, 2013 4:56 am Post subject: youtube video duration |
|
|
This should help:
$youtubevar is the current line of http data
| Code: | set youtubeduration ""
if {[regexp -nocase {<meta itemprop=\"duration\" content=\"(.*?)\">.*} $youtubevar match youtubeduration]} {
set youtubeduration "Duration: $youtubeduration"
set youtubeduration [string map [list {PT} {} {M} {:} {S} {}] $youtubeduration]
} |
I know this works. |
|
| Back to top |
|
 |
WazzaUK Voice
Joined: 02 Jul 2006 Posts: 19
|
Posted: Tue Sep 03, 2013 7:54 am Post subject: |
|
|
Heres an improved version... i know the code is a touch messy... Previous code wasnt 100% depending on the data from youtube...
| Code: | if {[regexp -nocase {<meta itemprop=\"duration\" content=\"(.*?)\">.*} $youtubevar match youtubeduration]} {
set youtubelength $youtubeduration
if {[regexp {M(.*?)S} $youtubevar match youtubeduration]} {
set videosecs $youtubeduration
}
set youtubeduration $youtubelength
if {[regexp {PT(.*?)M} $youtubevar match youtubeduration]} {
set videomins $youtubeduration
}
set totalseconds [expr {($videomins * 60) + $videosecs}]
set youtubeduration [clock format $totalseconds -format {%H:%M:%S}]
} |
Ive re-written most of original code - has much more info and functionality...
YouTube URL check v1.01 by WazzaUK - based on v.0.01 by Ford_Lawnmower |
|
| Back to top |
|
 |
WazzaUK Voice
Joined: 02 Jul 2006 Posts: 19
|
Posted: Tue Dec 31, 2013 1:40 am Post subject: Duration for Youtube |
|
|
Only just realised the previous code i provided doesnt work. Get invalid variable type for use with expr and +.
$data is http data, after proc completes $duration contains the duration.
Im sure the following code works, i use it in my youtube script.
| Code: |
if {[regexp -nocase {<meta itemprop=\"duration\" content=\"(.*?)\">.*} $data match duration]} {
set youtubelength $duration
if {[regexp {M(.*?)S} $duration match duration]} {
set videosecs $duration
}
set duration $youtubelength
if {[regexp {PT(.*?)M} $duration match duration]} {
set videomins $duration
}
set totalseconds [expr {($videomins * 60) + $videosecs}]
set duration [clock format $totalseconds -format {%H:%M:%S}]
}
|
|
|
| Back to top |
|
 |
SoUkSoU Voice
Joined: 11 Jan 2014 Posts: 13
|
Posted: Tue Jan 14, 2014 12:06 pm Post subject: Hey |
|
|
Can you provide the full tcl with the duration in it ?
Regards, |
|
| Back to top |
|
 |
WazzaUK Voice
Joined: 02 Jul 2006 Posts: 19
|
|
| Back to top |
|
 |
bunnybump Voice

Joined: 17 Aug 2012 Posts: 9
|
Posted: Sun Feb 23, 2014 12:50 am Post subject: Re: Full tcl script with duration... |
|
|
regarding to WazzUK posted, i got this error when i tried to run it on my eggdrop. i've try this tcl but it keeps telling me that there's an error with the script. here what i got:
| Code: | can't read "maxlen": no such variable
while executing
"string is integer -strict $maxlen"
invoked from within
"if {[string is integer -strict $maxlen]} {
if {($maxlen == "") || ($maxlen < 1)} {set maxlen 100}
} else { set maxlen "100" }"
(file "scripts/you.tcl" line 50)
|
what should i do to fix it? thank you in advance for the help. _________________ In the Beginning... Was the Command Line |
|
| Back to top |
|
 |
|