Exemple #1
0
    def file_hosts(self):
        data = url_open(urls.episode % (urllib.quote(self.show.name), self.season.id, self.number))
        watch_url = self._watch_url.findall(data)[0]

        self.__hosts = {}

        data = url_open(watch_url)
        hostnames = self._host_names_re.findall(data)

        hostmap = {'megaupload': 'http://www.megaupload.com/?d=',
                   'bitshare': 'http://bitshare.com/?f=',
                   'filefactory': 'http://www.filefactory.com/file/'
                   }

        for name, id in self._hosts_re.findall(data):
            self.__hosts['megaupload'] = hostmap.get('megaupload')+id
            break
            if not hostnames:
                break
            hostname = hostnames.pop()
            id = hostmap.get(hostname, '') + id
            self.__hosts[hostname] = id

        print self.__hosts
        return self.__hosts
Exemple #2
0
    def info(self):
        """ Returns a dict with info about this movie. """

        if self.__info:
            return self.__info

        page_data = url_open(urls.movie_info % (self.id, self.normalized_name))

        name = self._name_re.findall(page_data)[0].strip()
        image = self._image_re.findall(page_data)[0]
        description = self._description_re.findall(page_data)[0].strip()
        cast = self._cast_re.findall(page_data)
        genere = self._genere_re.findall(page_data)[0].strip()
        language = self._language_re.findall(page_data)[0].strip()

        self.__info = {
            "name": name,
            "image": image,
            "description": description,
            "cast": cast,
            "genere": genere,
            "language": language,
        }

        return self.__info
Exemple #3
0
    def search(self, show):
        """ Returs a list with the seasons from show. """

        data = url_open(urls.seasons % (show.id, show.urlname))
        jsondata = json.loads(self._json_re.search(data).group(1))

        for data in jsondata:
            yield Season(data, jsondata[data], show)
Exemple #4
0
    def search(self, show):
        data = url_open(urls.seasons % urllib.quote(show.name))
        data = data.split('<ol id="season-list">')[1]

        for season in self._search_re.finditer(data):
            s =  Season(**season.groupdict())
            s.show = show
            yield s
Exemple #5
0
    def search(self, name=''):
        """ Returns a list with all the currently avaliable Shows. """

        name = name.lower()

        for show in self._search_re.finditer(url_open(urls.shows)):
            show_dict = show.groupdict()
            if not name or name in show_dict['name'].lower():
                yield Show(**show_dict)
Exemple #6
0
    def data(self):
        fd = url_open(self.url, handle=True)

        data = fd.read(1024*5)
        while True:
            yield data
            data = fd.read(1024)
            if not data:
                break
Exemple #7
0
    def search(self, season):
        """
        Returns a list with Episodes of
        of `season`.
        """

        data = url_open(urls.episodes, {"t": season.id})
        for episode in self._search_re.finditer(data):
            yield Episode(**episode.groupdict())
Exemple #8
0
def search(query):
    query = urllib.quote(query)
    data = url_open(SEARCH_URL % query)
    songs = []
    for song in RE_SONG.finditer(data):
        song_obj = Song(song.groupdict())
        songs.append(song_obj)
        #yield song_obj

    return songs
Exemple #9
0
    def get_latest(self):
        """ Returns a list with all the latest
        movies. """

        data = url_open(urls.latest_movies)
        for movie in self._latest_re.finditer(data):
            movie_dict = movie.groupdict()
            movie_dict["description"] = movie_dict["description"].strip()

            yield Movie(**movie_dict)
Exemple #10
0
    def search(self, name=""):
        """ Returns a list with all the currently avaliable Shows. """

        name = name.lower()

        data = url_open(urls.shows)
        jsondata = json.loads(self._json_re.search(data).group(1))

        for show in jsondata:
            yield Show(show["url"], show["tit"])
Exemple #11
0
    def file_hosts(self):
        """ Returns a a dict with name and instance. """

        if self.__hosts:
            return self.__hosts

        self.__hosts = {}

        data = url_open(urls.player_movie % self.id)
        for id, name in self._hosts_re.findall(data):
            data = [("key", id), ("host", name), ("vars", "&id=%s&subs=,ES,EN&tipo=&amp;sub_pre=ES" % self.id)]
            url = url_open(urls.source_get, data=data)

            # before http are ugly chars
            url = url[url.find("http:") :].split("&id")[0]

            self.__hosts[name] = url

        return self.__hosts
