Plugin coding

Let’s walk through the code…

TestPlugin class must implements Plugin interface from plugin-0.4.0.jar library

getPluginName – returns plugin name
getPluginVersionCode – returns version code of plugin it implements (get from, currently it’s 3
init – plugin init actions at plugin loading
setPluginIcon – icon.png from jar as Object will be set at plugin loading (leave unchanged)
getPluginIcon – returns plugin icon (leave unchanged)

refresh – download current URL and parse current page text
getNames – returns current page videos and folders names
getURLs – returns current page videos and folders URLs
getTypes – returns current page items types
getThumbs – returns current page items thumbs URLs
isProvideExtraData – returns true if plugin returns thumbs and descriptions, otherwise false
getDescription – returns current page itemNum‘s link description

nextPage – save current URL to urlsHistory, go to next page, then refresh. If refresh is not successful, then return to previous page.
previousPage – go to previous page from urlsHistory, then refresh
selectItem – go to selected item URL if it’s a folder, save current URL to urlsHistory and refresh
setFileslink – enter to filesLink. Used for Favorites implementation. Can do nothing.
getFilesLink – get filesLink. Used for Favorites implementation. Can do nothing.

testPlugin – refresh data from current URL and print fetched data to terminal
main – can be used for plugin local testing without putting plugin to Perfect Player

All previous methods seems to be the same for the most other plugins

The core part of plugin is current page text parsing. Let’s look at the source code from the page of our base link:

Method parsePage is used to fetch thumbs URLs, videos names, URLs and descriptions from current page text

If we found needed data on parsing, then generate arrays: names, urls, types, thumbsURLs, descriptions to return them to player on request

If you have any questions about plugins coding, please, contact: