Ejemplo n.º 1
0
    def get_subtitle(self):
        desc = NotAvailable
        a = self.parser.select(self.document.getroot(), 'a#bt-dwl', 1)
        id = a.attrib.get('rel', '').split('/')[-1]
        m = re.match('Download \((\w+)\)', self.parser.tocleanstring(a))
        if m:
            ext = m.group(1)
        else:
            ext = u'zip'
        url = unicode('http://www.opensubtitles.org/subtitleserve/sub/%s' % id)
        link = self.parser.select(self.document.getroot(), 'link[rel=bookmark]', 1)
        title = unicode(link.attrib.get('title', ''))
        nb_cd = int(title.lower().split('cd')[0].split()[-1])
        lang = unicode(title.split('(')[1].split(')')[0])
        file_names = self.parser.select(self.document.getroot(), "img[title~=filename]")
        if len(file_names) > 0:
            file_name = file_names[0].getparent().text_content()
            file_name = ' '.join(file_name.split())
            desc = u'files :'
            for f in file_names:
                desc_line = f.getparent().text_content()
                desc += '\n'+' '.join(desc_line.split())
        name = unicode('%s (%s)' % (title, file_name))

        subtitle = Subtitle(id, name)
        subtitle.url = url
        subtitle.ext = ext
        for lshort, llong in LANGUAGE_CONV.items():
            if lang == llong:
                lang = unicode(lshort)
                break
        subtitle.language = lang
        subtitle.nb_cd = nb_cd
        subtitle.description = desc
        return subtitle
Ejemplo n.º 2
0
    def __init__(self, movie, backend, parent=None):
        super(Movie, self).__init__(parent)
        self.parent = parent
        self.ui = Ui_Movie()
        self.ui.setupUi(self)
        langs = sorted(LANGUAGE_CONV.keys())
        for lang in langs:
            self.ui.langCombo.addItem(lang)

        self.ui.castingButton.clicked.connect(self.casting)
        self.ui.torrentButton.clicked.connect(self.searchTorrent)
        self.ui.subtitleButton.clicked.connect(self.searchSubtitle)
        self.ui.personsInCommonButton.clicked.connect(self.personsInCommon)

        self.movie = movie
        self.backend = backend
        self.ui.titleLabel.setText(movie.original_title)
        self.ui.durationLabel.setText(unicode(movie.duration))
        self.gotThumbnail()
        self.putReleases()

        self.ui.idEdit.setText(u'%s@%s' % (movie.id, backend.name))
        if not empty(movie.other_titles):
            self.ui.otherTitlesPlain.setPlainText('\n'.join(movie.other_titles))
        else:
            self.ui.otherTitlesPlain.parent().hide()
        if not empty(movie.genres):
            genres = u''
            for g in movie.genres:
                genres += '%s, ' % g
            genres = genres[:-2]
            self.ui.genresLabel.setText(genres)
        else:
            self.ui.genresLabel.parent().hide()
        if not empty(movie.release_date):
            self.ui.releaseDateLabel.setText(movie.release_date.strftime('%Y-%m-%d'))
        else:
            self.ui.releaseDateLabel.parent().hide()
        if not empty(movie.duration):
            self.ui.durationLabel.setText('%s min' % movie.duration)
        else:
            self.ui.durationLabel.parent().hide()
        if not empty(movie.pitch):
            self.ui.pitchPlain.setPlainText('%s' % movie.pitch)
        else:
            self.ui.pitchPlain.parent().hide()
        if not empty(movie.country):
            self.ui.countryLabel.setText('%s' % movie.country)
        else:
            self.ui.countryLabel.parent().hide()
        if not empty(movie.note):
            self.ui.noteLabel.setText('%s' % movie.note)
        else:
            self.ui.noteLabel.parent().hide()
        for role in movie.roles.keys():
            self.ui.castingCombo.addItem('%s' % role)

        self.ui.verticalLayout.setAlignment(Qt.AlignTop)
        self.ui.verticalLayout_2.setAlignment(Qt.AlignTop)