Exemple #12
0
    def file_hosts(self):
        """ Returns a a dict with name and instance. """

        if self.__hosts:
            return self.__hosts

        self.__hosts = {}

        data = url_open(urls.player_movie % self.id)
        for id, name in self._hosts_re.findall(data):
            data = [('key', id), ('host', name),
                    ('vars', '&id=%s&subs=,ES,EN&tipo=&amp;sub_pre=ES' % self.id)]
            url = url_open(urls.source_get, data=data)

            # before http are ugly chars
            url = url[url.find('http:'):].split('&id')[0]

            self.__hosts[name] = url

        return self.__hosts
Exemple #13
0
    def search(self, query=""):
        """ Returns a list with all the matched
        movies searched using the query. """

        query = query.lower().replace(" ", "+")

        for movie in self._search_re.finditer(url_open(urls.search % query)):
            movie_dict = movie.groupdict()
            movie_dict["description"] = movie_dict["description"].strip()

            yield Movie(**movie_dict)
Exemple #14
0
    def get_recomended(self):
        """ Returns a list with all the recomended
        movies. """

        data = url_open(urls.recomended_movies)
        data = data.split("<h3>Películas destacadas</h3>")[1].split("<h3>Episodios destacados</h3>")[0]
        for movie in self._recomended_re.finditer(data):
            movie_dict = movie.groupdict()
            movie_dict["name"] = movie_dict["name"].strip()

            yield Movie(**movie_dict)
Exemple #15
0
    def get_subtitle(self, lang="ES", filename=None):
        """ Downloads the subtitle of the movie. """

        if filename:
            filename += ".srt"

        try:
            result = url_open(urls.sub_movie % (self.id, lang), filename=filename)
        except:
            raise Exception("Subtitle not found")

        return result
Exemple #16
0
    def search(self, name=''):
        """
        Returns a list with all the
        currently avaliable Shows
        """

        data = url_open(urls.shows)

        for show in self._search_re.finditer(data):
            show_dict = show.groupdict()
            show_dict["id"] = int(md5(show_dict["name"]).hexdigest(), 16)

            yield Show(**show_dict)
Exemple #17
0
def setup(username=None, password=None, cache_dir="/tmp/", cache_lifetime=60 * 60 * 6):
    """ Does the inicialization and login of the website. """

    # Singleton
    cached = Cached.get()
    cached.set_cache_dir(cache_dir)
    cached.set_lifetime(cache_lifetime)

    if username:
        data = {"usuario": username, "password": password, "ingresar": True, "recordarme": "si"}
        ret = url_open(urls.login, data=data)
        if username not in ret:
            raise Exception("Login fail, check username and password")
Exemple #18
0
    def file_hosts(self):
        """ Returns a a dict with name and instance. """

        if self.__hosts:
            return self.__hosts
        self.__hosts = {}

        data = url_open(urls.player_season % self.id)
        sources = json.loads(self._sources_re.search(data).group(1))

        for host in sources["360"]["2"]:

            data = [("id", self.id), ("tipo", "serie"), ("def", "360"), ("audio", "2"), ("host", host)]

            hostdata = url_open(urls.source_get, data=data)

            # before http are ugly chars
            url = hostdata[hostdata.find("http:") :].split("&id")[0]

            self.__hosts[host] = url

        return self.__hosts
Exemple #19
0
def get_token():
    # TODO: should implement cookies to disk too
    #try:
    #    with open('.token') as fd:
    #        token = fd.read()
    #except Exception, error:
    #    data = url_open(HOST)
    #    token = data.split('var ptk = "')[1].split('";')[0]
    #    with open('.token', 'w') as fd:
    #        fd.write(token)
    data = url_open(HOST)
    token = data.split('var ptk = "')[1].split('";')[0]
    return token
Exemple #20
0
    def search(self, season):
        """
        Returns a list with Episodes of
        of `season`.
        """

        data = url_open(urls.episodes % (urllib.quote(season.show.name), season.id))
        data = data.split('<ol id="episode-list">')[1]

        for episode in self._search_re.finditer(data):
            e =  Episode(**episode.groupdict())
            e.show = season.show
            e.season = season
            yield e
Exemple #21
0
    def get_subtitle(self, lang="ES", filename=None):
        if filename:
            filename += ".srt"

        id = self.id.split("/play/")[1].split("/", 1)[0]
        print
        print urls.sub_show % id
        print "asdas adsas dads asd asdada<<<<<<<<<<<<<<<<<<<<<<<<<"
        try:
            result = url_open(urls.sub_show % id, filename=filename)
        except:
            raise Exception("Subtitle not found")

        return result
