<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-gb">
	<link rel="self" type="application/atom+xml" href="https://forum.eggheads.org/app.php/feed/topic/19829" />

	<title>egghelp/eggheads community</title>
	<subtitle>Discussion of eggdrop bots, shell accounts and tcl scripts.</subtitle>
	<link href="https://forum.eggheads.org/index.php" />
	<updated>2014-12-06T15:27:52-04:00</updated>

	<author><name><![CDATA[egghelp/eggheads community]]></name></author>
	<id>https://forum.eggheads.org/app.php/feed/topic/19829</id>

		<entry>
		<author><name><![CDATA[spithash]]></name></author>
		<updated>2014-12-06T15:27:52-04:00</updated>

		<published>2014-12-06T15:27:52-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=103348#p103348</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=103348#p103348"/>
		<title type="html"><![CDATA[How do I combine the results to one line on KYoutube script]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=103348#p103348"><![CDATA[
So I got this script from the archive, it is really a cool script. I modified it a bit to fit my needs and it works great, but my question is if I can combine the results from all the 3 lines of output  to 1 line and split the results if it has to, let's say for example after 440 chars.<br><br>As I've seen it's currently using this: <div class="codebox"><p>Code: </p><pre><code>set lines [split $data "\n"]</code></pre></div>I hope I explain things the right way here <img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_smile.gif" width="15" height="15" alt=":)" title="Smile"><br><div class="codebox"><p>Code: </p><pre><code># KYoutube.tcl v1.4## Author: Outsider# Evolutions : Krypte (krypte@europnet.org)## Example :# &lt;Krypte&gt; http://www.youtube.com/watch?v=s7L2PVdrb_8# &lt;KBot&gt; [Youtube] Title: Game Of Thrones "Official" Show Open (HBO) | Duration: 1min 42sec | Views: 11021898## You can also search a video using !youtube argument## Change Log v1.4 :# Add activation on chan !yact (on|off) enables or disables script for active channel (flags "mno" only)# Improvement of the duration format (code from JazZ)# Translation in Englishsetudef flag yactpackage require http#bind pub mno|mno !yact YouTube-Activate#bind pubm - *http://*youtu*/watch* pubm:youtubebind ctcp - * action:youtubebind pub - !youtube pub:youtubebind pub - !yt pub:youtube# procedure for activate KYoutube.tcl on a channelproc YouTube-Activate {nick host hand chan text} {if {![channel get $chan yact] &amp;&amp; $text == "on"} {catch {channel set $chan +yact}putserv "notice $nick :YouTube: enabled for $chan"putlog "YouTube: script enabled (by $nick for $chan)"} elseif {[channel get $chan yact] &amp;&amp; $text == "off"} {catch {channel set $chan -yact}putserv "notice $nick :YouTube: disabled for $chan"putlog "YouTube: script disabled (by $nick for $chan)"} else {putserv "notice $nick :YouTube: !yact (on|off) enables or disables script for active channel"}}# procedure for matching on action, e.g * Krypte is watching http://www.youtube.com/watch?v=s7L2PVdrb_8proc action:youtube {nick host hand dest keyword args} {        if {[channel get $dest yact]} {        set args [lindex $args 0]        if {![validchan $dest]} {return}        if {$keyword == "ACTION" &amp;&amp; [string match *http://*youtu*/watch* $args]} {pubm:youtube $nick $host $hand $dest $args}}}# main youtube procedure on textproc pubm:youtube {nick host hand chan args} {        if {[channel get $chan yact]} {        set args [lindex $args 0]        while {[regexp -- {(http:\/\/.*youtub.*/watch.*)} $args -&gt; url args]} {                while {[regexp -- {v=(.*)&amp;?} $url -&gt; vid url]} {                        set vid [lindex [split $vid &amp;] 0]                        set gurl "http://gdata.youtube.com/feeds/api/videos/$vid"                        set search [http::formatQuery v 2 alt jsonc prettyprint true]                        set token [http::config -useragent "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.11) Gecko/20071127 Firefox/2.0.0.11" -accept "*/*"]                        set token [http::geturl "$gurl?$search"]                        set data [::http::data $token]                        http::cleanup $token                        set lines [split $data "\n"]                        set title ""                        set duration ""                        set viewCount ""                        foreach line $lines {                                if {$title==""} {set title [lindex [regexp -all -nocase -inline {\"title\"\: \"(.*)\"} $line] 1]}                                if {$duration==""} {set duration [lindex [regexp -all -nocase -inline {\"duration\"\: ([0-9]+)} $line] 1]}                                if {$viewCount==""} {set viewCount [lindex [regexp -all -nocase -inline {\"viewCount\"\: ([0-9]+)} $line] 1]}                        }                        set title [yturldehex $title]                        putmsg $chan "\[Youtube\] Title: \002$title\002 | Duration: \002[shortduration $duration]\002 | Views: \002$viewCount\002"                }        }}}# Search procedure, e.g !youtube game of thronesproc pub:youtube {nick host hand chan args} {        if {[channel get $chan yact]} {        set args [lindex $args 0]        if {$args == ""} {                putnotc $nick "Command to search: \002!youtube &lt;argument&gt;\002"                return        }        set search [http::formatQuery v 2 alt jsonc q $args orderby viewCount max-results 3 prettyprint true]        set token [http::config -useragent "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.11) Gecko/20071127 Firefox/2.0.0.11" -accept "*/*"]        set token [http::geturl "http://gdata.youtube.com/feeds/api/videos?$search"]        set data [::http::data $token]        http::cleanup $token        set totalitems [lindex [regexp -all -nocase -inline {\"totalItems\"\: ([0-9]+)} $data] 1]#        putnotc $nick "\[Youtube Search\] There is $totalitems results for your search on \002$args\002"        set lines [split $data "\n"]        set results ""        foreach line $lines {                if {[regexp -all -nocase -inline {\"id\"\: \"(.*)\"} $line] != ""} {                        set id [lindex [regexp -all -nocase -inline {\"id\"\: \"(.*)\"} $line] 1]                        lappend results $id                }                if {[regexp -all -nocase -inline {\"title\"\: \"(.*)\"} $line] != ""} {                        set result($id,title) [yturldehex [lindex [regexp -all -nocase -inline {\"title\"\: \"(.*)\"} $line] 1]]                }                if {[regexp -all -nocase -inline {\"duration\"\: ([0-9]+)} $line] != ""} {                        set result($id,duration) [lindex [regexp -all -nocase -inline {\"duration\"\: ([0-9]+)} $line] 1]                }                if {[regexp -all -nocase -inline {\"viewCount\"\: ([0-9]+)} $line] != ""} {                        set result($id,viewCount) [lindex [regexp -all -nocase -inline {\"viewCount\"\: ([0-9]+)} $line] 1]                }        }        foreach res $results {                putmsg $chan "\[Youtube\] Title: \002$result($res,title)\002 | Duration: \002[shortduration $result($res,duration)]\002 | Views: \002$result($res,viewCount)\002 | Link: \002http://www.youtube.com/watch?v=$res\002"        }}}proc yturldehex {string} {        regsub -all {[\[\]]} $string "" string        set string [subst [regsub -nocase -all {\&amp;#([0-9]{2,4});} $string {[format %c \1]}]]        return [string map {" \"} $string]}# Format the duration from seconds to x hours y mins z secproc shortduration {seconds} {            set hours [expr {$seconds / 3600}]            set minutes [expr {($seconds / 60) % 60}]            set seconds [expr {$seconds % 60}]            set res ""             if {$hours != 0} {append res "$hours hrs "}                        if {$minutes != 0} {append res "$minutes\min "}            if {$seconds != 0} {append res "$seconds\sec"}            return $res}putlog "KYoutube.tcl v1.4 Loaded."</code></pre></div>Also, I'm not sure if the developer of this script will watch this thread, but, is is easy to fetch and parse in the video results, the current video <strong class="text-strong">upload date</strong>? Just exactly as it's parsing the video views for example, or the duration.<br><br>Thanks.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=9145">spithash</a> — Sat Dec 06, 2014 3:27 pm</p><hr />
]]></content>
	</entry>
	</feed>