Ejemplo n.º 3
0
    def __init__(self, config, weboob, app, parent=None):
        QtMainWindow.__init__(self, parent)
        self.ui = Ui_MainWindow()
        self.ui.setupUi(self)

        self.config = config
        self.weboob = weboob
        self.app = app

        # search history is a list of patterns which have been searched
        self.search_history = self.loadSearchHistory()
        self.updateCompletion()

        self.connect(self.ui.searchEdit, SIGNAL("returnPressed()"),
                     self.search)
        self.connect(self.ui.idEdit, SIGNAL("returnPressed()"), self.searchId)
        self.connect(self.ui.typeCombo, SIGNAL("currentIndexChanged(QString)"),
                     self.typeComboChanged)

        count = self.config.get('settings', 'maxresultsnumber')
        self.ui.countSpin.setValue(int(count))
        showT = self.config.get('settings', 'showthumbnails')
        self.ui.showTCheck.setChecked(showT == '1')

        self.connect(self.ui.stopButton, SIGNAL("clicked()"), self.stopProcess)
        self.ui.stopButton.hide()

        self.connect(self.ui.actionBackends, SIGNAL("triggered()"),
                     self.backendsConfig)
        q = QShortcut(QKeySequence(Qt.CTRL + Qt.Key_Q), self)
        self.connect(q, SIGNAL("activated()"), self.close)
        n = QShortcut(QKeySequence(Qt.CTRL + Qt.Key_PageDown), self)
        self.connect(n, SIGNAL("activated()"), self.nextTab)
        p = QShortcut(QKeySequence(Qt.CTRL + Qt.Key_PageUp), self)
        self.connect(p, SIGNAL("activated()"), self.prevTab)
        w = QShortcut(QKeySequence(Qt.CTRL + Qt.Key_W), self)
        self.connect(w, SIGNAL("activated()"), self.closeCurrentTab)

        l = QShortcut(QKeySequence(Qt.CTRL + Qt.Key_L), self)
        self.connect(l, SIGNAL("activated()"), self.ui.searchEdit.setFocus)
        self.connect(l, SIGNAL("activated()"), self.ui.searchEdit.selectAll)

        self.connect(self.ui.resultsTab, SIGNAL("tabCloseRequested(int)"),
                     self.closeTab)

        self.loadBackendsList()

        if self.ui.backendEdit.count() == 0:
            self.backendsConfig()

        langs = sorted(LANGUAGE_CONV.keys())
        for lang in langs:
            self.ui.langCombo.addItem(lang)
        self.ui.langCombo.hide()
        self.ui.langLabel.hide()
Ejemplo n.º 4
0
    def __init__(self, config, weboob, app, parent=None):
        super(MainWindow, self).__init__(parent)
        self.ui = Ui_MainWindow()
        self.ui.setupUi(self)

        self.config = config
        self.weboob = weboob
        self.app = app

        # search history is a list of patterns which have been searched
        history_path = os.path.join(self.weboob.workdir, 'qcineoob_history')
        qc = HistoryCompleter(history_path, self)
        qc.load()
        qc.setCaseSensitivity(Qt.CaseInsensitive)
        self.ui.searchEdit.setCompleter(qc)

        self.ui.searchEdit.returnPressed.connect(self.search)
        self.ui.idEdit.returnPressed.connect(self.searchId)
        self.ui.typeCombo.currentIndexChanged[unicode].connect(
            self.typeComboChanged)

        count = self.config.get('settings', 'maxresultsnumber')
        self.ui.countSpin.setValue(int(count))
        showT = self.config.get('settings', 'showthumbnails')
        self.ui.showTCheck.setChecked(showT == '1')

        self.ui.stopButton.clicked.connect(self.stopProcess)
        self.ui.stopButton.hide()

        self.ui.actionBackends.triggered.connect(self.backendsConfig)
        q = QShortcut(QKeySequence(Qt.CTRL + Qt.Key_Q), self)
        q.activated.connect(self.close)
        n = QShortcut(QKeySequence(Qt.CTRL + Qt.Key_PageDown), self)
        n.activated.connect(self.nextTab)
        p = QShortcut(QKeySequence(Qt.CTRL + Qt.Key_PageUp), self)
        p.activated.connect(self.prevTab)
        w = QShortcut(QKeySequence(Qt.CTRL + Qt.Key_W), self)
        w.activated.connect(self.closeCurrentTab)

        l = QShortcut(QKeySequence(Qt.CTRL + Qt.Key_L), self)
        l.activated.connect(self.ui.searchEdit.setFocus)
        l.activated.connect(self.ui.searchEdit.selectAll)

        self.ui.resultsTab.tabCloseRequested.connect(self.closeTab)

        self.loadBackendsList()

        if self.ui.backendEdit.count() == 0:
            self.backendsConfig()

        langs = sorted(LANGUAGE_CONV.keys())
        for lang in langs:
            self.ui.langCombo.addItem(lang)
        self.ui.langCombo.hide()
        self.ui.langLabel.hide()
