Ejemplo n.º 1
0
        def fetch_info():
            full_description = file_object.info["description"] + "\n\n" + \
                gettext("<b>Cast:</b> ") + ", ".join(file_object.info["cast"]) + "\n" + \
                gettext("<b>Genere:</b> ") + file_object.info["genere"] + "\n" + \
                gettext("<b>Language:</b> ") + file_object.info["language"]

            return file_object.name, full_description
Ejemplo n.º 2
0
        def fetch_info():
            full_description = file_object.info["description"] + "\n\n" + \
                gettext("<b>Cast:</b> ") + ", ".join(file_object.info["cast"]) + "\n" + \
                gettext("<b>Genere:</b> ") + file_object.info["genere"] + "\n" + \
                gettext("<b>Language:</b> ") + file_object.info["language"]

            return file_object.name, full_description
Ejemplo n.º 3
0
        def fetch_info():

            description = file_object.info.get("description", "")
            cast = file_object.info.get("cast", [])
            genere = file_object.info.get("genere", "")
            language = file_object.info.get("language", "")

            full_description = description + "\n\n" + \
                gettext("<b>Cast:</b> ") + ", ".join(cast) + "\n" + \
                gettext("<b>Genere:</b> ") + genere + "\n" + \
                gettext("<b>Language:</b> ") + language

            return file_object.name, full_description
Ejemplo n.º 4
0
        def fetch_info():

            description = file_object.info.get("description", "")
            cast = file_object.info.get("cast", [])
            genere = file_object.info.get("genere", "")
            language = file_object.info.get("language", "")

            full_description = description + "\n\n" + \
                gettext("<b>Cast:</b> ") + ", ".join(cast) + "\n" + \
                gettext("<b>Genere:</b> ") + genere + "\n" + \
                gettext("<b>Language:</b> ") + language

            return file_object.name, full_description
Ejemplo n.º 5
0
    def open_in_original(self, *args):
        """ Open selected episode or movie on his original website. """

        path, _ = self.file_viewer.get_cursor()
        file_object = self.file_viewer_model[path][FILE_VIEW_COLUMN_OBJECT]
        try:
            url = file_object.original_url
        except NotImplementedError:
            self.report_error(gettext("Option not avaliable in this site"))
            return
        except:
            self.report_error(gettext("Error opening original url: %s") % error)
            return

        webbrowser.open(url)
Ejemplo n.º 6
0
    def _on_menu_download_clicked(self, widget, download_only=False):
        """ Called when the user click on the download and
        play context menu item. """

        chooser = gtk.FileChooserDialog(
            title=gettext("Dowload to..."),
            parent=self.main_window,
            action=gtk.FILE_CHOOSER_ACTION_SELECT_FOLDER,
            buttons=(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL, gtk.STOCK_SAVE,
                     gtk.RESPONSE_OK))

        last_download_dir = self.config.get_key("last_download_directory")
        chooser.set_current_folder(last_download_dir)
        response = chooser.run()

        if response != gtk.RESPONSE_OK:
            chooser.destroy()
            return

        save_to = chooser.get_filename()
        self.config.set_key("last_download_directory", save_to)
        chooser.destroy()

        path, _ = self.file_viewer.get_cursor()
        file_object = self.file_viewer_model[path][FILE_VIEW_COLUMN_OBJECT]
        Player(self, file_object, save_to, download_only=download_only)
Ejemplo n.º 7
0
    def _on_menu_download_clicked(self, widget, download_only=False):
        """ Called when the user click on the download and
        play context menu item. """

        chooser = gtk.FileChooserDialog(title=gettext("Dowload to..."),
                  parent=self.main_window,
                  action=gtk.FILE_CHOOSER_ACTION_SELECT_FOLDER,
                  buttons=(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL,
                  gtk.STOCK_SAVE, gtk.RESPONSE_OK))

        last_download_dir = self.config.get_key("last_download_directory")
        chooser.set_current_folder(last_download_dir)
        response = chooser.run()

        if response != gtk.RESPONSE_OK:
            chooser.destroy()
            return

        save_to = chooser.get_filename()
        self.config.set_key("last_download_directory", save_to)
        chooser.destroy()

        path, _ = self.file_viewer.get_cursor()
        file_object = self.file_viewer_model[path][FILE_VIEW_COLUMN_OBJECT]
        Player(self, file_object, save_to, download_only=download_only)
