There are multiple ways to do this. The main part you need is the video_resolution, and optionally the bitrate within the MediaObject(). Note: Clients will honor bitrate settings over video_resolution.
Example 1:
Traditionally it is better NOT to call a URL within the MediaObjectsForURL() function, as it will slow down a channels performance, especially when videos are presented in a list. So, if you have relatively consistent content (similar bitrates, resolutions, etc… from one video to another) then its better to hard code the resolution and bitrate within the MediaObjectsForURL() and use an @indirect approach to find which resolution and bitrate are truly available.
Services.bundle/Contents/Service Sets/com.plexapp.plugins.vimeo/URL/Vimeo/ServiceCode.pys#L83…L176
Here, because the PlayVideo() is an @indirect Callback, it makes a HTTP request only when a user presses the play button within a Plex Client. The PlayVideo() code tries to find the closes match for the selected bitrate and resolution.
Example 2:
Sometimes it’s not feasible to hard code the bitrate and resolution, as it fluctuates too much between streams, and/or in reality there is only a couple resolutions available instead of hard coding 5 (that may only have a need once-in-a-blue-moon). Alternatively the @deferred method can be used to parse the URL for stream information within the MediaObjectsForURL() and return the direct stream.
UnSupportedServices.bundle/Contents/Service Sets/com.plexapp.plugins.xvideosharing/URL/WatchVideo/ServiceCode.pys#L53…L77
Here the MediaObjectsForURL() does all the work, and returns the video streams directly. It’s pulling down the master m3u8 file, parsing for bitrate, resolution, and stream. Then using list comprehension to build the final MediaObject(). To save some time, each URL is cached for 10 seconds, as many clients make the same request twice rapidly to fill out metadata and stream information.
The official Services.bundle is a good resource for finding service code examples. You may also find some useful examples within my UnSupportedServices.bundle.
Edit
Looking at your post history, is this MYTF1.bundle/Contents/Code/__init__.py#L132…L172 the code your having issues with?
If so, then try including the @indirect decorator and returning an IndirectResponse() from your PlayVideo() function.
Example: GreekTV.bundle/Contents/Code/__init__.py#L133…L152