<?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/20192" />

	<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>2016-07-24T03:53:32-04:00</updated>

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

		<entry>
		<author><name><![CDATA[caesar]]></name></author>
		<updated>2016-07-24T03:53:32-04:00</updated>

		<published>2016-07-24T03:53:32-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=105274#p105274</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=105274#p105274"/>
		<title type="html"><![CDATA[Shoutcast 2.47 tcl and sqlite3]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=105274#p105274"><![CDATA[
Your welcome, glad I could help. <img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_smile.gif" width="15" height="15" alt=":)" title="Smile"><p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=187">caesar</a> — Sun Jul 24, 2016 3:53 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[ricktee76]]></name></author>
		<updated>2016-07-23T15:08:25-04:00</updated>

		<published>2016-07-23T15:08:25-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=105272#p105272</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=105272#p105272"/>
		<title type="html"><![CDATA[Shoutcast 2.47 tcl and sqlite3]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=105272#p105272"><![CDATA[
thanks caesar, I've had to spend some time doing this as i'm new to tcl but i've finally got it done, your reply really helped point me in the right direction.<br>Much appreciated.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=12639">ricktee76</a> — Sat Jul 23, 2016 3:08 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[caesar]]></name></author>
		<updated>2016-07-22T08:08:30-04:00</updated>

		<published>2016-07-22T08:08:30-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=105269#p105269</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=105269#p105269"/>
		<title type="html"><![CDATA[Shoutcast 2.47 tcl and sqlite3]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=105269#p105269"><![CDATA[
Replace:<div class="codebox"><p>Code: </p><pre><code>if { [kdb eval {SELECT * FROM Songs WHERE Song=$cursong}] == 1} { </code></pre></div>with:<div class="codebox"><p>Code: </p><pre><code>if {[kdb eval {SELECT 1 FROM Songs WHERE Song=$cursong}]} {</code></pre></div>if you want to see if whatever you have in <em class="text-italics">$cursong</em> exists in the database, as it will return 1 for true and nothing for false.<br><br>Keep in mind that the <em class="text-italics">Song = $cursong</em> in the above query as is right now is in case sensitive mode, meaning <em class="text-italics">Something</em> is not equal with <em class="text-italics">something</em> or <em class="text-italics">SOMETHING</em>, or whatever variation you want to add. To make it ignore the case then add <em class="text-italics">COLLATE NOCASE</em> at the end:<div class="codebox"><p>Code: </p><pre><code>if {[kdb eval {SELECT 1 FROM Songs WHERE Song=$cursong COLLATE NOCASE}]} {</code></pre></div>Also, there's no need to do run the same query twice when you have the TRUE case with the above and can use an <em class="text-italics">else</em> statement like for the FALSE one:<div class="codebox"><p>Code: </p><pre><code>if {[kdb eval {SELECT 1 FROM Songs WHERE Song=$cursong}]} {      putlog "\00304Record already exists\003"} else {# do the inserts or whatever you wish}</code></pre></div>If <em class="text-italics">SongID</em> is the primary key and for some reason want to know it then replace the 1 with the <em class="text-italics">SongID</em> in the above statement. Always select what you will be using and don't be lazy and use * if you don't plan to use all that info.<br><br>Edit: I see that you use <em class="text-italics">ABS(RANDOM()) % (999999999 - 1) + 1</em> to create some random number representing the <em class="text-italics">SongID</em>. If you want a unique number that would also be auto-incremented, then I would be recreating the <em class="text-italics">Songs</em> table and dumping the <em class="text-italics">Ratings</em> one like this:<div class="codebox"><p>Code: </p><pre><code>CREATE TABLE Songs(SongID INTEGER PRIMARY KEY AUTOINCREMENT, Song TEXT, Rating REAL, Votes INTEGER, UNIQUE(Song))</code></pre></div>and when would insert something in the <em class="text-italics">Songs</em> table would just:<div class="codebox"><p>Code: </p><pre><code>INSERT INTO Songs (Song, Rating, Votes) VALUES ($cursong, 0, 0)</code></pre></div>and the SongID is automatically added.<br><br>Want to add votes to a certain song?<div class="codebox"><p>Code: </p><pre><code>UPDATE Songs SET Votes = Votes + 1 WHERE SongID = $id</code></pre></div>Want to calculate it's rating?<div class="codebox"><p>Code: </p><pre><code>UPDATE Songs SET Rating = $rating WHERE SongID = $id</code></pre></div>for example.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=187">caesar</a> — Fri Jul 22, 2016 8:08 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[ricktee76]]></name></author>
		<updated>2016-07-21T17:11:07-04:00</updated>

		<published>2016-07-21T17:11:07-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=105263#p105263</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=105263#p105263"/>
		<title type="html"><![CDATA[Shoutcast 2.47 tcl and sqlite3]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=105263#p105263"><![CDATA[
I have modified Domsen's Shoutcast script to SC2.47.<br>I would like it to add each song to the database as it is played. <br>This seems to do nothing, nor does it report errors. <br>All help appreciated.<br><div class="codebox"><p>Code: </p><pre><code>######## CHECK IF SONG EXISTS ##############                  putlog "\00309Checking if song is already in Database...\003"             set kdbfile "database.db"      sqlite3 kdb $kdbfile                          if { [kdb eval {SELECT * FROM Songs WHERE Song=$cursong}] == 1} {      putlog "\00304Record already exists\003"    }       if { [kdb eval {SELECT * FROM Songs WHERE Song=$songtitle}] == 0} {          kdb [eval { INSERT INTO Songs (SongID, Song) VALUES (ABS(RANDOM()) % (999999999 - 1) + 1, $cursong) }]          kdb [eval { INSERT INTO Ratings (SongID, Song, Rating, Votes) VALUES (ABS(RANDOM()) % (999999999 - 1) + 1, $cursong, 0,0) }]          putlog "\00309Song Succesfully Added.\003"         }           ########### END OF CHECK ################# </code></pre></div><p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=12639">ricktee76</a> — Thu Jul 21, 2016 5:11 pm</p><hr />
]]></content>
	</entry>
	</feed>
