C# Class OnlineVideos.Sites.SiteUtilBase

The abstract base class for all sites. Instances might be hosted in a seperate AppDomain than the main application, so it can be unloaded at runtime.
Inheritance: UserConfigurable
Datei anzeigen Open project: offbyoneBB/mp-onlinevideos2 Class Usage Examples

Public Methods

Method Description
DiscoverDynamicCategories ( ) : int

If the site's categories can be retrieved dynamically, then it should be done in the implementation of this method. The categories must be added to the SiteSettings retrieved from the Settings property of this class. Once the categories are added you should set SiteSettings.DynamicCategoriesDiscovered to true, so this method won't be called each time the user enters this site in the GUI (unless you want that behavior).
default: sets SiteSettings.DynamicCategoriesDiscovered to true

DiscoverNextPageCategories ( NextPageCategory category ) : int

Override this method in your derived Util when you need paging in a list of Categorys. It will be called when the last item in that list is a NextPageCategory.

DiscoverSubCategories ( Category parentCategory ) : int

If a category has sub-categories this function will be called when the user selects a category in the GUI. This happens only when Category.HasSubCategories is true and Category.SubCategoriesDiscovered is false.

ExecuteContextMenuEntry ( Category selectedCategory, System.VideoInfo selectedItem, OnlineVideos.Sites.ContextMenuEntry choice ) : OnlineVideos.Sites.ContextMenuExecutionResult

This function is called when one of the custom contextmenu entries was selected by the user. Override it to handle the entries you added with GetContextMenuEntries.

GetContextMenuEntries ( Category selectedCategory, System.VideoInfo selectedItem ) : List

This function will be called when a contextmenu for a video or category is to be shown in the GUI. Override it to add your own entries (which should be localized).

GetCurrentVideosTitle ( ) : string

Should return the title of the current page, which will be put in #header.label at state=videos when showing videos returned from a search

GetFileNameForDownload ( System.VideoInfo video, Category category, string url ) : string

