コード例 #1
0
 public function testCreateComment()
 {
     $client = mock_client(201, '{
           "id": 190,
           "parent_id": 0,
           "created_at": "2014-08-04T06:46:01.996Z",
           "comment": "Oh, I wasn\'t really listening.",
           "spoiler": false,
           "review": false,
           "replies": 0,
           "likes": 0,
           "user_rating": null,
           "user": {
             "username": "******",
             "private": false,
             "name": "Sean Rudford",
             "vip": true,
             "vip_ep": false
           }
         }');
     $auth = mock_auth();
     //        $movieClient = mock_client(200, '[]');
     $trakt = new Trakt($auth, $client);
     $commend = $trakt->comments->create(movie($client), "This was so awesome! I really liked it!", false);
     $this->assertInternalType("object", $commend);
 }
コード例 #2
0
    public function testCheckIn()
    {
        $json = '{
  "watched_at": "2014-08-06T01:11:37.953Z",
  "sharing": {
    "facebook": true,
    "twitter": true,
    "tumblr": false
  },
  "movie": {
    "title": "Guardians of the Galaxy",
    "year": 2014,
    "ids": {
      "trakt": 28,
      "slug": "guardians-of-the-galaxy-2014",
      "imdb": "tt2015381",
      "tmdb": 118340
    }
  }
}';
        $client = Mockery::mock(stdClass::class . ", " . ClientInterface::class);
        $request = Mockery::mock(stdClass::class . ", " . RequestInterface::class);
        $response = Mockery::mock(stdClass::class . ", " . ResponseInterface::class);
        $client->shouldReceive("createRequest")->once()->andReturn($request);
        $response->shouldReceive("getStatusCode")->once()->andReturn(200);
        $response->shouldReceive("json")->once()->andReturn(json_decode($json));
        $client->shouldReceive("send")->once()->andReturn($response);
        $auth = mock_auth();
        $trakt = new Trakt($auth, $client);
        $checkIn = $trakt->checkIn;
        $this->assertInstanceOf("Wubs\\Trakt\\Api\\CheckIn", $checkIn);
        $response = $checkIn->create(get_token(), movie($client), "nooo way!", ['facebook' => false, 'twitter' => false, 'tumblr' => false], "1200", "blablabla", "1.1", $this->today->format("Y-m-d"));
        $this->assertInstanceOf("Wubs\\Trakt\\Response\\CheckIn", $response);
    }
