C# Класс 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.
Наследование: UserConfigurable
Показать файл Открыть проект Примеры использования класса

Открытые методы

Метод Описание
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

Приватные методы

Метод Описание
GetConfigurationKey ( string fieldName ) : string

Описание методов

DiscoverDynamicCategories() публичный Метод

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
Результат int

DiscoverNextPageCategories() публичный Метод

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.
Результат int

DiscoverSubCategories() публичный Метод

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
Результат int

ExecuteContextMenuEntry() публичный Метод

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
Результат OnlineVideos.Sites.ContextMenuExecutionResult

GetContextMenuEntries() публичный Метод

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
Результат List

GetCurrentVideosTitle() публичный Метод

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
Результат string

GetFileNameForDownload() публичный Метод

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.
Результат string

GetMultipleVideoUrls() публичный Метод

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
Результат List

GetNextPageVideos() публичный Метод

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
Результат List

GetPlaylistItemVideoUrl() публичный Метод

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
Результат string

GetSearchableCategories() публичный Метод

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
Результат string>.Dictionary

GetTrackingInfo() публичный Метод

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.
Результат ITrackingInfo

GetVideoUrl() публичный Метод

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.
Результат String

GetVideos() публичный абстрактный Метод

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.
Результат List

Initialize() публичный Метод

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
Результат void

IsPossibleVideo() публичный Метод

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.
Результат bool

OnDownloadEnded() публичный Метод

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
Результат void

OnPlaybackEnded() публичный Метод

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
Результат void

Search() публичный Метод

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.
Результат List

ToString() публичный Метод

public ToString ( ) : string
Результат string