This method will be called before downloading the video from the given url, or before adding it to the favorites. (in that case the url param is null.
By default, the favorite name is the VideoInfo.Title.

GetMultipleVideoUrls ( System.VideoInfo video, bool inPlaylist = false ) : List

This function will be called to get the urls for playback of a video. Use this if your video is split into smaller parts for playback.
By default: returns a list with the result from GetVideoUrl.

GetNextPageVideos ( ) : List

This function should return the videos of the next page. No state is given, so the class implementation has to remember and set the current category and page itself. It will only be called if HasNextPage returned true on the last call and after the user selected the menu entry for "next page".
default: empty list

GetPlaylistItemVideoUrl ( System.VideoInfo clonedVideoInfo, string chosenPlaybackOption, bool inPlaylist = false ) : string

Allows the Util to resolve the url of a playlist item to playback options or a new url directly before playback.

GetSearchableCategories ( ) : string>.Dictionary

Will be called to get the list of categories (names only) that can be chosen to search. The keys will be the names and the value will be given to the Search as parameter.
default: returns empty list, so no category specific search can be done This is also used if HasFilterCategories returns true

GetTrackingInfo ( System.VideoInfo video ) : ITrackingInfo

This method will ask the Util to provide information for a VideoInfo that can be used to identify the video for http://trakt.tv/.

GetVideoUrl ( System.VideoInfo video ) : String

This function will be called when the user selects a video for playback. It should return the absolute url to the video file.
By default, the VideoInfo.VideoUrl fields value will be returned.

GetVideos ( Category category ) : List

This is the only function a subclass has to implement. It's called when a user selects a category in the GUI.
It should return a list of videos for that category, reset the paging indexes, remember this category, whatever is needed to hold state, because a call to HasNextPage and GetNextPageVideos will not give any parameter.

Initialize ( SiteSettings siteSettings ) : void

You should always call this implementation, even when overriding it. It is called after the instance has been created in order to configure settings from the xml for this util.

IsPossibleVideo ( string fsUrl ) : bool

This function checks a given string, if it points to a file that is a valid video. It will check for protocol and known and supported video extensions.

OnDownloadEnded ( System.VideoInfo video, string url, double percent, bool stoppedByUser ) : void

This method will be called after download of a video from this site was stopped or has ended.

OnPlaybackEnded ( System.VideoInfo video, string url, double percent, bool stoppedByUser ) : void

This method will be called after playback of a video from this site was stopped or has ended.

Search ( string query, string category = null ) : List

Should return a list of VideoInfo or Category for the given query - limited to the given category if not null.
All items in the list must be of the same type!
default: returns empty list

ToString ( ) : string

Private Methods

Method Description
GetConfigurationKey ( string fieldName ) : string

Method Details

DiscoverDynamicCategories() public method

If the site's categories can be retrieved dynamically, then it should be done in the implementation of this method. The categories must be added to the SiteSettings retrieved from the Settings property of this class. Once the categories are added you should set SiteSettings.DynamicCategoriesDiscovered to true, so this method won't be called each time the user enters this site in the GUI (unless you want that behavior).
default: sets SiteSettings.DynamicCategoriesDiscovered to true
public DiscoverDynamicCategories ( ) : int
return int

DiscoverNextPageCategories() public method

Override this method in your derived Util when you need paging in a list of Categorys. It will be called when the last item in that list is a NextPageCategory.
public DiscoverNextPageCategories ( NextPageCategory category ) : int
category NextPageCategory The category item that you used to store info about how to get the next page categories.
return int

DiscoverSubCategories() public method

If a category has sub-categories this function will be called when the user selects a category in the GUI. This happens only when Category.HasSubCategories is true and Category.SubCategoriesDiscovered is false.
public DiscoverSubCategories ( Category parentCategory ) : int
parentCategory Category the category that was selected by the user
return int

ExecuteContextMenuEntry() public method

This function is called when one of the custom contextmenu entries was selected by the user. Override it to handle the entries you added with GetContextMenuEntries.
public ExecuteContextMenuEntry ( Category selectedCategory, System.VideoInfo selectedItem, OnlineVideos.Sites.ContextMenuEntry choice ) : OnlineVideos.Sites.ContextMenuExecutionResult
selectedCategory Category either the the context menu was shown for, or the of the video the context menu was shown for
selectedItem System.VideoInfo when this is null the context menu was called on the otherwise on the
choice OnlineVideos.Sites.ContextMenuEntry the that was chosen by the user
return OnlineVideos.Sites.ContextMenuExecutionResult

GetContextMenuEntries() public method

This function will be called when a contextmenu for a video or category is to be shown in the GUI. Override it to add your own entries (which should be localized).
public GetContextMenuEntries ( Category selectedCategory, System.VideoInfo selectedItem ) : List
selectedCategory Category either the to show the context menu for, or the of the video to show the context menu for
selectedItem System.VideoInfo when this is null the context menu is called on the otherwise on the
return List

GetCurrentVideosTitle() public method

Should return the title of the current page, which will be put in #header.label at state=videos when showing videos returned from a search
public GetCurrentVideosTitle ( ) : string
return string

GetFileNameForDownload() public method

This method will be called before downloading the video from the given url, or before adding it to the favorites. (in that case the url param is null.
By default, the favorite name is the VideoInfo.Title.
public GetFileNameForDownload ( System.VideoInfo video, Category category, string url ) : string
video System.VideoInfo The object that can be used to get some more info.
category Category The that this video comes from.
url string The url from which the download will take place. If null, a favorite name should be returned.
return string

GetMultipleVideoUrls() public method

This function will be called to get the urls for playback of a video. Use this if your video is split into smaller parts for playback.
By default: returns a list with the result from GetVideoUrl.
public GetMultipleVideoUrls ( System.VideoInfo video, bool inPlaylist = false ) : List
video System.VideoInfo The object, for which to get a list of urls.
inPlaylist bool
return List

GetNextPageVideos() public method

This function should return the videos of the next page. No state is given, so the class implementation has to remember and set the current category and page itself. It will only be called if HasNextPage returned true on the last call and after the user selected the menu entry for "next page".
default: empty list
public GetNextPageVideos ( ) : List
return List

GetPlaylistItemVideoUrl() public method

Allows the Util to resolve the url of a playlist item to playback options or a new url directly before playback.
public GetPlaylistItemVideoUrl ( System.VideoInfo clonedVideoInfo, string chosenPlaybackOption, bool inPlaylist = false ) : string
clonedVideoInfo System.VideoInfo A clone of the original object, given in , with the VideoUrl set to one of the urls returned.
chosenPlaybackOption string the key from the of the first video chosen by the user
inPlaylist bool
return string

GetSearchableCategories() public method

Will be called to get the list of categories (names only) that can be chosen to search. The keys will be the names and the value will be given to the Search as parameter.
default: returns empty list, so no category specific search can be done This is also used if HasFilterCategories returns true
public GetSearchableCategories ( ) : string>.Dictionary
return string>.Dictionary

GetTrackingInfo() public method

This method will ask the Util to provide information for a VideoInfo that can be used to identify the video for http://trakt.tv/.
public GetTrackingInfo ( System.VideoInfo video ) : ITrackingInfo
video System.VideoInfo The to get info for.
return ITrackingInfo

GetVideoUrl() public method

This function will be called when the user selects a video for playback. It should return the absolute url to the video file.
By default, the VideoInfo.VideoUrl fields value will be returned.
public GetVideoUrl ( System.VideoInfo video ) : String
video System.VideoInfo The from the list of displayed videos that were returned by this instance previously.
return String

GetVideos() public abstract method

This is the only function a subclass has to implement. It's called when a user selects a category in the GUI.
It should return a list of videos for that category, reset the paging indexes, remember this category, whatever is needed to hold state, because a call to HasNextPage and GetNextPageVideos will not give any parameter.
public abstract GetVideos ( Category category ) : List
category Category The that was selected by the user.
return List

Initialize() public method

You should always call this implementation, even when overriding it. It is called after the instance has been created in order to configure settings from the xml for this util.
public Initialize ( SiteSettings siteSettings ) : void
siteSettings SiteSettings
return void

IsPossibleVideo() public method

This function checks a given string, if it points to a file that is a valid video. It will check for protocol and known and supported video extensions.
public IsPossibleVideo ( string fsUrl ) : bool
fsUrl string the string to check which should be a valid URI.
return bool

OnDownloadEnded() public method

This method will be called after download of a video from this site was stopped or has ended.
public OnDownloadEnded ( System.VideoInfo video, string url, double percent, bool stoppedByUser ) : void
video System.VideoInfo
url string
percent double
stoppedByUser bool
return void

OnPlaybackEnded() public method

This method will be called after playback of a video from this site was stopped or has ended.
public OnPlaybackEnded ( System.VideoInfo video, string url, double percent, bool stoppedByUser ) : void
video System.VideoInfo
url string
percent double
stoppedByUser bool
return void

Search() public method

Should return a list of VideoInfo or Category for the given query - limited to the given category if not null.
All items in the list must be of the same type!
default: returns empty list
public Search ( string query, string category = null ) : List
query string The user entered query.
category string The category to search in, can be null to indicate a global search - not limited to a category.
return List

ToString() public method

public ToString ( ) : string
return string