Vidscraper defines a simple API for “Suites”, classes which provide the functionality necessary for scraping video information from a specific video service.
An instance of SuiteRegistry which is used by vidscraper to track registered suites.
A registry of suites. Suites may be registered, unregistered, and iterated over.
For each registered suite, calls get_feed() with the given parameters, until a suite returns a feed instance.
Returns: | An instance of a specific suite’s feed_class with no data loaded. |
---|---|
Raises : | UnhandledFeed if no registered suites know how to handle this url. |
For each registered suite, calls get_search() with the given parameters.
Returns: | a list of iterators over search results for suites which support the given parameters. |
---|
For each registered suite, calls get_video() with the given url, fields, and api_keys, until a suite returns a Video instance.
Parameters: | require_loaders – Changes the behavior if no suite is found which handles the given parameters. If True (default), UnhandledVideo will be raised; otherwise, a video will returned with the given url and fields, but it will not be able to load any additional data. |
---|---|
Raises : | UnhandledVideo if require_loaders is True and no registered suite returns a video for the given parameters. |
Returns: | Video instance with no data loaded. |
Returns True if any registered suite can make a feed with the given parameters, and False otherwise.
Note
This does all the work of creating a feed, then discards it. If you are going to use a feed instance if one is created, it would be more efficient to use get_feed() directly.
Returns True if any registered suite can make a video with the given parameters, and False otherwise.
Note
This does all the work of creating a video, then discards it. If you are going to use a video instance if one is created, it would be more efficient to use get_video() directly.
Registers a suite if it is not already registered.
Registers a fallback suite, which is tried only if no other suite successfully handles a given video, feed, or search.
Returns a tuple of registered suites. If a fallback is registered, it will always be at the end of this tuple.
Unregisters a suite if it is registered.
This is a base class for suites, demonstrating the API which is expected when interacting with suites. It is not suitable for actual use; some vital methods must be defined on a suite-by-suite basis.
Returns a set of all of the fields we could possibly get from this suite.
A string or precompiled regular expression which will be matched against feed urls to check if they can be handled by this suite.
Returns an instance of feed_class, which should be a subclass of BaseFeed.
Raises : | UnhandledFeed if feed_class is None. |
---|
Returns an instance of search_class, which should be a subclass of BaseSearch.
Raises : | UnhandledSearch if search_class is None. |
---|
Returns a video using this suite’s loaders. This instance will not have data loaded.
Parameters: |
|
---|---|
Raises : | UnhandledVideo if none of this suite’s loaders can handle the given url and api keys. |
Returns True if this suite can make a feed with the given parameters, and False otherwise.
Note
This does all the work of creating a feed, then discards it. If you are going to use a feed instance if one is created, it would be more efficient to use get_feed() directly.
Returns True if this suite can make a search with the given parameters, and False otherwise.
Returns True if this suite can make a video with the given parameters, and False otherwise.
Note
This does all the work of creating a video, then discards it. If you are going to use a video instance if one is created, it would be more efficient to use get_video() directly.
A list or tuple of VideoLoader classes which will be used to populate videos with data. These loaders will be run in the order they are given, so it’s a good idea to order them by the effort they would require; for example, OEmbed should generally come first, since the response is small and easy to parse compared to, say, a page scrape.
See also
A BaseSearch subclass that will be used to run searches for this suite.
A string or precompiled regular expression which will be matched against video urls to check if they can be handled by this suite.