Ejemplo n.º 8
0
    def open_in_original(self, *args):
        """ Open selected episode or movie on his original website. """

        path, _ = self.file_viewer.get_cursor()
        file_object = self.file_viewer_model[path][FILE_VIEW_COLUMN_OBJECT]
        try:
            url = file_object.original_url
        except NotImplementedError:
            self.report_error(gettext("Option not avaliable in this site"))
            return
        except:
            self.report_error(
                gettext("Error opening original url: %s") % error)
            return

        webbrowser.open(url)
Ejemplo n.º 9
0
    def _on_file_viewer_open(self, widget, path, *args):
        """ Called when the user double clicks on a file
        inside the file viewer. """

        file_object = self.file_viewer_model[path][FILE_VIEW_COLUMN_OBJECT]

        mode = self.get_mode()

        if isinstance(file_object, self.api.Movie):
            Player(self, file_object)
        elif isinstance(file_object, self.api.Season):
            self.current_season = file_object

            self.path_label.set_text("%s / %s" % \
                    (self.current_show.name, self.current_season.name))

            def fetch_episodes():
                return [x for x in file_object.episodes]

            self.background_task(fetch_episodes, self.display_episodes)

        elif isinstance(file_object, self.api.Episode):
            Player(self, file_object)
        elif file_object == None:

            def fetch_seasons():
                return [x for x in self.current_show.seasons]

            self.background_task(fetch_seasons, self.display_seasons,
                status_message=gettext("Loading show %s...") % \
                                       self.current_show.name)
Ejemplo n.º 10
0
    def _on_file_viewer_open(self, widget, path, *args):
        """ Called when the user double clicks on a file
        inside the file viewer. """

        file_object = self.file_viewer_model[path][FILE_VIEW_COLUMN_OBJECT]

        mode = self.get_mode()

        if isinstance(file_object, self.api.Movie):
            Player(self, file_object)
        elif isinstance(file_object, self.api.Season):
            self.current_season = file_object

            self.path_label.set_text("%s / %s" % \
                    (self.current_show.name, self.current_season.name))

            def fetch_episodes():
                return [x for x in file_object.episodes]

            self.background_task(fetch_episodes, self.display_episodes)

        elif isinstance(file_object, self.api.Episode):
            Player(self, file_object)
        elif file_object == None:

            def fetch_seasons():
                return [x for x in self.current_show.seasons]

            self.background_task(fetch_seasons, self.display_seasons,
                status_message=gettext("Loading show %s...") % \
                                       self.current_show.name)
Ejemplo n.º 11
0
    def set_mode_recomended(self):
        """ Sets the curret mode to recomended movies. """

        self.sidebar.hide()
        self.background_task(
            self.api.Movie.get_recomended,
            self.display_movies,
            status_message=gettext("Loading recomended movies..."))
Ejemplo n.º 12
0
    def set_mode_latest(self):
        """ Sets the curret mode to latest movies. """

        self.sidebar.hide()
        self.background_task(
            self.api.Movie.get_latest,
            self.display_movies,
            status_message=gettext("Loading latest movies..."))
Ejemplo n.º 13
0
    def set_mode_shows(self, *args):
        """ Sets the current mode to shows. """

        self.sidebar.show()
        self.search_entry.set_text("")
        self.name_filter.set_text("")
        self.path_label.set_text("")
        self.name_list_model.clear()
        self.background_task(self.api.Show.search, self.display_shows,
                             status_message=gettext("Obtaining shows list"))
Ejemplo n.º 14
0
    def set_mode_favorites(self):
        """ Sets the current mode to favorites. """

        self.sidebar.show()
        self.search_entry.set_text("")
        self.path_label.set_text("")
        self.name_filter.set_text("")

        self.background_task(self.favorites.get_all, self.display_favorites,
                             status_message=gettext("Loading favorites"))
Ejemplo n.º 15
0
    def set_mode_favorites(self):
        """ Sets the current mode to favorites. """

        self.sidebar.show()
        self.search_entry.set_text("")
        self.path_label.set_text("")
        self.name_filter.set_text("")

        self.background_task(self.favorites.get_all,
                             self.display_favorites,
                             status_message=gettext("Loading favorites"))
