Ejemplo n.º 1
0
def play_media(link, image):

    link = unquote_plus(link)
    li = control.item(path=link, iconImage=image, thumbnailImage=image)
    li.setArt({'thumb': image})

    control.player().play(link, li)
Ejemplo n.º 2
0
    def get(self, query):

        query = py3_dec(query)

        try:

            query = ' '.join(
                unquote_plus(re.sub(r'%\w\w', ' ', quote_plus(query))).split())

            url = ''.join([
                self.base_link,
                '/search.php?name={0}'.format(quote_plus(query))
            ])

            result = client.request(url, timeout=control.setting('timeout'))

            try:
                result = result.decode('utf-8', errors='replace')
            except AttributeError:
                pass

            items = client.parseDOM(result, 'tr', attrs={'on.+?': '.+?'})

            if not items:
                log_debug('Subtitles.gr did not provide any results')
                return

        except Exception as e:

            _, __, tb = sys.exc_info()

            print(traceback.print_tb(tb))

            log_debug('Subtitles.gr failed at get function, reason: ' + str(e))

            return

        for item in items:

            try:

                if u'flags/el.gif' not in item:

                    continue

                try:
                    uploader = client.parseDOM(item,
                                               'a',
                                               attrs={'class':
                                                      'link_from'})[0].strip()
                    uploader = client.replaceHTMLCodes(uploader)
                except IndexError:
                    uploader = ''

                try:
                    uploader = uploader.decode('utf-8')
                except AttributeError:
                    pass

                if not uploader:
                    uploader = 'other'

                try:
                    downloads = client.parseDOM(
                        item, 'td', attrs={'class':
                                           'latest_downloads'})[0].strip()
                except:
                    downloads = '0'

                downloads = re.sub('[^0-9]', '', downloads)

                name = client.parseDOM(item,
                                       'a',
                                       attrs={'onclick': 'runme.+?'})[0]
                name = ' '.join(re.sub('<.+?>', '', name).split())
                name = client.replaceHTMLCodes(name)
                label = u'[{0}] {1} [{2} DLs]'.format(uploader, name,
                                                      downloads)

                url = client.parseDOM(item,
                                      'a',
                                      ret='href',
                                      attrs={'onclick': 'runme.+?'})[0]
                url = url.split('"')[0].split('\'')[0].split(' ')[0]
                url = client.replaceHTMLCodes(url)
                url = url.encode('utf-8')

                rating = self._rating(downloads)

                self.list.append({
                    'name': label,
                    'url': url,
                    'source': 'subtitlesgr',
                    'rating': rating,
                    'title': name,
                    'downloads': downloads
                })

            except Exception as e:

                _, __, tb = sys.exc_info()

                print(traceback.print_tb(tb))

                log_debug(
                    'Subtitles.gr failed at self.list formation function, reason: '
                    + str(e))

                return

        return self.list
    def get(self, query):

        query = py3_dec(query)

        try:

            query = ' '.join(
                unquote_plus(re.sub(r'%\w\w', ' ', quote_plus(query))).split())

            query_link = '&'.join([
                'keywords={keywords}', 'movie_type={movie_type}',
                'language=!el', 'seasons={seasons}', 'episodes={episodes}',
                'year={year}', 'type=', 'undefined=auto', 'undefined=en'
            ])

            match = re.findall(
                r'(.+?)(?: -)?[ \.](?:\(?(\d{4})\)?|S?(\d{1,2})X?(?: |\.)?E?P?(\d{1,2})(?: \. (.+))?)',
                query,
                flags=re.I)

            if match:

                query, year, season, episode, episode_title = match[0]

                url = '?'.join([
                    self.search_link,
                    query_link.format(
                        keywords=quote_plus(query),
                        movie_type='movie'
                        if year and not (season or episode) else 'tv-series',
                        seasons=season,
                        episodes=episode,
                        year=year)
                ])

            else:

                url = '?'.join([
                    self.search_link,
                    query_link.format(keywords=quote_plus(query),
                                      movie_type='',
                                      seasons='',
                                      episodes='',
                                      year='')
                ])

            result = client.request(url,
                                    headers={
                                        'Accept':
                                        'text/html',
                                        'Accept-Language':
                                        'en-US,en;q=0.9,el;q=0.8'
                                    },
                                    timeout=control.setting('timeout'),
                                    verify=False)

            try:
                result = result.decode('utf-8', errors='replace')
            except AttributeError:
                pass

            items = client.parseDOM(result,
                                    'tr',
                                    attrs={'class': 'subtitle-entry'})

            if not items:
                log_debug('Podnapisi.net did not provide any results')
                return

        except Exception as e:

            _, __, tb = sys.exc_info()

            print(traceback.print_tb(tb))

            log_debug('Podnapisi.net failed at get function, reason: ' +
                      str(e))

            return

        for item in items:

            try:

                if '<span>el</span>' not in item:
                    continue

                table = client.parseDOM(item, 'td')

                try:
                    downloads = [i.strip() for i in table]
                    downloads = [i for i in downloads if i.isdigit()][1]
                except IndexError:
                    downloads = '0'

                downloads = re.sub('[^0-9]', '', downloads)

                label = client.parseDOM(item,
                                        'a',
                                        attrs={'alt': 'Subtitles\' page'})[0]
                label = client.replaceHTMLCodes(label)
                name = u'{0} [{1} DLs]'.format(label, downloads)

                url = [i for i in table if 'Download subtitles.' in i][0]
                url = client.parseDOM(url, 'a', ret='href')[0]
                url = ''.join([self.base_link, url])

                rating = [i for i in table if 'progress rating' in i][0]
                rating = client.parseDOM(rating,
                                         'div',
                                         attrs={'class': 'progress rating'},
                                         ret='data-title')[0]
                rating = int(rating.partition('.')[0]) / 20

                self.list.append({
                    'name': name,
                    'url': url,
                    'source': 'podnapisi',
                    'rating': rating,
                    'title': label,
                    'downloads': downloads
                })

            except Exception as e:

                _, __, tb = sys.exc_info()

                print(traceback.print_tb(tb))

                log_debug(
                    'Podnapisi.net failed at self.list formation function, reason: '
                    + str(e))

                return

        return self.list
