mIRC Home    About    Download    Register    News    Help

Print Thread
#166197 07/12/06 04:11 PM
Joined: Dec 2006
Posts: 4
C
Self-satisified door
OP Offline
Self-satisified door
C
Joined: Dec 2006
Posts: 4
Hi. I have been struggling with this script for a couple of days now, and i need some help.

What it does is that it will get todays tv-shows from tvrage.com and send it to #mychan, on the command !tv. The problem is that it stops reading halfway. I found out that it always stops after 1460 bytes. Can't mirc read more that 1460 bytes?

Here is the script:
Code:
on *:text:!tv:#mychan: {
  sockopen tvragetonight www.tvrage.com 80
}

on *:sockopen:tvragetonight: {
  sockwrite -n $sockname GET /quickschedule.php HTTP/1.1
  sockwrite -n $sockname Host: www.tvrage.com
  sockwrite -n $sockname $crlf
}

on *:sockread:tvragetonight: {
  while ($sockerr == 0) {
    sockread -f %readdata
    if ($sockbr == 0) { sockclose $sockname }
    if ([DAY] isin %readdata) {
      if (%nextday == 1) { sockclose $sockname | halt }
      var %nextday 1
      msg #mychan NEW TV for $remove(%readdata,[DAY],[/DAY]) $+  (Time is GMT+1)
    }
    if ([time] isin %readdata) {
      if (%time != $null) { msg #mychan %time }
      var %temp $left($remove(%readdata,[TIME],[/TIME]),-3)
      var %time 0 $+ $calc($gettok(%temp,1,58) + 6 - 12) $+ : $+ $gettok(%temp,2,58) $+ :
    }
    if ([show] isin %readdata) {
      if (??:??: iswm $strip(%time)) { var %time %time $gettok($remove(%readdata,[SHOW],[/SHOW]),2,94) }
      else { var %time %time 9- $gettok($remove(%readdata,[SHOW],[/SHOW]),2,94) }
    }
  }
}


Hope someone can give me an answer smile
Thanx

/cryptonic

Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
Is there a line that is really long somewhere in there? Because you're using a regular variable and not a binary variable, if the line is over about 950 characters, it will fail. It should give you a "line too long" error, though.


Invision Support
#Invision on irc.irchighway.net
Joined: Dec 2006
Posts: 4
C
Self-satisified door
OP Offline
Self-satisified door
C
Joined: Dec 2006
Posts: 4
No errors, no long lines. Can't figure out what's wrong.

Currently today, the last line is:
[SHOW]NBC^30 Rock^01x07^http:

Where the full line is:
[SHOW]NBC^30 Rock^01x07^http://www.tvrage.com/shows/id-11215[/SHOW]

That's the 21st row on the page, and the size is 1460 bytes. I've tested other sites and get the same error. Always stops after 1460 bytes.

It seems to be a limit on how much data mirc can receive. I have searched everywhere and other ppl don't seem to have this problem.

This is the output i get:
Quote:

Date: Fri, 08 Dec 2006 01:01:55 GMT
Server: Apache/2.0.55 (Unix) PHP/5.0.5
X-Powered-By: PHP/5.0.5
Set-Cookie: visited=1; expires=Sat, 04 Dec 2021 01:01:56 GMT; path=/; domain=.tvrage.com
Transfer-Encoding: chunked
Content-Type: text/html; charset=UTF-8
3a75
[DAY]Thursday, 07 Dec 2006[/DAY]
[TIME]07:00 pm[/TIME]
[SHOW]NickToons^Kappa Mikey^01x18^http://www.tvrage.com/Kappa_Mikey[/SHOW]
[TIME]08:00 pm[/TIME]
[SHOW]Cartoon Network^Pokémon^09x34^http://www.tvrage.com/Pokemon[/SHOW]
[SHOW]NBC^My Name Is Earl^02x10^http://www.tvrage.com/My_Name_Is_Earl[/SHOW]
[SHOW]The CW^Smallville^06x09^http://www.tvrage.com/Smallville[/SHOW]
[SHOW]CBS^Survivor (US)^13x13^http://www.tvrage.com/Survivor[/SHOW]
[SHOW]My Network TV^Wicked Wicked Games^01x02^http://www.tvrage.com/shows/id-14649[/SHOW]
[TIME]08:30 pm[/TIME]
[SHOW]NBC^My Name Is Earl^02x11^http://www.tvrage.com/My_Name_Is_Earl[/SHOW]
[TIME]09:00 pm[/TIME]
[SHOW]CBS^CSI^07x10^http://www.tvrage.com/CSI[/SHOW]
[SHOW]NBC^Scrubs^06x02^http://www.tvrage.com/Scrubs[/SHOW]
[SHOW]The CW^Supernatural^02x09^http://www.tvrage.com/Supernatural[/SHOW]
[SHOW]CBS^Survivor (US)^13x13^http://www.tvrage.com/Survivor[/SHOW]
[SHOW]FOX^The O.C.^04x06^http://www.tvrage.com/The_OC[/SHOW]
[SHOW]Spike TV^TNA iMPACT!^03x50^http://www.tvrage.com/TNA_Impact[/SHOW]
[SHOW]My Network TV^Watch Over Me^01x02^http://www.tvrage.com/shows/id-14650[/SHOW]
[TIME]09:30 pm[/TIME]
[SHOW]NBC^30 Rock^01x07^http:


/cryptonic

Last edited by cryptonic; 08/12/06 01:16 AM.
Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
It's this line:

Code:
if ($sockbr == 0) { sockclose $sockname }


Remove it and it will work correctly. This method of closing the socket doesn't always work correctly. You can just let mIRC close it automatically (no scripting needed), or if you are concerned with it staying open since that does happen occasionally, you can always do a check for </html> in %readdata, and if it sees that, then it closes the socket. I also like to have it close the socket once reaching a certain part of the page... if I already got all the data I need after reading half the page, there isn't any reason to read the rest of the page, so I sometimes have it close before finishing the page.


Invision Support
#Invision on irc.irchighway.net
Joined: Dec 2006
Posts: 4
C
Self-satisified door
OP Offline
Self-satisified door
C
Joined: Dec 2006
Posts: 4
I tried removing that line with the same result but now mirc freezes when i run the script. i have to kill it in task manager :S

/cryptonic

Last edited by cryptonic; 08/12/06 02:11 AM.
Joined: Dec 2006
Posts: 4
C
Self-satisified door
OP Offline
Self-satisified door
C
Joined: Dec 2006
Posts: 4
I finally got it to work. The problem was in sockread section. This is the working code:

Code:
on *:sockread:tvragetonight: {
  sockread -f %readdata
  while ($sockbr) {
    if ([DAY] isin %readdata) {
      if (%nextday == 1) { sockclose $sockname | unset %nextday | halt }
      set %nextday 1
      msg #mychan NEW TV for $remove(%readdata,[DAY],[/DAY]) $+  (Time is GMT+1)
    }
    if ([time] isin %readdata) {
      if (%time != $null) { msg #mychan %time }
      var %temp $left($remove(%readdata,[TIME],[/TIME]),-3)
      var %time 0 $+ $calc($gettok(%temp,1,58) + 6 - 12) $+ : $+ $gettok(%temp,2,58) $+ :
    }
    if ([show] isin %readdata) {
      if (??:??: iswm $strip(%time)) { var %time %time $gettok($remove(%readdata,[SHOW],[/SHOW]),2,94) }
      else { var %time %time 9- $gettok($remove(%readdata,[SHOW],[/SHOW]),2,94) }
    }
    sockread -f %readdata
  }
}


Tnx for the help smile

/cryptonic

Last edited by cryptonic; 08/12/06 02:30 AM.
Joined: Mar 2007
Posts: 8
R
Nutrimatic drinks dispenser
Offline
Nutrimatic drinks dispenser
R
Joined: Mar 2007
Posts: 8
This is the debug output i got from the script :
Quote:

2: [TIME]09:00 pm[/TIME]
2: [SHOW]FOX^24^06x12^http://www.tvrage.com/24[/SHOW]
2: [SHOW]History Channel^Digging for the Truth^03x06^http://www.tvrage.com/Digging_for_the_Truth[/SHOW]
2: [SHOW]MTV^My Super Sweet 16^04x09^http://www.tvrage.com/My_Super_Sweet_16[/SHOW]
2: [SHOW]ABC^Supernanny^03x12^http://www.tvrage.com/Supernanny[/S
2:
1: HOW]
2: [SHOW]USA^WWE Raw^15x10^http://www.tvrage.com/shows/id-6659[/SHOW]
2: [SHOW]NBC^Heroes^01x18^http://www.tvrage.com/Heroes[/SHOW]
2: [SHOW]Discovery Channel^FutureWeapons^02x08^http://www.tvrage.com/Futureweapons[/SHOW]
2: [SHOW]My Network TV^Watch Over Me^01x72^http://www.tvrage.com/Watch_Over_Me[/SHOW]
2: [SHOW]VH1^I Love New York^01x07^http://www.tvrage.com/I_Love_New_York[/SHOW]
2: [SHOW]Travel Channel^Bizarre Foods^01x03^http://www.tvrage.com/shows/id-15226[/SHOW]


1: is on the first sockread -f %readdata
2: is on the second sockread -f %readdata

This break really breaks everything on the time line :
Quote:

NEW TV for Monday, 05 Mar 2007 (GMT+1)
00:00: It Takes a Thief (2005)
01:00: Lincoln Heights
01:30: Yin Yang Yo
02:00: Power Rangers - Prison Break - Wildfire - Deal Or No Deal (US) - Wicked Wicked Games
02:30: The Class
- WWE Raw - Heroes - FutureWeapons - Watch Over Me - I Love New York - Bizarre Foods
03:30: Rules of Engagement - Engaged & Underage
04:00: The Hills - What About Brian - The Black Donnellys - Stunt Junkies - Saved
04:30: The Naked Trucker & T-Bones Show - DanceLife
05:00: WWE Raw
05:30: The Colbert Report


So, we're missing :
Quote:

03:00: 24 - Digging for the Truth - My Super Sweet 16 - Supernanny


Now, i can't figure out if it comes from the tvrage server, or if it's script-related.

Anyone got an idea ?

Joined: Oct 2005
Posts: 1,741
G
Hoopy frood
Offline
Hoopy frood
G
Joined: Oct 2005
Posts: 1,741
Try using HTTP/1.0 instead of HTTP/1.1

1.1 sends data in 'chunks', whereas 1.0 sends line by line.

-genius_at_work

Joined: Mar 2007
Posts: 8
R
Nutrimatic drinks dispenser
Offline
Nutrimatic drinks dispenser
R
Joined: Mar 2007
Posts: 8
Here the code I'm using :
Code:
alias tvtest { sockopen tvragetonight www.tvrage.com 80 }
on *:text:!tv:#:sockopen tvragetonight www.tvrage.com 80
on *:sockopen:tvragetonight:sockwrite -n $sockname GET /quickschedule.php HTTP/1.0 | sockwrite -n $sockname Host: www.tvrage.com | sockwrite -n $sockname $crlf
on *:sockread:tvragetonight:{
  sockread -f %readdata | echo -s 1: %readdata
  while ($sockbr) {
    if ($left(%readdata,5) == [DAY]) {
      if (%nextday == 1) { sockclose $sockname | unset %nextday | halt }
      set %nextday 1
      echo -a NEW TV for $remove(%readdata,[DAY],[/DAY]) $+  $chr(40) $+ $gettok($time(zzzz),2,32) $+ $chr(41)
    }
    if ($left(%readdata,6) == [TIME]) {
      if (%time != $null) { echo -a %time }
      var %temp $left($remove(%readdata,[TIME],[/TIME]),-3)
      var %time 0 $+ $calc($gettok(%temp,1,58) + 6 - 12) $+ : $+ $gettok(%temp,2,58) $+ :
    }
    if ($left(%readdata,6) == [SHOW]) {
      if (??:??: iswm $strip(%time)) { var %time %time $gettok(%readdata,2,94) $chr(40) $+ $remove($gettok(%readdata,1,94),[SHOW]) $+ $chr(41) }
      else { var %time %time 9- $gettok(%readdata,2,94) $chr(40) $+ $remove($gettok(%readdata,1,94),[SHOW]) $+ $chr(41)  }
    }
    sockread -f %readdata | echo -s 2: %readdata
  }
}


As you can see :
Code:
GET /quickschedule.php HTTP/1.0

I'm already trying to use 1.0 but I stil got this debug output :
Quote:

1: HTTP/1.1 200 OK
2: Date: Tue, 06 Mar 2007 06:09:47 GMT
2: Server: Apache/2.2.3 (Unix) PHP/5.2.0
2: X-Powered-By: PHP/5.2.0
2: Set-Cookie: visited=1; expires=Wed, 02-Mar-2022 06:09:47 GMT; path=/; domain=.tvrage.com
2: Connection: close
2: Content-Type: text/html; charset=UTF-8
2:
2: [DAY]Monday, 05 Mar 2007[/DAY]
2: [TIME]06:00 pm[/TIME]
2: [SHOW]Discovery Channel^It Takes a Thief (2005)^04x31^http://www.tvrage.com/It_Takes_a_Thief_2005[/SHOW]
2: [TIME]07:00 pm[/TIME]
2: [SHOW]ABC Family^Lincoln Heights^01x09^http://www.tvrage.com/Lincoln_Heights[/SHOW]
2: [TIME]07:30 pm[/TIME]
2: [SHOW]Toon Disney^Yin Yang Yo^01x23^http://www.tvrage.com/shows/id-13517[/SHOW]
2: [TIME]08:00 pm[/TIME]
2: [SHOW]Toon Disney^Power Rangers^15x03^http://www.tvrage.com/shows/id-4877[/SHOW]
2: [SHOW]FOX^Prison Break^02x19^http://www.tvrage.com/Prison_Break[/SHOW]
2: [SHOW]ABC Family^Wildfire^03x10^http://www.tvrage.com/Wildfire[/SHOW]
2: [SHOW]NBC^Deal Or No Deal (US)^02x52^http://www.tvrage.com/Deal_Or_No_Deal[/SHOW]
2: [SHOW]My Network TV^Wicked Wicked Games^01x70^http://www.tvrage.com/Wicked_Wicked_Games[/SHOW]
2: [SHOW]Lifetime^Gay, Straight or Taken?^01x15^http://www.tvrage.com/Gay_Straight_or_Taken[/SHOW]
2: [TIME]08:30 pm[/TIME]
2: [SHOW]CBS^The Class^01x19^http://www.tvrage.com/The_Class[/SHOW]
2: [SHOW]Lifetime^Gay, Straight or Taken?^01x16^http://www.tvrage.com/Gay_Straight_or_Taken[/SHOW]
2: [TIME]09:00 pm[/TIME]
2: [SHOW]FOX^24^06x12^http://www.tvrage.com/24[/SHOW]
2: [SHOW]History Channel^Digging for the Truth^03x06^ht
2:
1: [url=tp://www.tvrage.com/Digging_for_the_Truth][url=tp://www.tvrage.com/Digging_for_the_Truth][url=tp://www.tvrage.com/Digging_for_the_Truth]tp://www.tvrage.com/Digging_for_the_Truth[/url][/url][/url][/SHOW]
2: [SHOW]MTV^My Super Sweet 16^04x09^http://www.tvrage.com/My_Super_Sweet_16[/SHOW]
2: [SHOW]ABC^Supernanny^03x12^http://www.tvrage.com/Supernanny[/SHOW]
2: [SHOW]USA^WWE Raw^15x10^http://www.tvrage.com/shows/id-6659[/SHOW]
2: [SHOW]NBC^Heroes^01x18^http://www.tvrage.com/Heroes[/SHOW]
2: [SHOW]Discovery Channel^FutureWeapons^02x08^http://www.tvrage.com/Futureweapons[/SHOW]
2: [SHOW]My Network TV^Watch Over Me^01x72^http://www.tvrage.com/Watch_Over_Me[/SHOW]
2: [SHOW]VH1^I Love New York^01x07^http://www.tvrage.com/I_Love_New_York[/SHOW]
2: [SHOW]Travel Channel^Bizarre Foods^01x03^http://www.tvrage.com/shows/id-15226[/SHOW]
2: [TIME]09:30 pm[/TIME]
2: [SHOW]CBS^Rules of Engagement^01x05^http://www.tvrage.com/shows/id-11224[/SHOW]
2: [SHOW]MTV^Engaged & Underage^01x07^http://www.tvrage.com/shows/id-15071[/SHOW]
2: [TIME]10:00 pm[/TIME]
2: [SHOW]MTV^The Hills^02x08^http://www.tvrage.com/The_Hills[/SHOW]
2: [SHOW]ABC^What About Brian^02x16^http://www.tvrage.com/What_About_Brian[/SHOW]
2: [SHOW]NBC^The Black Donnellys^01x02^http://www.tvrage.com/shows/id-6936[/SHOW]
2: [SHOW]Discovery Channel^Stunt Junkies^02x26^http://www.tvrage.com/Stunt_Junkies[/SHOW]
2: [TIME]10:30 pm[/TIME]
2: [SHOW]Comedy Central^The Naked Trucker & T-Bones Show^01x08^http://www.tvrage.com/shows/id-10199[/SHOW]
2: [SHOW]MTV^DanceLife^01x08^http://www.tvrage.com/shows/id-15062[/SHOW]
2: [TIME]11:00 pm[/TIME]
2: [SHOW]Comedy Central^The Daily Show^12x29^http://www.tvrage.com/The_Daily_Show[/SHOW]
2: [SHOW]USA^WWE Raw^15x10^http://www.tvrage.com/shows/id-6659[/SHOW]
2: [TIME]11:30 pm[/TIME]
2: [SHOW]Comedy Central^The Colbert Report^03x29^http://www.tvrage.com/The_Colbert_Report[/SHOW]
2: [TIME]12:35 am[/TIME]
2: [SHOW]CBS^The Late Late Show with Craig Ferguson^03x41^http://www.tvrage.com/The_Late_Late_Show_with_Craig_Ferguson[/SHOW]
2:
2:
2: [DAY]Tuesday, 06 Mar 2007[/DAY]


And this as output :
Quote:

NEW TV for Monday, 05 Mar 2007 (GMT+1)
00:00: It Takes a Thief (2005) (Discovery Channel)
01:00: Lincoln Heights (ABC Family)
01:30: Yin Yang Yo (Toon Disney)
02:00: Power Rangers (Toon Disney) - Prison Break (FOX) - Wildfire (ABC Family) - Deal Or No Deal (US) (NBC) - Wicked Wicked Games (My Network TV) - Gay, Straight or Taken? (Lifetime)
02:30: The Class (CBS) - Gay, Straight or Taken? (Lifetime)
- My Super Sweet 16 (MTV) - Supernanny (ABC) - WWE Raw (USA) - Heroes (NBC) - FutureWeapons (Discovery Channel) - Watch Over Me (My Network TV) - I Love New York (VH1) - Bizarre Foods (Travel Channel)
03:30: Rules of Engagement (CBS) - Engaged & Underage (MTV)
04:00: The Hills (MTV) - What About Brian (ABC) - The Black Donnellys (NBC) - Stunt Junkies (Discovery Channel)
04:30: The Naked Trucker & T-Bones Show (Comedy Central) - DanceLife (MTV)
05:00: The Daily Show (Comedy Central) - WWE Raw (USA)
05:30: The Colbert Report (Comedy Central)


The thing is : sometimes it works, sometimes it just doesn't because of the oops-i-got-a-break-somewhere issue.

mad


Link Copied to Clipboard