Ejemplo n.º 16
0
    def set_mode_shows(self, *args):
        """ Sets the current mode to shows. """

        self.sidebar.show()
        self.search_entry.set_text("")
        self.name_filter.set_text("")
        self.path_label.set_text("")
        self.name_list_model.clear()
        self.background_task(self.api.Show.search,
                             self.display_shows,
                             status_message=gettext("Obtaining shows list"))
Ejemplo n.º 17
0
    def _on_search_activate(self, *args):
        """ Called when the user does a search. """

        # Sets the correct mode
        self.set_mode_movies()
        self.mode_combo.set_active(self.avaliable_modes.index("Movies"))

        query = self.search_entry.get_text()
        self.background_task(self.api.Movie.search,
            self.display_movies, query,
            status_message=gettext("Searching movies with title %s...") % query)
Ejemplo n.º 18
0
    def _on_search_activate(self, *args):
        """ Called when the user does a search. """

        # Sets the correct mode
        self.set_mode_movies()
        self.mode_combo.set_active(self.avaliable_modes.index("Movies"))

        query = self.search_entry.get_text()
        self.background_task(
            self.api.Movie.search,
            self.display_movies,
            query,
            status_message=gettext("Searching movies with title %s...") %
            query)
Ejemplo n.º 19
0
    def _on_show_selected(self, tree_view, path, column):
        """ Called when the user selects a show from the name list. """

        self.file_viewer_model.clear()

        model = tree_view.get_model()
        selected_show = model[path][NAME_LIST_COLUMN_OBJECT]

        self.current_show = selected_show
        self.path_label.set_text(selected_show.name)

        def fetch_seasons():
            return [x for x in selected_show.seasons]

        self.background_task(fetch_seasons, self.display_seasons,
            status_message=gettext("Loading show %s...") % selected_show.name)
Ejemplo n.º 20
0
    def _on_show_selected(self, tree_view, path, column):
        """ Called when the user selects a show from the name list. """

        self.file_viewer_model.clear()

        model = tree_view.get_model()
        selected_show = model[path][NAME_LIST_COLUMN_OBJECT]

        self.current_show = selected_show
        self.path_label.set_text(selected_show.name)

        def fetch_seasons():
            return [x for x in selected_show.seasons]

        self.background_task(fetch_seasons,
                             self.display_seasons,
                             status_message=gettext("Loading show %s...") %
                             selected_show.name)
Ejemplo n.º 21
0
    def background_task(self, func, callback=None, *args, **kwargs):
        """
        Freezes the gui, starts a thread with func.
        When it's done, unfreezes the gui and calls callback with the result.

        The results it's a tuple (is_error, result) with a boolean if
        an error has ocurred and the exception, or the result if there
        was no errors.
        """

        status_message = gettext("Loading...")
        freeze = True

        if "status_message" in kwargs:
            status_message = kwargs["status_message"]
            del kwargs["status_message"]

        if "freeze" in kwargs:
            freeze = kwargs["freeze"]
            del kwargs["freeze"]

        if freeze:
            self.freeze(status_message)
        else:
            kwargs["unfreeze"] = False

        if "unfreeze" in kwargs and not kwargs["unfreeze"]:
            real_callback = callback
            del kwargs["unfreeze"]
        else:

            def real_callback(result):
                self.unfreeze()
                callback(result)

        if callback == None:

            def real_callback((is_error, result)):
                pass

        GtkThreadRunner(real_callback, func, *args, **kwargs)
Ejemplo n.º 22
0
    def background_task(self, func, callback=None, *args, **kwargs):
        """
        Freezes the gui, starts a thread with func.
        When it's done, unfreezes the gui and calls callback with the result.

        The results it's a tuple (is_error, result) with a boolean if
        an error has ocurred and the exception, or the result if there
        was no errors.
        """

        status_message = gettext("Loading...")
        freeze = True

        if "status_message" in kwargs:
            status_message = kwargs["status_message"]
            del kwargs["status_message"]

        if "freeze" in kwargs:
            freeze = kwargs["freeze"]
            del kwargs["freeze"]

        if freeze:
            self.freeze(status_message)
        else:
            kwargs["unfreeze"] = False

        if "unfreeze" in kwargs and not kwargs["unfreeze"]:
            real_callback = callback
            del kwargs["unfreeze"]
        else:
            def real_callback(result):
                self.unfreeze()
                callback(result)

        if callback == None:
            def real_callback((is_error, result)):
                pass

        GtkThreadRunner(real_callback, func, *args, **kwargs)