Ejemplo n.º 5
0
    def __init__(self, config, weboob, app, parent=None):
        QtMainWindow.__init__(self, parent)
        self.ui = Ui_MainWindow()
        self.ui.setupUi(self)

        self.config = config
        self.weboob = weboob
        self.app = app

        # search history is a list of patterns which have been searched
        self.search_history = self.loadSearchHistory()
        self.updateCompletion()

        self.connect(self.ui.searchEdit, SIGNAL("returnPressed()"),
                     self.search)
        self.connect(self.ui.idEdit, SIGNAL("returnPressed()"), self.searchId)
        self.connect(self.ui.typeCombo, SIGNAL("currentIndexChanged(QString)"),
                     self.typeComboChanged)

        count = self.config.get('settings', 'maxresultsnumber')
        self.ui.countSpin.setValue(int(count))
        showT = self.config.get('settings', 'showthumbnails')
        self.ui.showTCheck.setChecked(showT == '1')

        self.connect(self.ui.stopButton, SIGNAL("clicked()"), self.stopProcess)
        self.ui.stopButton.hide()

        self.connect(self.ui.actionBackends, SIGNAL("triggered()"),
                     self.backendsConfig)
        q = QShortcut(QKeySequence(Qt.CTRL + Qt.Key_Q), self)
        self.connect(q, SIGNAL("activated()"), self.close)
        n = QShortcut(QKeySequence(Qt.CTRL + Qt.Key_PageDown), self)
        self.connect(n, SIGNAL("activated()"), self.nextTab)
        p = QShortcut(QKeySequence(Qt.CTRL + Qt.Key_PageUp), self)
        self.connect(p, SIGNAL("activated()"), self.prevTab)
        w = QShortcut(QKeySequence(Qt.CTRL + Qt.Key_W), self)
        self.connect(w, SIGNAL("activated()"), self.closeCurrentTab)

        l = QShortcut(QKeySequence(Qt.CTRL + Qt.Key_L), self)
        self.connect(l, SIGNAL("activated()"), self.ui.searchEdit.setFocus)
        self.connect(l, SIGNAL("activated()"), self.ui.searchEdit.selectAll)

        self.connect(self.ui.resultsTab, SIGNAL("tabCloseRequested(int)"),
                     self.closeTab)

        self.loadBackendsList()

        if self.ui.backendEdit.count() == 0:
            self.backendsConfig()

        langs = sorted(LANGUAGE_CONV.keys())
        for lang in langs:
            self.ui.langCombo.addItem(lang)
        self.ui.langCombo.hide()
        self.ui.langLabel.hide()
Ejemplo n.º 6
0
    def __init__(self, config, weboob, app, parent=None):
        super(MainWindow, self).__init__(parent)
        self.ui = Ui_MainWindow()
        self.ui.setupUi(self)

        self.config = config
        self.weboob = weboob
        self.app = app

        # search history is a list of patterns which have been searched
        history_path = os.path.join(self.weboob.workdir, 'qcineoob_history')
        qc = HistoryCompleter(history_path, self)
        qc.load()
        qc.setCaseSensitivity(Qt.CaseInsensitive)
        self.ui.searchEdit.setCompleter(qc)

        self.ui.searchEdit.returnPressed.connect(self.search)
        self.ui.idEdit.returnPressed.connect(self.searchId)
        self.ui.typeCombo.currentIndexChanged[unicode].connect(self.typeComboChanged)

        count = self.config.get('settings', 'maxresultsnumber')
        self.ui.countSpin.setValue(int(count))
        showT = self.config.get('settings', 'showthumbnails')
        self.ui.showTCheck.setChecked(showT == '1')

        self.ui.stopButton.clicked.connect(self.stopProcess)
        self.ui.stopButton.hide()

        self.ui.actionBackends.triggered.connect(self.backendsConfig)
        q = QShortcut(QKeySequence(Qt.CTRL + Qt.Key_Q), self)
        q.activated.connect(self.close)
        n = QShortcut(QKeySequence(Qt.CTRL + Qt.Key_PageDown), self)
        n.activated.connect(self.nextTab)
        p = QShortcut(QKeySequence(Qt.CTRL + Qt.Key_PageUp), self)
        p.activated.connect(self.prevTab)
        w = QShortcut(QKeySequence(Qt.CTRL + Qt.Key_W), self)
        w.activated.connect(self.closeCurrentTab)

        l = QShortcut(QKeySequence(Qt.CTRL + Qt.Key_L), self)
        l.activated.connect(self.ui.searchEdit.setFocus)
        l.activated.connect(self.ui.searchEdit.selectAll)

        self.ui.resultsTab.tabCloseRequested.connect(self.closeTab)

        self.loadBackendsList()

        if self.ui.backendEdit.count() == 0:
            self.backendsConfig()

        langs = sorted(LANGUAGE_CONV.keys())
        for lang in langs:
            self.ui.langCombo.addItem(lang)
        self.ui.langCombo.hide()
        self.ui.langLabel.hide()
