changeset 4:8c9049f2b2b0

Improve RasiaTube de-mangler.
author Matti Hamalainen <ccr@tnsp.org>
date Fri, 25 Mar 2011 00:40:41 +0200
parents 8003090caa35
children 5ac4fd6d011a
files urllog.tcl
diffstat 1 files changed, 15 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/urllog.tcl	Sun Jan 16 20:51:18 2011 +0200
+++ b/urllog.tcl	Fri Mar 25 00:40:41 2011 +0200
@@ -324,7 +324,7 @@
 
 	# Stop fetching data after 3000 bytes, this should be enough to
 	# contain the head section of a HTML page.
-	if {$ucurr > 3000} {
+	if {$ucurr > 64000} {
 		set state(status) "ok"
 	}
 }
@@ -463,14 +463,25 @@
 
 		# Rasiatube hack
 		if {[string match "*/rasiatube/view*" $urlStr]} {
+			set rasia 0
 			set umatches [regexp -nocase -inline -- "<link rel=\"video_src\"\.\*\?file=(http://\[^&\]+)&" $udata]
 			if {[llength $umatches] > 0} {
 				set urlStr [lindex $umatches 1]
 				regsub -all "\/v\/" $urlStr "\/watch\?v=" urlStr
-
+				set rasia 1
+			} else {
+				set umatches [regexp -nocase -inline -- "SWFObject.\"(\[^\"\]+)\", *\"flashvideo" $udata]
+				if {[llength $umatches] > 0} {
+					set urlStr [lindex $umatches 1]
+					regsub "http:\/\/www.dailymotion.com\/swf\/" $urlStr "http:\/\/www.dailymotion.com\/video\/" urlStr
+					set rasia 1
+				}
 			}
-			urllog_log "RasiaTube mangler: $urlStr"
-			urllog_verb_msg $urlNick $urlChan "Korjataan haiseva rasiatube-linkki: $urlStr"
+			
+			if {$rasia != 0} {
+				urllog_log "RasiaTube mangler: $urlStr"
+				urllog_verb_msg $urlNick $urlChan "Korjataan haiseva rasiatube-linkki: $urlStr"
+			}
 		}
 
 		urllog_addurl $urlStr $urlNick $urlHost $urlChan $urlTitle