Ajax subtitle API

A simple description, this ajax script searches SubtitleSource and MoTechSubs after a specific releasename and gives you the result in a very simple format. The example below shows you how the final result looks like. If you are planning on using this script on a site with more than 5000 visitors/searches a day, please consider adding a cache on the search results, both for us and for yourself!

Example:
The.Golden.Compass.DVDRip.XviD-BeStDivX

Download all files and images zipped



<script src="subajax.js"></script>

<body onLoad="refreshSub(this.value='enter the releasename here')">

<div id="showSubs"><img src="images/2-1.gif"></div>


<?php

$Sub 
= new SubAjax();
$Sub->releasename trim($_GET['q']);

# Settings
# Subtitle language filter, uncomment the ones that you don't want to see

#$Sub->blocklist("Arabic");
#$Sub->blocklist("Bulgarian");
#$Sub->blocklist("Croatian");
#$Sub->blocklist("Czech");
#$Sub->blocklist("Danish");
#$Sub->blocklist("Dutch");
#$Sub->blocklist("English");
#$Sub->blocklist("Estonian");
#$Sub->blocklist("Finnish");
#$Sub->blocklist("French");
#$Sub->blocklist("German");
#$Sub->blocklist("Greek");
#$Sub->blocklist("Hebrew");
#$Sub->blocklist("Hungarian");
#$Sub->blocklist("Icelandic");
#$Sub->blocklist("Japanese");
#$Sub->blocklist("Norwegian");
#$Sub->blocklist("Persian");
#$Sub->blocklist("Polish");
#$Sub->blocklist("Portuguese");
#$Sub->blocklist("Romanian");
#$Sub->blocklist("Russian");
#$Sub->blocklist("Serbian");
#$Sub->blocklist("Slovak");
#$Sub->blocklist("Slovenian");
#$Sub->blocklist("Spanish");
#$Sub->blocklist("Swedish");
#$Sub->blocklist("Turkish");


class SubAjax{

    function 
getdata($url){
        
$this->subcont file_get_contents($url $this->releasename "/");

    }

    function 
source($source){
    
$this->source "$source";
    }

    function 
blocklist($block){
    
$this->langarray[] = $block;
    }


    function 
echolink($id$language){
     if (@!
in_array($language$this->langarray)) {
          
$this->langarray[] = $language;

    echo 
"<a href=\"";
    if(
strstr($this->source'SubtitleSource')){ echo "http://www.subtitlesource.org/getfile?id=$id\""; }else{ echo "http://subs.motechnet.com/release/$id/" $this->releasename "/\" target=\"_about\""; }
    echo 
" title=\"$language subtitles @ $this->source\" border=\"0\">";
    echo 
"<img src=\"images/" strtolower($language) . ".gif\" alt=\"$language subtitles @ $this->source\" border=\"0\"></a> ";

    return 
$languagearray;
      }
    }

}



# --------------------- #
#    SubtitleSource     #
# --------------------- #

$Sub->source("SubtitleSource");
$Sub->getdata("http://www.subtitlesource.org/indexing/ajaxsubs.php?rls=");

$Sub->subcont explode("|"$Sub->subcont);
$runtimes count($Sub->subcont) - 2;

for(
$i 0$i <= $runtimes$i++) {
    
$tempsub explode("-"$Sub->subcont[$i]);

    
$Sub->echolink($tempsub[0], $tempsub[1]);
}


# --------------------- #
#      MotechSubs       #
# --------------------- #

$Sub->source("MotechSubs");
$Sub->getdata("http://subs.motechnet.com/xml/");

if (
strlen($Sub->subcont) < 130) { exit; }
$Sub->subcont explode("\n"$Sub->subcont);

$id trim(strip_tags($Sub->subcont[6]));

  for(
$i 11$i <= count($Sub->subcont) - 6$i $i 6){
      
$Sub->echolink($idtrim(strip_tags($Sub->subcont[$i])));
      }

?>
1
RSS   213 online
Forum | SubEditor
© 2007-2008 SubtitleSource.org
Subs | English Subtitles | MP3