Exemple #22
0
    def search(self, name=""):
        """
        Returns a list with all the
        currently avaliable Shows
        """

        data = url_open(urls.shows)
        data = data.split('<select name="s" id="serie" size="15">')[1]
        data = data.split("</select>", 1)[0]

        for show in self._search_re.finditer(data):
            show_dict = show.groupdict()
            if not name or name in show_dict["name"].lower():
                yield Show(**show_dict)
Exemple #23
0
def setup(username=None, password=None,
        cache_dir='/tmp/', cache_lifetime=60*60*6):
    """ Does the inicialization and login of the website. """

    # Singleton
    cached = Cached.get()
    cached.set_cache_dir(cache_dir)
    cached.set_lifetime(cache_lifetime)

    if username:
        data = {'usuario': username, 'password': password,
                'ingresar': True, 'recordarme': 'si'}
        ret = url_open(urls.login, data=data)
        if username not in ret:
            raise Exception('Login fail, check username and password')
Exemple #24
0
    def get_subtitle(self, filename=None):
        """ Downloads the subtitle of the episode. """

	lang = self.get_available_subtitles(self.info['subtitle'])

	for i in range(len(lang)):
            if filename:
		filename2 = filename
		filename2 += '-' +lang[i] +'.srt'
            try:
                result = url_open(urls.sub_show % (self.id, lang[i]), filename=filename2)
            except:
                raise Exception("Subtitle not found")

        return result
Exemple #25
0
    def get_subtitle(self, lang="ES", quality=None, filename=None):
        """ Downloads the subtitle of the episode. """

        if filename:
            filename += ".srt"

        if quality:
            url = urls.sub_show_quality % (self.id, lang, quality)
        else:
            url = urls.sub_show % (self.id, lang)

        try:
            result = url_open(url, filename=filename)
        except:
            raise Exception("Subtitle not found")

        return result
Exemple #26
0
    def info(self):
        """ Returns a dict with info about this movie. """

        if self.__info:
            return self.__info

        page_data = url_open(urls.movie_info % (self.id, self.normalized_name))

        name = self._name_re.findall(page_data)[0].strip()
        image = self._image_re.findall(page_data)[0]
        description = self._description_re.findall(page_data)[0].strip()
        cast = self._cast_re.findall(page_data)
        genere = self._genere_re.findall(page_data)[0].strip()
        language = self._language_re.findall(page_data)[0].strip()
	subtitle = self._subtitle_re.findall(page_data)[0].strip()

        self.__info = {'name': name, 'image': image, 'description': description,
                'cast': cast, 'genere': genere, 'language': language, 'subtitle': subtitle}

        return self.__info
Exemple #27
0
    def info(self):
        """ set info data in __info dict and return it. """

        if self.__info:
            return self.__info

        page_data = url_open(urls.show_info % self.id)

        name = self._name_re.findall(page_data)[0].strip()
        show = self._show_re.findall(page_data)[0].strip()
        image = urls.host + self._image_re.findall(page_data)[0]
        description = self._description_re.findall(page_data)[0].strip()
        cast = self._cast_re.findall(page_data)
        genere = self._genere_re.findall(page_data)[0].strip()
        language = self._language_re.findall(page_data)[0].strip()
        season = self._season_number_re.findall(page_data)[0].strip()
	subtitle = self._subtitle_re.findall(page_data)[0].strip()

        self.__info = {'name': name, 'show': show, 'image': image, 'description': description,
                'cast': cast, 'genere': genere, 'language': language, 'season': season, 'subtitle' : subtitle}
        return self.__info
Exemple #28
0
    def file_hosts(self):
        self.__hosts = {}

        data = url_open(self.id)
        hostnames = self._host_names_re.findall(data)

        hostmap = {
            "megaupload": "http://www.megaupload.com/?d=",
            "bitshare": "http://bitshare.com/?f=",
            "filefactory": "http://www.filefactory.com/file/",
        }

        for name, id in self._hosts_re.findall(data):
            self.__hosts["megaupload"] = hostmap.get("megaupload") + id
            break
            if not hostnames:
                break
            hostname = hostnames.pop()
            id = hostmap.get(hostname, "") + id
            self.__hosts[hostname] = id

        print self.__hosts
        return self.__hosts
Exemple #29
0
 def url(self):
     params = {'file': self.id,
               'token': get_token()}
     return url_open(SONG_URL, data=params)
Exemple #30
0
    def search(self, show):
        """ Returs a list with the seasons from show. """

        data = url_open(urls.seasons % show.id)
        for season in self._search_re.finditer(data):
            yield Season(**season.groupdict())