egghelp.org community Forum Index
[ egghelp.org home | forum home ]
egghelp.org community
Discussion of eggdrop bots, shell accounts and tcl scripts.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Youtube tcl - duration option

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Requests
View previous topic :: View next topic  
Author Message
ege
Voice


Joined: 25 Jul 2013
Posts: 6

PostPosted: Sat Jul 27, 2013 12:46 am    Post subject: Youtube tcl - duration option Reply with quote

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
View user's profile Send private message
WazzaUK
Voice


Joined: 02 Jul 2006
Posts: 19

PostPosted: Sun Aug 25, 2013 4:56 am    Post subject: youtube video duration Reply with quote

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
View user's profile Send private message
WazzaUK
Voice


Joined: 02 Jul 2006
Posts: 19

PostPosted: Tue Sep 03, 2013 7:54 am    Post subject: Reply with quote

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
View user's profile Send private message
WazzaUK
Voice


Joined: 02 Jul 2006
Posts: 19

PostPosted: Tue Dec 31, 2013 1:40 am    Post subject: Duration for Youtube Reply with quote

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
View user's profile Send private message
SoUkSoU
Voice


Joined: 11 Jan 2014
Posts: 13

PostPosted: Tue Jan 14, 2014 12:06 pm    Post subject: Hey Reply with quote

Can you provide the full tcl with the duration in it ?

Regards,
Back to top
View user's profile Send private message
WazzaUK
Voice


Joined: 02 Jul 2006
Posts: 19

PostPosted: Wed Jan 29, 2014 4:58 pm    Post subject: Full tcl script with duration... Reply with quote

http://forum.egghelp.org/viewtopic.php?t=19596
Back to top
View user's profile Send private message
bunnybump
Voice


Joined: 17 Aug 2012
Posts: 9

PostPosted: Sun Feb 23, 2014 12:50 am    Post subject: Re: Full tcl script with duration... Reply with quote

WazzaUK wrote:
http://forum.egghelp.org/viewtopic.php?t=19596


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
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Requests All times are GMT - 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Forum hosting provided by Reverse.net

Powered by phpBB © 2001, 2005 phpBB Group
subGreen style by ktauber