Ejemplo n.º 7
0
    def get_subtitle(self):
        desc = NotAvailable
        a = self.parser.select(self.document.getroot(), 'a#bt-dwl-bt', 1)
        id = a.attrib.get('data-product-id', '')
        m = re.match('Download \((\w+)\)', self.parser.tocleanstring(a))
        if m:
            ext = m.group(1)
        else:
            ext = u'zip'
        url = unicode('http://www.opensubtitles.org/en/subtitleserve/sub/%s' %
                      id)
        link = self.parser.select(self.document.getroot(),
                                  'link[rel=bookmark]', 1)
        title = unicode(link.attrib.get('title', ''))
        nb_cd = int(title.lower().split('cd')[0].split()[-1])
        lang = unicode(title.split('(')[1].split(')')[0])
        file_names = self.parser.select(self.document.getroot(),
                                        "img[title~=filename]")
        if len(file_names) > 0:
            file_name = file_names[0].getparent().text_content()
            file_name = ' '.join(file_name.split())
            desc = u'files :'
            for f in file_names:
                desc_line = f.getparent().text_content()
                desc += '\n' + ' '.join(desc_line.split())
        name = unicode('%s (%s)' % (title, file_name))

        subtitle = Subtitle(id, name)
        subtitle.url = url
        subtitle.ext = ext
        for lshort, llong in LANGUAGE_CONV.items():
            if lang == llong:
                lang = unicode(lshort)
                break
        subtitle.language = lang
        subtitle.nb_cd = nb_cd
        subtitle.description = desc
        return subtitle
Ejemplo n.º 8
0
    def get_subtitle_from_line(self, line):
        cells = self.parser.select(line, 'td')
        if len(cells) > 0:
            links = self.parser.select(line, 'a')
            a = links[0]
            name = u" ".join(a.text.strip().split())
            first_cell = cells[0]
            spanlist = self.parser.select(first_cell, 'span')
            if len(spanlist) > 0:
                long_name = spanlist[0].attrib.get('title', '')
            else:
                texts = first_cell.itertext()
                long_name = texts.next()
                long_name = texts.next()
                if "Download at 25" in long_name:
                    long_name = "---"
            name = "%s (%s)" % (name, long_name)
            second_cell = cells[1]
            link = self.parser.select(second_cell, 'a', 1)
            lang = link.attrib.get('href', '').split('/')[-1].split('-')[-1]
            for lshort, llong in LANGUAGE_CONV.items():
                if lang == llong:
                    lang = unicode(lshort)
                    break
            nb_cd = int(cells[2].text.strip().lower().replace('cd', ''))
            cell_dl = cells[4]
            href = self.parser.select(cell_dl, 'a', 1).attrib.get('href', '')
            url = unicode('http://www.opensubtitles.org%s' % href)
            id = href.split('/')[-1]

            subtitle = Subtitle(id, name)
            subtitle.url = url
            subtitle.language = lang
            subtitle.nb_cd = nb_cd
            subtitle.description = NotLoaded
            return subtitle