コード例 #3
0
    public function testCheckIn()
    {
        /** @var Movie $movie */
        $client = Mockery::mock(stdClass::class . ", " . ClientInterface::class);
        $request = Mockery::mock(stdClass::class . ", " . RequestInterface::class);
        $response = Mockery::mock(stdClass::class . ", " . ResponseInterface::class);
        $client->shouldReceive("createRequest")->once()->andReturn($request);
        $response->shouldReceive("getStatusCode")->once()->andReturn(200);
        $response->shouldReceive("json")->once()->andReturn(json_decode('{
  "watched_at": "2014-08-06T01:11:37.953Z",
  "sharing": {
    "facebook": true,
    "twitter": true,
    "tumblr": false
  },
  "movie": {
    "title": "Guardians of the Galaxy",
    "year": 2014,
    "ids": {
      "trakt": 28,
      "slug": "guardians-of-the-galaxy-2014",
      "imdb": "tt2015381",
      "tmdb": 118340
    }
  }
}'));
        $client->shouldReceive("send")->andReturn($response);
        $movie = movie($client);
        $response = $movie->checkIn([], "I like this one!", null, null, null, null);
        //
        $this->assertInstanceOf(CheckIn::class, $response);
    }
コード例 #4
0
 /**
  *
  */
 public function testCheckInMovie()
 {
     $client = mock_client(201, '{
           "watched_at": "2014-08-06T01:11:37.953Z",
           "sharing": {
             "facebook": true,
             "twitter": true,
             "tumblr": false
           },
           "movie": {
             "title": "Guardians of the Galaxy",
             "year": 2014,
             "ids": {
               "trakt": 28,
               "slug": "guardians-of-the-galaxy-2014",
               "imdb": "tt2015381",
               "tmdb": 118340
             }
           }
         }');
     $auth = mock_auth();
     $trakt = new Trakt($auth, $client);
     $response = $trakt->checkIn->create(get_token(), movie($client), "Such an awesome movie! I love it");
     $this->assertInstanceOf(CheckIn::class, $response);
 }
コード例 #5
0
 public function testStaticCall()
 {
     $client = Mockery::mock(stdClass::class . ", " . ClientInterface::class);
     $request = new Create(get_token(), movie($client), "Awesome Movie!", [], null, null, null, null);
     $url = $request->getUrl();
     $type = $request->getRequestType();
     $this->assertEquals(RequestType::POST, $type);
     $this->assertEquals("checkin", $url);
 }
コード例 #6
0
 public function testCanCheckInFromMovieObject()
 {
     $client = mock_client(201, '{
               "watched_at": "2014-08-06T01:11:37.953Z",
               "sharing": {
                 "facebook": true,
                 "twitter": true,
                 "tumblr": false
               },
               "movie": {
                 "title": "Guardians of the Galaxy",
                 "year": 2014,
                 "ids": {
                   "trakt": 28,
                   "slug": "guardians-of-the-galaxy-2014",
                   "imdb": "tt2015381",
                   "tmdb": 118340
                 }
               }
             }');
     $movie = movie($client);
     $checkin = $movie->checkIn([], "Never seen this one before!");
     $this->assertInstanceOf("Wubs\\Trakt\\Response\\CheckIn", $checkin);
     $this->assertTrue($checkin->isSharedOnFacebook());
     $this->assertEquals("Guardians of the Galaxy", $checkin->media->title);
 }
コード例 #7
0
function process($file)
{
    global $TVDIR, $MVDIR, $RMBIN, $autoDelete, $verbose, $moveCount;
    if (strpos($file, '/') !== 0) {
        $value = realpath(getcwd() . '/' . $file);
    } else {
        $value = realpath($file);
    }
    if (!$value) {
        return;
    }
    if ($verbose) {
        echo "Processing: {$value}\n";
    }
    chdir(dirname($value));
    $extensions = 'avi|mkv|mp4';
    if (is_dir($value)) {
        $moveCount[$value] = 0;
        processDir($value);
        if ($autoDelete && $moveCount[$value]) {
            $f = escapeshellarg($value);
            `{$RMBIN} -rf {$f}`;
            echo "Deleted: {$value}\n";
        }
        return;
    } else {
        if (preg_match('/.*\\.part[0]+1\\.rar/i', $value, $m) || !preg_match('/.*\\.part[0-9]+\\.rar/i', $value) && preg_match('/.*\\.rar/i', $value, $m)) {
            if ($verbose) {
                echo "Extract: {$value}\n";
            }
            $files = extractRar($value);
            if ($verbose) {
                echo "\n";
                print_r($files);
                echo "\n";
            }
            foreach ($files as $f) {
                if ($verbose) {
                    echo "Process Extracted: {$f}\n";
                }
                process("{$f}");
            }
        } else {
            if (stripos($value, 'sample') !== false) {
                // TV in format: name.S01E01.tag.avi
            } else {
                if (preg_match('#(/)([a-z0-9\\- \\._]+)[\\. -](s[0-9]{2}e[0-9]{2})[^/]*\\.(avi|mkv)$#i', $value, $m)) {
                    moveto($value, $TVDIR . '/' . folder($m[2]) . '/' . filename($m[2], $m[3]) . '.' . $m[4]);
                    // TV in format: name 1x14 episode title.avi
                } else {
                    if (preg_match('#(/)([a-z0-9\\- \\._]+)[\\. -]([0-9]{1,2}x[0-9]{2})[^/]*\\.(avi|mkv)$#i', $value, $m)) {
                        moveto($value, $TVDIR . '/' . folder($m[2]) . '/' . filename($m[2], $m[3]) . '.' . $m[4]);
                        // TV in format: name.2010.10.06.tag.avi
                    } else {
                        if (preg_match('#(/)([a-z0-9\\- \\._]+)[\\. -](20[0-9]{2}[\\.\\-][0-9]{2}[\\.\\-][0-9]{2})[^/]*\\.(avi|mkv)$#i', $value, $m)) {
                            moveto($value, $TVDIR . '/' . folder($m[2]) . '/' . filename($m[2], $m[3]) . '.' . $m[4]);
                            // TV with path in form /name.S01E01.tag/name...avi
                        } else {
                            if (preg_match('#/([a-z0-9\\- \\._]+)[\\. \\-](s[0-9]{2}e[0-9]{2})[^/]*/[^/]*\\.(avi|mkv)$#i', $value, $m)) {
                                moveto($value, $TVDIR . '/' . folder($m[1]) . '/' . filename($m[1], $m[2]) . '.' . $m[3]);
                                // Movie parent in format: Movie.2010.dvd/CD1/tag-snom.avi
                            } else {
                                if (preg_match('#(/)([a-z0-9\\- \\._]+)[\\ .-\\[\\(]((19|20)[0-9]{2})[^/]*/CD(1|2)/[^/]*\\.(avi|mkv)$#i', $value, $m)) {
                                    moveto($value, $MVDIR . '/' . movie($m[2]) . ".{$m[3]}.part{$m[5]}.{$m[6]}");
                                    // Movie in format: movie.2010.dvd.avi (1900-2099) I don't have old movies
                                } else {
                                    if (preg_match("#(/)([a-z0-9\\- \\._]+)[\\ .-\\[\\(]((19|20)[0-9]{2})[^/]*\\.({$extensions})\$#i", $value, $m)) {
                                        moveto($value, $MVDIR . '/' . movie($m[2]) . ".{$m[3]}.{$m[5]}");
                                        // Movie parent in format: Movie.2010.dvd/tag-snom.avi
                                    } else {
                                        if (preg_match('#(/)([a-z0-9\\- \\._]+)[\\ .-\\[\\(]((19|20)[0-9]{2})[^/]*/[^/]*\\.(avi|mkv)$#i', $value, $m)) {
                                            moveto($value, $MVDIR . '/' . movie($m[2]) . ".{$m[3]}.{$m[5]}");
                                            // Movie in format: movie.dvdrip.tag.avi (1900-2099) I don't have old movies
                                        } else {
                                            if (preg_match('#(/)([a-z0-9\\- \\._]+)[\\ .-\\[\\(](dvdrip|bdrip)[^/]*\\.(avi|mkv)$#i', $value, $m)) {
                                                moveto($value, $MVDIR . '/' . movie($m[2]) . ".{$m[4]}");
                                                // Movie parent in format: Movie.dvdrip.tag/tag-snom.avi
                                            } else {
                                                if (preg_match('#(/)([a-z0-9\\- \\._]+)[\\ .-\\[\\(](dvdrip|bdrip)[^/]*/[^/]*\\.(avi|mkv)$#i', $value, $m)) {
                                                    moveto($value, $MVDIR . '/' . movie($m[2]) . ".{$m[4]}");
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
コード例 #8
0
 /**
  * @@expectedException Wubs\Trakt\Request\Exception\CommentTooShortException
  */
 public function testThrowsExceptionWithShoutLessThan5Words()
 {
     $client = Mockery::mock(stdClass::class . ", " . ClientInterface::class);
     $movie = movie($client);
     new Create($movie, "too short", false);
 }
コード例 #9
0
ファイル: imdb.php プロジェクト: hugcoday/wiki
 function movie_main($title_id)
 {
     return movie($title_id);
 }