Ejemplo n.º 4
0
    def wrapper(self, str_input, mode):

        query = self.google.format(str_input.encode('utf-8'), gm.base_link)

        html = client.request(query.replace(' ', '+'), headers=self.UA)

        items = client.parseDOM(html, 'h3', attrs={'class': 'r'})

        for item in items:

            if mode == 0:
                title = client.parseDOM(item, 'a')[0]
            else:
                title = client.parseDOM(item,
                                        'a')[0].rstrip(u' ‒ Greek-Movies')
            title = client.replaceHTMLCodes(title)
            title = re.sub('</?b>', '', title)

            if '- Greek' in title:
                idx = title.rfind('- Greek')
                title = title[:idx].strip()
            elif u'‒ Greek' in title:
                idx = title.rfind(u'‒ Greek')
                title = title[:idx].strip()

            url = client.parseDOM(item, 'a', ret='href')[0]
            url = unquote_plus(url.partition('=')[2].partition('&amp;')[0])

            if mode == 0:
                if all(
                    ['movies.php?m=' not in url, 'theater.php?m=' not in url]):
                    continue
            else:
                if all(['shows.php?s=' not in url, 'series.php?s='
                        not in url]):
                    continue

            item_html = client.request(url)

            try:
                thumb = client.parseDOM(item_html,
                                        'img',
                                        attrs={'class': 'thumbnail.*?'},
                                        ret='src')[0]
            except IndexError:
                thumb = client.parseDOM(item_html, 'IMG', ret='SRC')[0]

            image = urljoin(gm.base_link, thumb)

            year = client.parseDOM(item_html,
                                   'h4',
                                   attrs={'style': 'text-indent:10px;'})[0]
            year = int(year.strip(u'Έτος:').strip()[:4])

            if 'text-align: justify' in html:
                plot = client.parseDOM(html,
                                       'p',
                                       attrs={'style':
                                              'text-align: justify'})[0]
            elif 'text-justify' in html:
                plot = client.parseDOM(html,
                                       'p',
                                       attrs={'class': 'text-justify'})[0]
            else:
                plot = control.lang(30085)

            if mode == 0:
                self.list.append({
                    'title': title.encode('utf-8'),
                    'url': url,
                    'image': image.encode('utf-8'),
                    'year': year,
                    'plot': plot
                })

                if control.setting('action_type') == '0' or control.setting(
                        'action_type') == '2':
                    for item in self.list:
                        item.update({'action': 'play', 'isFolder': 'False'})
                else:
                    for item in self.list:
                        item.update({'action': 'directory'})

            else:
                self.list.append({
                    'title': title,
                    'url': url,
                    'image': image.encode('utf-8'),
                    'year': year,
                    'plot': plot,
                    'action': 'episodes'
                })

        for item in self.list:
            bookmark = dict(
                (k, v) for k, v in iteritems(item) if not k == 'next')
            bookmark['bookmark'] = item['url']
            bookmark_cm = {
                'title': 30080,
                'query': {
                    'action': 'addBookmark',
                    'url': json.dumps(bookmark)
                }
            }
            item.update({'cm': [bookmark_cm]})

        if self.list is None:
            return

        self.list = sorted(self.list, key=lambda k: k['title'])

        return self.list
    def get(self, query):

        query = py3_dec(query)

        try:

            query = ' '.join(
                unquote_plus(re.sub(r'%\w\w', ' ', quote_plus(query))).split())

            match = re.findall(
                r'(.+?)(?: -)?[ \.](?:\(?(\d{4})\)?|S?(\d{1,2})X?(?: |\.)?E?P?(\d{1,2})(?: \. (.+))?)',
                query,
                flags=re.I)

            if match:

                query, year, season, episode, episode_title = match[0]

                search = quote_plus(' '.join(
                    [query, 's', season, 'e', episode, episode_title]))

                url = self.search_show.format(search)

            else:

                url = self.search_movie.format(quote_plus(query))

            self.data = [
                client.request(url, timeout=control.setting('timeout'))
            ]

            try:
                _next_button = client.parseDOM(
                    self.data[0],
                    'a',
                    attrs={'class': 'next page-numbers'},
                    ret='href')[0]
            except IndexError:
                _next_button = None

            while _next_button:

                self.data.append(
                    client.request(_next_button,
                                   timeout=control.setting('timeout')))

                try:
                    _next_button = client.parseDOM(
                        self.data[-1],
                        'a',
                        attrs={'class': 'next page-numbers'},
                        ret='href')[0]
                    control.sleep(200)
                except IndexError:
                    _next_button = None
                    break

            html = '\n'.join(self.data)

            items = client.parseDOM(html,
                                    'div',
                                    attrs={'class': 'article__summary'})

            if not items:
                log_debug('Vipsubs.gr did not provide any results')
                return

        except Exception as e:

            _, __, tb = sys.exc_info()

            print(traceback.print_tb(tb))

            log_debug('Vipsubs.gr failed at get function, reason: ' + str(e))

            return

        for item in items:

            try:

                label = itertags_wrapper(item, 'a', attrs={'rel':
                                                           "bookmark"})[0].text

                label = client.replaceHTMLCodes(label)

                url = itertags_wrapper(item, 'a', ret='href')[-1]
                if 'vipsubs.gr' in url:
                    continue
                rating = 10.0

                self.list.append({
                    'name': label,
                    'url': url,
                    'source': 'vipsubs',
                    'rating': rating,
                    'title': label,
                    'downloads': '1000'
                })

            except Exception as e:

                _, __, tb = sys.exc_info()

                print(traceback.print_tb(tb))

                log_debug(
                    'Vipsubs.gr failed at self.list formation function, reason: '
                    + str(e))

                return

        return self.list
