JSJSONArrayParser: Allow single quotes (wimp, you are trying to annoy me, right?)
[videosite.git] / videosite.pl
index 2926b0b..26ca480 100644 (file)
@@ -153,14 +153,26 @@ sub expand_url_shortener {
     my $s = shift;
     my $os = '';
     my @urlshortener = (
+        'is\.gd/[[:alnum:]]+',
+        'otf\.me/[[:alnum:]]+',
+        'hel\.me/[[:alnum:]]+',
+        '7ax\.de/[[:alnum:]]+',
+        'ow\.ly/[[:alnum:]]+',
         'j\.mp/[[:alnum:]]+',
         'bit\.ly/[[:alnum:]]+',
         'tinyurl\.com/[[:alnum:]]+',
+        'pop\.is/[[:alnum:]]+',
+        'post\.ly/[[:alnum:]]+',
+        '1\.ly/[[:alnum:]]+',
+        '2\.ly/[[:alnum:]]+',
+        't\.co/[[:alnum:]]+',
+        'shar\.es/[[:alnum:]]+',
         );
-    my $ua = LWP::UserAgent->new(agent => 'Mozilla');
-    my $i = 100;
+    my $ua = LWP::UserAgent->new(agent => 'Mozilla', max_redirect => 0);
+    my $i = 10;
 
     OUTER: while (($os ne $s) and ($i > 0)) {
+        study($s);
         $os = $s;
         $i--;
 
@@ -174,8 +186,8 @@ sub expand_url_shortener {
 
                 write_debug("Found %s", $matched);
                 $res = $ua->head($matched);
-                if ($res->is_success()) {
-                    my $new = $res->request()->uri();
+                if ($res->is_redirect()) {
+                    my $new = $res->headers()->header("Location");
 
                     write_debug("Replacing %s with %s", $matched, $new);
                     $s =~ s/$matched/$new/;