Skip to content
Browse files

maj

  • Loading branch information...
1 parent 3dbfec5 commit a4b38388fcc7094f0cc1dd68f1163b29ae49090e Matthias ETIENNE committed Apr 18, 2012
Showing with 24 additions and 6 deletions.
  1. +8 −0 drivers/tvsubtitles.php
  2. +4 −0 php-subtitles.php
  3. +7 −5 tests/test_cls.php
  4. +5 −1 utils.php
View
8 drivers/tvsubtitles.php
@@ -12,6 +12,14 @@ class Subtitles_TVSubtitles {
public function search($type, $query, $lang = '') {
+ if($type == Subtitles::TYPE_MOVIE) {
+
+ }elseif($type == Subtitles::TYPE_SHOW) {
+
+ }else{
+ throw new Subtitles_Exception("Invalid type given in ".__METHOD__);
+ }
+
}
}
?>
View
4 php-subtitles.php
@@ -44,6 +44,10 @@ public function driver($driver)
}
+class Subtitles_Exception extends Exception {
+
+}
+
/**
* Subtitles_Config
*
View
12 tests/test_cls.php
@@ -29,12 +29,14 @@ function getBestSimilarString($original, $possibilities) {
function sortByBestSimilarString($a, $b) {
global $__str_to_match;
- $a1 = similar_text($__str_to_match, $a);
- $b1 = similar_text($__str_to_match, $b);
- return ($a1 < $b1) ? -1 : (($a1 > $b1) ? 1 : 0);
+ $a1 = similar_text($__str_to_match, $a['title']);
+ $b1 = similar_text($__str_to_match, $b['title']);
+ echo "a1 = $a1 et b1 = $b1\n";
+ return ($b1 < $a1) ? -1 : (($b1 > $a1) ? 1 : 0);
}
-$filename = "http://www.tvsubtitles.net/search.php?q=game+of+thrones";
+$__str_to_match = $search = "game of thrones";
+$filename = "http://www.tvsubtitles.net/search.php?q=".urlencode($search);
$doc = new DOMDocument();
@$doc->loadHTML(file_get_contents($filename));
@@ -52,7 +54,7 @@ function sortByBestSimilarString($a, $b) {
foreach($imgs as $img) {
$langs[] = strtoupper($img->getAttribute('alt'));
}
- $ret[] = array(
+ $ret[(string)$id] = array(
'id' => $id,
'title' => $title,
'languages' => $langs
View
6 utils.php
@@ -19,4 +19,8 @@ function dice_coefficient($str1, $str2) {
}
}
return (2.0 * $intersection) / ($length1 + $length2);
-}
+}
+
+class Subtitles_Utils {
+
+}

0 comments on commit a4b3838

Please sign in to comment.
Something went wrong with that request. Please try again.