Ejemplo n.º 6
0
    def get(self, query):

        try:

            try:
                match = re.findall(
                    r'(.+?) (?!\d{4})S?(\d{1,2}) ?X?E?(\d{1,2})$',
                    query,
                    flags=re.IGNORECASE)[0]
            except Exception:
                match = None

            if not match:

                match = re.findall(r'(.+?) *?\(?(\d{4})?\)?$', query)[0]

                if len(match[1]) == 4:

                    title, year = match[0], match[1]

                else:

                    title = match[0]

                query = ' '.join(
                    unquote_plus(re.sub('%\w\w', ' ',
                                        quote_plus(title))).split())

                url = 'https://subz.xyz/search?q={0}'.format(quote_plus(query))

                result = client.request(url)
                result = re.sub(r'[^\x00-\x7F]+', ' ', result)

                url = client.parseDOM(result,
                                      'section',
                                      attrs={'class': 'movies'})[0]
                url = re.findall('(/movies/\d+)', url)
                url = [x for y, x in enumerate(url) if x not in url[:y]]
                url = [urljoin('https://subz.xyz', i) for i in url]
                url = url[:20][::-1]

                for i in url:

                    c = cache.get(self.cache, 2200, i)

                    if c is not None:

                        if len(match[1]) == 4:
                            year_check = c[1] == year
                        else:
                            year_check = True

                        if cleantitle.get(
                                c[0]) == cleantitle.get(title) and year_check:

                            try:

                                item = self.r

                            except Exception:

                                item = client.request(i)

                            break

                        else:

                            self.data.append(self.r)

            else:

                title, season, episode = match

                season, episode = '{0}'.format(season), '{0}'.format(episode)

                query = ' '.join(
                    unquote_plus(re.sub('%\w\w', ' ',
                                        quote_plus(title))).split())

                url = 'https://subz.xyz/search?q={0}'.format(quote_plus(query))

                result = client.request(url)
                result = re.sub(r'[^\x00-\x7F]+', ' ', result)

                url = client.parseDOM(result,
                                      'section',
                                      attrs={'class': 'tvshows'})[0]
                url = re.findall('(/series/\d+)', url)
                url = [x for y, x in enumerate(url) if x not in url[:y]]
                url = [urljoin('https://subz.xyz', i) for i in url]
                url = url[:20][::-1]

                for i in url:

                    c = cache.get(self.cache, 2200, i)

                    if c is not None:

                        if cleantitle.get(c[0]) == cleantitle.get(title):

                            item = i

                            break

                item = '{0}/seasons/{1}/episodes/{2}'.format(
                    item, season, episode)
                item = client.request(item)

            if self.data:

                item = '\n\n'.join(self.data)

            item = re.sub(r'[^\x00-\x7F]+', ' ', item)
            items = client.parseDOM(item, 'tr', attrs={'data-id': '.+?'})

        except Exception as e:

            log.log('Subzxyz failed at get function, reason: ' + str(e))

            return

        for item in items:

            try:

                r = client.parseDOM(item, 'td', attrs={'class': '.+?'})[-1]

                url = client.parseDOM(r, 'a', ret='href')[0]
                url = client.replaceHTMLCodes(url)
                url = url.replace("'", "").encode('utf-8')

                name = url.split('/')[-1].strip()
                name = re.sub('\s\s+', ' ', name)
                name = name.replace('_', '').replace('%20', '.')
                name = client.replaceHTMLCodes(name)
                name = name.encode('utf-8')

                self.list.append({
                    'name': name,
                    'url': url,
                    'source': 'subzxyz',
                    'rating': 5
                })

            except Exception as e:

                log.log(
                    'Subzxyz failed at self.list formation function, reason: '
                    + str(e))

                return

        return self.list
