Play Locally Stored "TV Show TRAILERS" (non addon, but using python from skin)
#1
Hi, i start to learn a few basics, and want to share.

With that script and some xml editing every skin should be able to play locally stored TVShow Trailers .....
(could be used also on Movies , but you should check with condition - "String.IsEmpty(ListItem.Trailer)" as long as PlayMedia($INFO[ListItem.Trailer] works fine )

.... as long as they are saved in/as .mp4
              [*path*/(tvshow/movietitle=FOLDERNAME)/FOLDERNAME-trailer.mp4]
Quote:example for Shows >        \*whatever*\Bates Motel\Bates Motel-trailer.mp4
                                       \*whatever*\House of Cards (US)\House of Cards (US)-trailer.mp4

example for Movies >        \*whatever*\12 Years a Slave (2013)\12 Years a Slave (2013)-trailer.mp4
                                       \*whatever*\16 Uhr 50 ab Paddington (1961)\16 Uhr 50 ab Paddington (1961)-trailer.mp4

Create this python scrip and put it into your "skin/scripts" folder
checkexist.py
## -*- coding: utf-8 -*-
import xbmc
import xbmcvfs

trailerfilenamemp4 =  xbmc.getInfoLabel( "listitem.path" ) + xbmc.getInfoLabel( "listitem.FolderName" ) + "-trailer" + ".mp4"

if xbmcvfs.exists(trailerfilenamemp4):
    xbmc.executebuiltin( "SetProperty(trailer_avail,true,home)" )
else:
    pass

Now you can call it with
RunScript(special://skin/scripts/checkexist.py)

Benefit:

If file found it'll write a window property to true, wich can be used for visible conditions.
So you can prefer local trailers and use a youtube search as fallback if you like (skinhelper/or other custom script needed)

Con:  - Limited to mp4 files only (as i have no idea how to script it with diff filetypes/suffixes)
        - im unsure how it works on mac OS, or using emby
        - untested on widgets

EXAMPLE for simple use without depending skinsettings

place script

/%yourskin ID%/scripts/checkexist.py

created include

<include name="check_local_trailer">
        <control type="button">
              <visible>false</visible>
              <onfocus>RunScript(special://skin/scripts/checkexist.py)</onfocus> <!-- faster,than skinhelper check -->
              <onunfocus condition="!String.IsEmpty(Window(home).Property(trailer_avail))">ClearProperty(trailer_avail,home)</onunfocus>
        </control>
</include>

call the include on focused items in library

<focusedlayout width="**" height="**">
            <control type="group">
                 .
                 .
                <include>check_local_trailer</include>
                 .
                 .
             </control>
 </focusedlayout>

use playtrailer command
PlayMedia($INFO[listitem.path]$INFO[ListItem.FolderName,,-trailer.mp4],1) <!-- windowed , if you prefer default fullscreen delete ",1" -->
Skins                                                                                        
Reply
#2
thanks for the information
Reply
#3
Am I missing something? I thought most skins would play the local trailer if you have one already, else it goes to youtube and gets one referenced in the metadata that got scraped without the need of assistance.
Shield TV | Windows 10 | Mariadb | Mii Box
Evolve Ecosystem Repo | TV Melodies | Madnox Holiday Mod
Reply
#4
(2019-01-16, 10:40)smitchell6879 Wrote: Am I missing something? I thought most skins would play the local trailer if you have one already, else it goes to youtube and gets one referenced in the metadata that got scraped without the need of assistance.
 Only for movies. ListItem.Trailer is available just for movies content.

I thought about doing this as well in the past, here r my 2 cents...
Achieving this can be also done via a playtrailer command (script helper service) thus having youtube as fallback, something like this:
Code:

item_path = xbmc.getInfoLabel('Container({}).ListItem().Path'.format(xbmc.getInfoLabel('System.CurrentControlID')))
dirs, files = xbmcvfs.listdir(item_path)
for filename in files:
    if "-trailer" in filename.lower():
        trailer_file = os.path.join(item_path, filename)
        xbmc.executebuiltin('PlayMedia("%s",1)' % trailer_file)

Few issues with that:
1) if condition would be satisfied with '-trailer' in filename (no matter where it is placed)
Solution would be to check against regex pattern or remove .ext and check with str.endswith()
note: this does not check that the file is actually a video file...
2) won't work on some widgets, those will return videodb:// with listitem.folderpath.
Solution might be be either to translate videodb to local path (how?!) or using script helper to add each tvshow custom listitem.trailer and using that (at least as fallback).
Reply
#5
(2019-01-16, 10:40)smitchell6879 Wrote: Am I missing something? I thought most skins would play the local trailer if you have one already, else it goes to youtube and gets one referenced in the metadata that got scraped without the need of assistance.
Movies get scraped, yes.

But it s impossible for srapping tv show trailers.
Skins                                                                                        
Reply
#6
but i thought there is simple way. to use youtube addon for title search?
Reply
#7
(2019-01-20, 09:32)moshep15 Wrote: but i thought there is simple way. to use youtube addon for title search?
 (a) since it's not pre-scraped, youtube lookup takes more time (SIGNIFICANTLY MORE) & computational resources
(b) youtube match it's most relevant result based on the search query - tvshows trailers have much more chance to be a missmatch or give a trailer of a specific season instead of series
Reply
#8
Why Kodi team won't simply implement/allow playing local trailers for tv just like it (Kodi) can easily do the same for movies. I don't understand.
Reply
#9
(2019-03-31, 06:38)VikkiXavier Wrote: Why Kodi team won't simply implement/allow playing local trailers for tv just like it (Kodi) can easily do the same for movies. I don't understand.
The trailer url is supplied by a scraper, which is a addon for Kodi. Plus as mentioned above, only movies trailers are scraped at the mo. Smile
Would be good to have tvshow trailers but there needs to be some sort of db to back that up.
Reply
#10
(2019-03-31, 10:59)Steveb Wrote:
(2019-03-31, 06:38)VikkiXavier Wrote: Why Kodi team won't simply implement/allow playing local trailers for tv just like it (Kodi) can easily do the same for movies. I don't understand.
The trailer url is supplied by a scraper, which is a addon for Kodi. Plus as mentioned above, only movies trailers are scraped at the mo. Smile
Would be good to have tvshow trailers but there needs to be some sort of db to back that up. 

Thanks for the kind information. What is "the mo", btw?
Reply
#11
mo. = at this moment I think.
MediaBrazil forum Website - Youtube Channel
Aeon MQ9-0.1.0 & Ace2 Skin Team
MarcosQui Website Donate and support us.
Reply
#12
btw, with my script.bingie.helper tvshow trailers can be fetched & played from either youtube or local source...
Reply
#13
@cartman.dos  Your TITAN BINGIE Skin is the only Skin currently that offers a trailer solution for TvShows. From the pure technical point of view. To what extent does your implementation differ from that of @mardukL
Reply
#14
(2019-04-02, 09:55)chrissix Wrote: @cartman.dos  Your TITAN BINGIE Skin is the only Skin currently that offers a trailer solution for TvShows. From the pure technical point of view. To what extent does your implementation differ from that of @mardukL

He uses the script (skinhelper )
to lookup for local tv show trailer, (if not exist it ll do yt online lookup) which result in a smaler code for the skinner, as he dont need to use conditional actions
e.g.

<onup condition="!Player.HasVideo + !String.IsEmpty(Window(home).Property(trailer_avail))">PlayMedia($INFO[listitem.path]$INFO[ListItem.FolderName,,-trailer.mp4],1)</onup> 
<onup condition="!Player.HasVideo + [!String.IsEmpty(ListItem.Trailer) + String.IsEmpty(Window(home).Property(trailer_avail))]">PlayMedia($INFO[ListItem.Trailer],1)</onup> 
<onup condition="!Player.HasVideo + [[String.IsEmpty(Window(home).Property(trailer_avail)) + String.IsEmpty(ListItem.Trailer)] | ListItem.IsCollection | String.Contains(ListItem.Path,http)]">RunScript(script.skin.helper.service,action=playtraileryoutube,mode=windowed,title=$INFO[ListItem.Title],local=true)</onup>


and i think i doesnt matter which file type(mp4; avi; etc) you like to have.



And btw, my mod offers the tv show trailer ,too.(but without skinhelper, just the method like it is descripted in op)  ;-)
Skins                                                                                        
Reply
#15
(2019-04-02, 10:47)mardukL Wrote: And btw, my mod offers the tv show trailer ,too.(but without skinhelper, just the method like it is descripted in op)  ;-)

I apologize for that! Have most of the core features of the skins in overview, but that i overlooked for somehow reason.
Both solutions are very promising!

What I would generally wish in addition:
-> Independence from file extension (although i only use .mp4)
-> Both variants, only trailer.mp4 as well TvShowName-trailer.mp4 are possible.
(Although only for me personally spoken, second makes more sense for movies, and first for TvShows)

As far as I know, both solutions working with visible conditions, i mean when implementing a trailer button:
-> If no trailer is there so then no trailer button visible, if trailer there then show trailer button
Reply
 
Thread Rating:
  • 0 Vote(s) - 0 Average



Logout Mark Read Team Forum Stats Members Help
Play Locally Stored "TV Show TRAILERS" (non addon, but using python from skin)00