Ejemplo n.º 9
0
    def get_subtitle_from_line(self, line):
        cells = self.parser.select(line, 'td')
        if len(cells) > 0:
            links = self.parser.select(line, 'a')
            a = links[0]
            name = u" ".join(a.text.strip().split())
            first_cell = cells[0]
            spanlist = self.parser.select(first_cell, 'span')
            if len(spanlist) > 0:
                long_name = spanlist[0].attrib.get('title', '')
            else:
                texts = first_cell.itertext()
                long_name = texts.next()
                long_name = texts.next()
                if "Download at 25" in long_name:
                    long_name = "---"
            name = "%s (%s)" % (name, long_name)
            second_cell = cells[1]
            link = self.parser.select(second_cell, 'a', 1)
            lang = link.attrib.get('href', '').split('/')[-1].split('-')[-1]
            for lshort, llong in LANGUAGE_CONV.items():
                if lang == llong:
                    lang = unicode(lshort)
                    break
            nb_cd = int(cells[2].text.strip().lower().replace('cd', ''))
            cell_dl = cells[4]
            href = self.parser.select(cell_dl, 'a', 1).attrib.get('href', '')
            url = unicode('http://www.opensubtitles.org%s' % href)
            id = href.split('/')[-1]

            subtitle = Subtitle(id, name)
            subtitle.url = url
            subtitle.language = lang
            subtitle.nb_cd = nb_cd
            subtitle.description = NotLoaded
            return subtitle
Ejemplo n.º 10
0
 def iter_subtitles(self, language, pattern):
     if language not in LANGUAGE_CONV.keys():
         raise LanguageNotSupported()
     return self.browser.iter_subtitles(language, quote_plus(pattern.encode('utf-8')))
Ejemplo n.º 11
0
    def __init__(self, movie, backend, parent=None):
        super(Movie, self).__init__(parent)
        self.parent = parent
        self.ui = Ui_Movie()
        self.ui.setupUi(self)
        langs = sorted(LANGUAGE_CONV.keys())
        for lang in langs:
            self.ui.langCombo.addItem(lang)

        self.ui.castingButton.clicked.connect(self.casting)
        self.ui.torrentButton.clicked.connect(self.searchTorrent)
        self.ui.subtitleButton.clicked.connect(self.searchSubtitle)
        self.ui.personsInCommonButton.clicked.connect(self.personsInCommon)

        self.movie = movie
        self.backend = backend
        self.ui.titleLabel.setText(movie.original_title)
        self.ui.durationLabel.setText(unicode(movie.duration))
        self.gotThumbnail()
        self.putReleases()

        self.ui.idEdit.setText(u'%s@%s' % (movie.id, backend.name))
        if not empty(movie.other_titles):
            self.ui.otherTitlesPlain.setPlainText('\n'.join(
                movie.other_titles))
        else:
            self.ui.otherTitlesPlain.parent().hide()
        if not empty(movie.genres):
            genres = u''
            for g in movie.genres:
                genres += '%s, ' % g
            genres = genres[:-2]
            self.ui.genresLabel.setText(genres)
        else:
            self.ui.genresLabel.parent().hide()
        if not empty(movie.release_date):
            self.ui.releaseDateLabel.setText(
                movie.release_date.strftime('%Y-%m-%d'))
        else:
            self.ui.releaseDateLabel.parent().hide()
        if not empty(movie.duration):
            self.ui.durationLabel.setText('%s min' % movie.duration)
        else:
            self.ui.durationLabel.parent().hide()
        if not empty(movie.pitch):
            self.ui.pitchPlain.setPlainText('%s' % movie.pitch)
        else:
            self.ui.pitchPlain.parent().hide()
        if not empty(movie.country):
            self.ui.countryLabel.setText('%s' % movie.country)
        else:
            self.ui.countryLabel.parent().hide()
        if not empty(movie.note):
            self.ui.noteLabel.setText('%s' % movie.note)
        else:
            self.ui.noteLabel.parent().hide()
        for role in movie.roles.keys():
            self.ui.castingCombo.addItem('%s' % role)

        self.ui.verticalLayout.setAlignment(Qt.AlignTop)
        self.ui.verticalLayout_2.setAlignment(Qt.AlignTop)
Ejemplo n.º 12
0
 def iter_subtitles(self, language, pattern):
     if language not in LANGUAGE_CONV.keys():
         raise LanguageNotSupported()
     return self.browser.iter_subtitles(language,
                                        quote_plus(pattern.encode('utf-8')))