Ejemplo n.º 7
0
    def get(self, query):

        try:

            filtered = ['freeprojectx', 'subs4series', u'Εργαστήρι Υποτίτλων']

            query = ' '.join(
                unquote_plus(re.sub('%\w\w', ' ', quote_plus(query))).split())

            if control.setting('subtitlesgr') == 'true':

                url = 'http://www.subtitles.gr/search.php?name={0}'.format(
                    quote_plus(query))

            else:

                url = 'http://www.findsubtitles.eu/search.php?text={0}&lang=Greek&button=Search'.format(
                    quote_plus(query))

            url = client.request(url, output='geturl')

            result = client.request(url.replace('www', 'gr'))

            try:
                result = result.decode('utf-8', errors='replace')
            except AttributeError:
                pass

            items = client.parseDOM(result, 'tr', attrs={'on.+?': '.+?'})

        except Exception as e:

            log.log('Subtitles.gr failed at get function, reason: ' + str(e))

            return

        for item in items:

            try:

                if u'flags/el.gif' not in item:

                    continue

                try:

                    uploader = client.parseDOM(item,
                                               'a',
                                               attrs={'class':
                                                      'link_from'})[0].strip()
                    try:
                        uploader = uploader.decode('utf-8')
                    except AttributeError:
                        pass
                    if uploader == '':
                        raise Exception
                    if uploader in filtered:
                        continue

                except Exception:

                    uploader = 'other'

                try:
                    downloads = client.parseDOM(
                        item, 'td', attrs={'class':
                                           'latest_downloads'})[0].strip()
                except:
                    downloads = '0'

                downloads = re.sub('[^0-9]', '', downloads)

                name = client.parseDOM(item,
                                       'a',
                                       attrs={'onclick': 'runme.+?'})[0]
                name = ' '.join(re.sub('<.+?>', '', name).split())
                name = u'[{0}] {1} [{2} DLs]'.format(uploader, name, downloads)
                name = client.replaceHTMLCodes(name)
                # name = name.encode('utf-8')

                url = client.parseDOM(item,
                                      'a',
                                      ret='href',
                                      attrs={'onclick': 'runme.+?'})[0]
                url = url.split('"')[0].split('\'')[0].split(' ')[0]
                url = client.replaceHTMLCodes(url)
                url = url.encode('utf-8')

                rating = self._rating(downloads)

                self.list.append({
                    'name': name,
                    'url': url,
                    'source': 'subtitlesgr',
                    'rating': rating
                })

                self.list.sort(key=lambda k: k['rating'], reverse=True)

            except Exception as e:

                log.log(
                    'Subtitles.gr failed at self.list formation function, reason: '
                    + str(e))

                return

        return self.list