Exemple #1
0
    def onClick(self,control):
        xbmc.log(str(control))
        if control==104:
            self.do_now_playing()

        if control==105:
            self.do_popular()

        if control==201:
            li=self.getControl(201).getSelectedItem()
            movie_id=int(li.getProperty('movie_id'))
            from resources.lib import movie
            movie.movie_id=movie_id
            movie.startup()

        if control==101:
            from resources.lib import movies
            movies.source='popular'
            movies.page=1
            movies.startup()

        if control==102:
            from resources.lib import tvshows
            tvshows.source='popular'
            tvshows.page=1
            tvshows.startup()

        if control==103:
            from resources.lib import people
            people.source='popular'
            people.page=1
            people.startup()

        if control==99:
            xbmc.log('query=' + self.getControl(100).getText())
            from resources.lib import movies
            movies.source='query'
            movies.doSearch(self.getControl(100).getText())
Exemple #2
0
    def onClick(self,control):
        global exit_requested
        global source
        global query
        global page
        global maxpage
        do_tv_shows=False
        do_movies=False

        popular = 32101
        top_rated =  32102
        on_the_air = 32103
        airing_today = 32104
        query_btn = 32110
        previous = 32116
        next =32117
        movies_btn = 32113
        tv_btn=32114
        people_btn=32115

        if control == popular and source!='popular':
            source='popular'
            page=1
            do_tv_shows=True
        if control == top_rated and source!='top_rated':
            source='top_rated'
            do_tv_shows=True
            page=1
        if control == on_the_air and source!='on_the_air':
            source='on_the_air'
            do_tv_shows=True
            page=1
        if control == airing_today and source!='airing_today':
            source='airing_today'
            do_tv_shows=True
            page=1
        if control == query_btn:
            source='query'
            do_tv_shows=True
            page=1
        if control == next:
            if page < maxpage:
                page=page+1
                do_tv_shows=True
        if control == previous:
            if page > 1:
                page=page-1
                do_tv_shows=True
        if control == movies_btn:
            do_movies=True
        if control == people_btn:
            do_people=True

        xbmc.log('source ='+source)
        if do_tv_shows:
            if source=='query':
                if control==query_btn:
                    k=xbmc.Keyboard('','Enter TV Show Name to Search For')
                    k.doModal()
                    query=k.getText()
                if query!='':
                    tv_shows=tmdb.search_tv_shows(query,page)
                    maxpage=tv_shows['total_pages']
                    tv_shows=tv_shows['results']
                    if maxpage > page:
                        tv_shows.append(tmdb.search_tv_shows(query,page+1)['results'][0])
                    self.close()
                    show_tv(tv_shows,source,page)
            else:
                query=''
                tv_shows=tmdb.get_tv_shows(source,page)
                maxpage=10
                if source=='airing_today' or source=='on_the_air':maxpage=tv_shows['total_pages']
                total_pages=tv_shows['total_pages']
                tv_shows=tv_shows['results']
                if total_pages > page:
                    tv_shows.append(tmdb.get_tv_shows(source,page+1)['results'][0])
                self.close()
                show_tv(tv_shows,source,page)
        if do_movies:
            from resources.lib import movies
            movies.source='popular'
            movies.startup()
        if do_people:
            from resources.lib import people
            people.source='popular'
            people.startup()