Ejemplo n.º 23
0
    def set_mode_recomended(self):
        """ Sets the curret mode to recomended movies. """

        self.sidebar.hide()
        self.background_task(self.api.Movie.get_recomended, self.display_movies,
            status_message=gettext("Loading recomended movies..."))
Ejemplo n.º 24
0
    def set_mode_latest(self):
        """ Sets the curret mode to latest movies. """

        self.sidebar.hide()
        self.background_task(self.api.Movie.get_latest, self.display_movies,
            status_message=gettext("Loading latest movies..."))
Ejemplo n.º 25
0
    def freeze(self, status_message=gettext("Loading...")):
        """ Freezes the gui so the user can't interact with it. """

        self.header_hbox.set_sensitive(False)
        self.main_hpaned.set_sensitive(False)
        self.set_status_message(status_message)
Ejemplo n.º 26
0
        return (site_text, site_module)

    def report_error(self, message):
        """ Shows up an error dialog to the user. """

        self.error_label.set_label(message)
        self.error_dialog.show_all()
        self.set_status_message("")
        self.unfreeze()

    def display_favorites(self, (is_error, result)):
        self.name_list_model.clear()

        if is_error:
            self.report_error(gettext("Error loading favorites: %s") % result)
            return

        for favorite in result:
            try:
                show = self.api.Show.search(favorite).next()
            except StopIteration:
                log.warn("didin't find %s in show list" % favorite)
                continue

            self.name_list_model.append([show.name, show])

    def display_shows(self, (is_error, result)):
        """ Displays the shows. """

        self.name_list_model.clear()
Ejemplo n.º 27
0
"""
Guicavane constants.

Module with constants values.
"""

import os
import sys
import gtk
from Gettext import gettext

from Paths import GUI_DIR, IMAGES_DIR, SEP

# Modes
MODES = {
    "Shows": gettext("Shows"),
    "Movies": gettext("Movies"),
    "Favorites": gettext("Favorites"),
    "Latest": gettext("Latest movies"),
    "Recomended": gettext("Recomended movies"),
}

# Index of the columns on the tree views
FILE_VIEW_COLUMN_PIXBUF = 0
FILE_VIEW_COLUMN_TEXT = 1
FILE_VIEW_COLUMN_OBJECT = 2

NAME_LIST_COLUMN_TEXT = 0
NAME_LIST_COLUMN_OBJECT = 1

HOSTS_VIEW_COLUMN_PIXBUF = 0
Ejemplo n.º 28
0
    def freeze(self, status_message=gettext("Loading...")):
        """ Freezes the gui so the user can't interact with it. """

        self.header_hbox.set_sensitive(False)
        self.main_hpaned.set_sensitive(False)
        self.set_status_message(status_message)
Ejemplo n.º 29
0
"""
Guicavane constants.

Module with constants values.
"""

import os
import sys
import gtk
from Gettext import gettext

from Paths import GUI_DIR, IMAGES_DIR, SEP

# Modes
MODES = {
    "Shows": gettext("Shows"),
    "Movies": gettext("Movies"),
    "Favorites": gettext("Favorites"),
    "Latest": gettext("Latest movies"),
    "Recomended": gettext("Recomended movies"),
}

# Index of the columns on the tree views
FILE_VIEW_COLUMN_PIXBUF = 0
FILE_VIEW_COLUMN_TEXT = 1
FILE_VIEW_COLUMN_OBJECT = 2

NAME_LIST_COLUMN_TEXT = 0
NAME_LIST_COLUMN_OBJECT = 1

HOSTS_VIEW_COLUMN_PIXBUF = 0
Ejemplo n.º 30
0
        return (site_text, site_module)

    def report_error(self, message):
        """ Shows up an error dialog to the user. """

        self.error_label.set_label(message)
        self.error_dialog.show_all()
        self.set_status_message("")
        self.unfreeze()

    def display_favorites(self, (is_error, result)):
        self.name_list_model.clear()

        if is_error:
            self.report_error(gettext("Error loading favorites: %s") % result)
            return

        for favorite in result:
            try:
                show = self.api.Show.search(favorite).next()
            except StopIteration:
                log.warn("didin't find %s in show list" % favorite)
                continue

            self.name_list_model.append([show.name, show])

    def display_shows(self, (is_error, result)):
        """ Displays the shows. """

        self.name_list_model.clear()