Login(); $myShows = $mc->GetMyShows(); if ( !empty( $myShows ) ) { printf( "MyShows count: %d\n" , count( $myShows ) ); /** @var $tmpMyShows My_UserShow[] */ $tmpMyShows = array_slice( $myShows, 0, 2 ); foreach( $tmpMyShows as $myShow ) { printf ( "showId: %d\t - %s (%d of %d watched)\n", $myShow->showId, $myShow->title, $myShow->watchedEpisodes, $myShow->totalEpisodes ); $episodes = $mc->GetWatchedEpisodes( $myShow->showId ); foreach ( $episodes as $episode ) { printf( "\t\t * episode id %d watched at %s\n", $episode->id, $episode->watchDate); } if ( !empty( $episode ) ) { $uncheckResult = $mc->UnCheckEpisode( $episode->id ); printf( "Unchecked episode id %d. Result: %s\n", $episode->id, $uncheckResult ); $episodes = $mc->GetWatchedEpisodes( $myShow->showId ); if ( !empty( $episodes[$episode->id] ) ) { die( 'uncheck failed' ); } } } } $nextEpisodes = $mc->GetNextEpisodes(); if ( !empty( $nextEpisodes ) ) { printf( "My Next episodes (first 5 of %d)\n", count( $nextEpisodes ) ); $nextEpisodes = array_slice( $nextEpisodes, 0, 5 ); foreach( $nextEpisodes as $nextEpisode ) { printf( "\t\t * %s: %s (id#i%d), s%02de%02d \n", $nextEpisode->airDate, $myShows[$nextEpisode->showId]->title, $nextEpisode->showId, $nextEpisode->seasonNumber, $nextEpisode->episodeNumber ); } } $unwatchedEpisodes = $mc->GetUnwatchedEpisodes(); if ( !empty( $unwatchedEpisodes ) ) { printf( "My Unwatched episodes (first 5 of %d)\n", count( $unwatchedEpisodes ) ); $unwatchedEpisodes = array_slice( $unwatchedEpisodes, 0, 5 ); foreach( $unwatchedEpisodes as $unwatchedEpisode ) { printf( "\t\t * %s: %s (id#i%d), s%02de%02d \n", $unwatchedEpisode->airDate, $myShows[$unwatchedEpisode->showId]->title, $unwatchedEpisode->showId, $unwatchedEpisode->seasonNumber, $unwatchedEpisode->episodeNumber ); } // check episode $unwatchedEpisode = reset( $unwatchedEpisodes ); $rating = rand( 0, 5 ); $checkResult = $mc->CheckEpisode( $unwatchedEpisode->episodeId, $rating ); printf( "Checked episodeId: %d with rating %d. Result: %s\n", $unwatchedEpisode->episodeId, $rating, $checkResult ); } // sync episodes $myShow = current( $myShows ); $episodes = $mc->GetWatchedEpisodes( $myShow->showId ); $episodeIds = array_slice( array_keys( $episodes ), 0, count( $episodes ) - 2 ); $syncResult = $mc->SyncEpisodes( $myShow->showId, $episodeIds ); printf( "Synced episodes for show #%d. Result: %d. Ids: %s\n", $myShow->showId, $episodeIds, implode( ', ', $episodeIds ) ); $showStatus = $mc->SetShowStatus( $myShow->showId, MyShowsClient::StatusWatching ); printf( "Set show status to %s for %s. Result: %d\n", MyShowsClient::StatusWatching, $myShow->title, $showStatus ); $rating = rand( 0, 5 ); $showRating = $mc->SetShowRating( $myShow->showId, $rating ); printf( "Set show rating to %s for %s. Result: %d\n", $rating, $myShow->title, $showRating ); $rating = rand( 0, 5 ); $episode = reset( $episodes ); $episodeRating = $mc->SetEpisodeRating( $episode->id, $rating ); printf( "Set episode rating to %s for %s. Result: %d\n", $rating, $episode->id, $episodeRating ); /** todo favorites */ $news = $mc->GetFriendNews(); printf( "News days: %s\n", count( $news ) ); foreach( $news as $date => $entries ) { printf( "\t %s\n", $date ); foreach( $entries as $entry ) { /** @var $entry My_UserNews */ printf( "\t\t * %s watched %s episode(s) of %s\n", $entry->login, $entry->episodes, $entry->show ); } } unset( $mc ); /** Public API */ $mc = new MyShowsClient(); $shows = $mc->SearchShow( 'the big bang theory' ); printf( "Found : %d\n" , count( $shows ) ); foreach( $shows as $show ) { $info = $mc->GetShowById( $show->id ); printf( "Episodes: %d\n" , count( $info->episodes ) ); break; } $sf = $mc->SearchEpisodesByFile( 'Star.Wars.The.Clone.Wars.s02e01e02.rus.LostFilm.TV.avi' ); if ( !empty( $sf ) ) { printf( "File Size: %d\n" , $sf->filesize ); } $top = $mc->GetTopShows(); if ( !empty( $top ) ) { $top = array_slice( $top, 0, 5 ); foreach( $top as $show ) { printf( "%d - %s\n" , $show->place, $show->title); } } $user = $mc->GetProfile( 'sergeyfast' ); printf( "%s - friends: %d, followers: %d \n" , $user->login, count($user->friends), count( $user->followers) ); $genres = $mc->GetGenres(); foreach( $genres as $genre ) { printf( "%d: %s \n" , $genre->id, $genre->title ); }