Exemple #3
0
    def onClick(self, control):
        global source
        global query
        global page
        global maxpage
        global genre_id
        global genre_name
        global year
        global person_id
        global person_name
        global keyword_id
        global list_id
        global list_name
        movieid = ""
        movieid = self.get_movieid_from_control(control)
        do_movies = False
        do_tv = False
        do_people = False

        popular = 32101
        top_rated = 32102
        upcoming = 32103
        now_playing = 32104
        favorites = 33105
        watchlist = 33106
        rated = 33107
        list_btn = 33108
        query_btn = 81
        previous = 32116
        next = 32117
        tv_shows = 32114
        people = 32115
        genre_btn = 82
        year_btn = 83
        person_btn = 84

        if movieid != "":
            from resources.lib import movie

            movie.movie_id = movieid
            movie_window = movie.movieWindow("script-movieDetailWindow.xml", addon_path, "default")
            movie_window.doModal()
            del movie_window
        if control == popular and source != "popular":
            source = "popular"
            page = 1
            do_movies = True
        if control == top_rated and source != "top_rated":
            source = "top_rated"
            do_movies = True
            page = 1
        if control == upcoming and source != "upcoming":
            source = "upcoming"
            do_movies = True
            page = 1
        if control == now_playing and source != "now_playing":
            source = "now_playing"
            do_movies = True
            page = 1
        if control == favorites and source != "favorites":
            do_movies = True
            source = "favorites"
            page = 1
        if control == watchlist and source != "watchlist":
            do_movies = True
            source = "watchlist"
            page = 1
        if control == rated and source != "rated":
            do_movies = True
            source = "rated"
            page = 1
        if control == query_btn:
            source = "query"
            do_movies = True
            page = 1
        if control == genre_btn:
            source = "genre"
            page = 1
            genre_id = ""
            do_movies = True
        if control == year_btn:
            source = "years"
            page = 1
            year = ""
            do_movies = True
        if control == person_btn:
            source = "person"
            page = 1
            person_id = ""
            person_name = ""
            do_movies = True
        if control == list_btn:
            source = "list"
            list_id = ""
            page = 1
            do_movies = True
        if control == next:
            if page < maxpage:
                page = page + 1
                do_movies = True
        if control == previous:
            if page > 1:
                page = page - 1
                do_movies = True
        if control == tv_shows:
            do_tv = True
        if control == people:
            do_people = True

        if do_movies:
            ans = True
            if source == "query":
                self.getControl(80).setVisible(True)
                if control == query_btn:
                    k = xbmc.Keyboard("", "Enter Movie Title to Search For")
                    k.doModal()
                    query = k.getText()
                if query != "":
                    movies = tmdb.search_movies(query, page)
                    maxpage = movies["total_pages"]
                    movies = movies["results"]
                    if maxpage > page:
                        movies.append(tmdb.search_movies(query, page + 1)["results"][0])
                    show_movies(movies, source, page)
            elif source == "favorites":
                if self.session_id == "":
                    session_id = utils.get_login()
                    if session_id != "":
                        self.session_id = session_id
                if self.session_id != "":
                    movies = tmdb.get_favorite_movies(self.session_id, page)
                    total_pages = movies["total_pages"]
                    maxpage = total_pages
                    movies = movies["results"]
                    if total_pages > page:
                        movies.append(tmdb.get_favorite_movies(self.session_id, page + 1)["results"][0])
                    show_movies(movies, source, page)
            elif source == "watchlist":
                if self.session_id == "":
                    session_id = utils.get_login()
                    if session_id != "":
                        self.session_id = session_id
                if self.session_id != "":
                    movies = tmdb.get_watchlist_movies(self.session_id, page)
                    total_pages = movies["total_pages"]
                    maxpage = total_pages
                    movies = movies["results"]
                    if total_pages > page:
                        movies.append(tmdb.get_watchlist_movies(self.session_id, page + 1)["results"][0])
                    show_movies(movies, source, page)
            elif source == "rated":
                if self.session_id == "":
                    session_id = utils.get_login()
                    if session_id != "":
                        self.session_id = session_id
                if self.session_id != "":
                    movies = tmdb.get_rated_movies(self.session_id, page)
                    total_pages = movies["total_pages"]
                    maxpage = total_pages
                    movies = movies["results"]
                    if total_pages > page:
                        movies.append(tmdb.get_rated_movies(self.session_id, page + 1)["results"][0])
                    show_movies(movies, source, page)
            elif source == "list":
                if self.session_id == "":
                    session_id = utils.get_login()
                    if session_id != "":
                        self.session_id = session_id
                if self.session_id != "" and list_id == "":
                    dg = dialogWindow("dialog_select.xml", addon_path, "Default")
                    dg.mode = "list"
                    dg.doModal()
                if list_name == "Add New":
                    k = xbmc.Keyboard("", "Enter List Name")
                    k.doModal()
                    name = k.getText()
                    if name != "" and (k.isConfirmed()):
                        k = xbmc.Keyboard("", "Enter List Description")
                        k.doModal()
                        description = k.getText()
                        if k.isConfirmed():
                            res = tmdb.add_list(name, description, addon.getSetting("session_id"))
                            if res:
                                dialog = xbmcgui.Dialog()
                                dialog.notification(
                                    "themoviedb.org Browser",
                                    "List " + name + " Successfully Added",
                                    xbmcgui.NOTIFICATION_INFO,
                                    5000,
                                )
                            else:
                                dialog = xbmcgui.Dialog()
                                dialog.notification(
                                    "themoviedb.org Browser", "Failed Add " + name, xbmcgui.NOTIFICATION_ERROR, 5000
                                )
                if list_id != "":
                    movies = tmdb.get_movie_list(list_id)
                    movies = movies["items"]
                    pages = len(movies) / 20
                    if len(movies) % 20 > 0:
                        pages = pages + 1
                    total_pages = pages
                    maxpage = total_pages
                    list_movies = []
                    if page > 1:
                        for i in range((page * 20) - 20, (page * 20) + 1):
                            if i < len(movies):
                                list_movies.append(movies[i])
                        movies = list_movies
                    show_movies(movies, source, page)
            elif source == "genre":
                if genre_id == "":
                    dg = dialogWindow("dialog_select.xml", addon_path, "Default")
                    dg.mode = "genre"
                    dg.doModal()
                if genre_id != "":
                    movies = tmdb.get_movies_by_genre(genre_id, page)
                    total_pages = movies["total_pages"]
                    movies = movies["results"]
                    maxpage = total_pages
                    if total_pages > page:
                        movies.append(tmdb.get_movies_by_genre(genre_id, page + 1)["results"][0])
                    show_movies(movies, source, page)
            elif source == "years":
                if year == "":
                    kb = xbmc.Keyboard("", "Enter Year")
                    kb.doModal()
                    year = kb.getText()
                movies = tmdb.get_movies_by_year(year, page)
                total_pages = movies["total_pages"]
                movies = movies["results"]
                maxpage = total_pages
                if total_pages > page:
                    movies.append(tmdb.get_movies_by_year(year, page + 1)["results"][0])
                show_movies(movies, source, page)
            elif source == "similar":
                movies = tmdb.get_similar_movies(similar_id, page)
                total_pages = movies["total_pages"]
                movies = movies["results"]
                maxpage = total_pages
                if total_pages > page:
                    movies.append(tmdb.get_similar_movies(similar_id, page + 1)["results"][0])
                show_movies(movies, source, page)
            elif source == "keyword":
                movies = tmdb.getMoviesByKeyword(keyword_id, page)
                total_pages = movies["total_pages"]
                movies = movies["results"]
                maxpage = total_pages
                if total_pages > page:
                    movies.append(tmdb.getMoviesByKeyword(keyword_id, page + 1)["results"][0])
                show_movies(movies, source, page)
            elif source == "person":
                if person_id == "":
                    kb = xbmc.Keyboard("", "Enter Persons Name")
                    kb.doModal()
                    person_name = kb.getText()
                    if person_name != "":
                        dg = dialogWindow("dialog_select.xml", addon_path, "Default")
                        dg.mode = "people"
                        dg.doModal()
                movies = tmdb.getMoviesByActor(person_id, page)
                pages = len(movies) / 20
                if len(movies) % 20 > 0:
                    pages = pages + 1
                total_pages = pages
                xbmc.log(str(len(movies)))
                maxpage = total_pages
                movies = sorted(movies, key=lambda k: k["release_date"], reverse=True)
                person_movies = []
                if page > 1:
                    for i in range((page * 20) - 20, (page * 20) + 1):
                        if i < len(movies):
                            person_movies.append(movies[i])
                    movies = person_movies
                show_movies(movies, source, page)
            elif source in ("Production", "Directing", "Writing"):
                person = tmdb.get_person(person_id)
                crew_movies = person["movie_credits"]["crew"]
                movies = []
                for movie in crew_movies:
                    if movie["department"] == source:
                        movies.append(movie)
                pages = len(movies) / 20
                if len(movies) % 20 > 0:
                    pages = pages + 1
                total_pages = pages
                maxpage = total_pages
                movies = sorted(movies, key=lambda k: k["release_date"], reverse=True)
                person_movies = []
                if page > 1:
                    for i in range((page * 20) - 20, (page * 20) + 1):
                        if i < len(movies):
                            person_movies.append(movies[i])
                    movies = person_movies
                show_movies(movies, source, page)
            else:
                query = ""
                xbmc.log(source)
                movies = tmdb.get_movies(source, page)
                total_pages = movies["total_pages"]
                maxpage = 10
                if source == "upcoming" or source == "now_playing":
                    maxpage = movies["total_pages"]
                movies = movies["results"]
                if total_pages > page:
                    movies.append(tmdb.get_movies(source, page + 1)["results"][0])
                show_movies(movies, source, page)
        elif do_tv:
            from resources.lib import tvshows

            tvshows.source = "popular"
            tvshows.startup()
        elif do_people:
            from resources.lib import people

            people.source = "popular"
            people.startup()
Exemple #4
0
# Random trailer player
#
# Author - kzeleny
# Version - 1.1.8
# Compatibility - Frodo/Gothum
#
import xbmc
import xbmcgui
import xbmcaddon
from resources.lib import tmdb
from resources.lib import movies
from resources.lib import people
from resources.lib import tvshows
from resources.lib import opening

addon = xbmcaddon.Addon()
addon_path = addon.getAddonInfo('path')
start_mode=addon.getSetting('start_mode')

if addon.getSetting('session_id')=='' and addon.getSetting('username')!='' and addon.getSetting('password')!='':
    addon.setSetting('session_id',tmdb.validate_new_user(addon.getSetting('username'),addon.getSetting('password')))

if start_mode=='0':
    opening.startup()
elif start_mode=='1':
    people.startup()
elif start_mode=='2':
    tvshows.startup()
else:
    movies.startup()