Exemplo n.º 1
0
    def onPlayBackEnded(self):
        self.tearDown()

        logger.debug('onPlayBackEnded: is_exluded: %s', self.is_excluded)
        if self.is_excluded:
            return

        logger.debug('last_pos / total_time : %s / %s',
                     self._last_pos, self._total_time)

        actual_percent = (self._last_pos/self._total_time)*100
        logger.debug('last_pos / total_time : %s / %s = %s %%',
                     self._last_pos, self._total_time, actual_percent)

        logger.debug("min_percent: %s", self._min_percent)

        if actual_percent < self._min_percent:
            return

        # In case it was deleted or whatever happened during playback
        self._addShow()

        # Playback is finished, set the items to watched
        found = 32923
        if self.mye.set_episode_watched(self.showid, self.season, self.episode):
            found = 32924
        utils.notif("{0.title} ({0.season} - {0.episode}) {1}".format(self, _language(found)))
Exemplo n.º 2
0
    def onPlayBackEnded(self):
        self.tearDown()

        logger.debug('onPlayBackEnded: is_exluded: %s', self.is_excluded)
        if self.is_excluded:
            return

        logger.debug('last_pos / total_time : %s / %s', self._last_pos,
                     self._total_time)

        actual_percent = (self._last_pos / self._total_time) * 100
        logger.debug('last_pos / total_time : %s / %s = %s %%', self._last_pos,
                     self._total_time, actual_percent)

        logger.debug("min_percent: %s", self._min_percent)

        if actual_percent < self._min_percent:
            return

        # In case it was deleted or whatever happened during playback
        self._addShow()

        # Playback is finished, set the items to watched
        found = 32923
        if self.mye.set_episode_watched(self.showid, self.season,
                                        self.episode):
            found = 32924
        utils.notif("{0.title} ({0.season} - {0.episode}) {1}".format(
            self, _language(found)))
Exemplo n.º 3
0
 def parse(self, response):
     asins = response.xpath("//*[contains(@id, 'result')]/@data-asin").extract()
     for asin in asins:
         notif(asin)
         url_asin = "https://www.amazon.com/dp/" + asin;
         yield scrapy.Request(url=url_asin, callback=self.parse_product, headers={"user-agent": random.choice(self.headers)}, cookies=self.cookies)
     next_page = response.xpath('//*[@id="pagnNextLink"]/@href').extract_first()
     if (next_page is not None):
         header = random.choice(self.headers)
         yield response.follow(next_page, callback=self.parse, cookies=self.cookies, headers={"user-agent": header})
Exemplo n.º 4
0
    def onAVStarted(self):
        self.setUp()
        self._total_time = self.getTotalTime()
        self._tracker.start()

        filename_full_path = self.getPlayingFile().decode('utf-8')
        # We don't want to take care of any URL because we can't really gain
        # information from it.
        self.is_excluded = False
        if utils.is_excluded(filename_full_path):
            self.is_excluded = True
            self.tearDown()
            return

        # Try to find the title with the help of XBMC (Theses came from
        # XBMC.Subtitles add-ons)
        self.season = str(xbmc.getInfoLabel("VideoPlayer.Season"))
        logger.debug('Player - Season: %s', self.season)
        self.episode = str(xbmc.getInfoLabel("VideoPlayer.Episode"))
        logger.debug('Player - Episode: %s', self.episode)
        self.title = xbmc.getInfoLabel("VideoPlayer.TVshowtitle")
        logger.debug('Player - TVShow: %s', self.title)
        if self.title == "":
            filename = os.path.basename(filename_full_path)
            logger.debug('Player - Filename: %s', filename)
            self.title, self.season, self.episode = self.mye.get_info(filename)
            logger.debug('Player - TVShow: %s', self.title)

        logger.debug("Title: %s - Season: %s - Ep: %s", self.title,
                     self.season, self.episode)
        if not self.season and not self.episode:
            # It's not a show. If it should be recognised as one. Send a bug.
            self.tearDown()
            return

        self.showid = self.mye.find_show_id(self.title)
        if self.showid is None:
            utils.notif("%s %s" % (self.title, _language(32923)), time=3000)
            self.tearDown()
            return
        logger.debug('Player - Found : %s - %d (S%s E%s)', self.title,
                     self.showid, self.season, self.episode)

        utils.notif(self.title, time=2000)
        self._addShow()
Exemplo n.º 5
0
    def onAVStarted(self):
        self.setUp()
        self._total_time = self.getTotalTime()
        self._tracker.start()

        filename_full_path = self.getPlayingFile().decode('utf-8')
        # We don't want to take care of any URL because we can't really gain
        # information from it.
        self.is_excluded = False
        if utils.is_excluded(filename_full_path):
            self.is_excluded = True
            self.tearDown()
            return

        # Try to find the title with the help of XBMC (Theses came from
        # XBMC.Subtitles add-ons)
        self.season = str(xbmc.getInfoLabel("VideoPlayer.Season"))
        logger.debug('Player - Season: %s', self.season)
        self.episode = str(xbmc.getInfoLabel("VideoPlayer.Episode"))
        logger.debug('Player - Episode: %s', self.episode)
        self.title = xbmc.getInfoLabel("VideoPlayer.TVshowtitle")
        logger.debug('Player - TVShow: %s', self.title)
        if self.title == "":
            filename = os.path.basename(filename_full_path)
            logger.debug('Player - Filename: %s', filename)
            self.title, self.season, self.episode = self.mye.get_info(filename)
            logger.debug('Player - TVShow: %s', self.title)

        logger.debug("Title: %s - Season: %s - Ep: %s",
                     self.title, self.season, self.episode)
        if not self.season and not self.episode:
            # It's not a show. If it should be recognised as one. Send a bug.
            self.tearDown()
            return

        self.showid = self.mye.find_show_id(self.title)
        if self.showid is None:
            utils.notif("%s %s" % (self.title, _language(32923)), time=3000)
            self.tearDown()
            return
        logger.debug('Player - Found : %s - %d (S%s E%s)',
                     self.title, self.showid, self.season, self.episode)

        utils.notif(self.title, time=2000)
        self._addShow()
Exemplo n.º 6
0
    def _addShow(self):

        if not utils.getSettingAsBool('auto-add'):
            logger.debug('Auto-add function disabled.')
            return

        # Update the show dict to check if it has already been added somehow.
        self.mye.populate_shows()

        # Add the show if it's not already in our account
        if self.showid in self.mye.shows.values():
            logger.debug('Show is already in the account.')
            return

        was_added = self.mye.add_show(self.showid)
        added = 32926
        if was_added:
            added = 32925
        utils.notif("%s %s" % (self.title, _language(added)))
Exemplo n.º 7
0
    def _addShow(self):

        if not utils.getSettingAsBool('auto-add'):
            logger.debug('Auto-add function disabled.')
            return

        # Update the show dict to check if it has already been added somehow.
        self.mye.populate_shows()

        # Add the show if it's not already in our account
        if self.showid in self.mye.shows.values():
            logger.debug('Show is already in the account.')
            return

        was_added = self.mye.add_show(self.showid)
        added = 32926
        if was_added:
            added = 32925
        utils.notif("%s %s" % (self.title, _language(added)))
Exemplo n.º 8
0
    def start_requests(self):
        try:
            file = self.file
            mode = Mode.FILE
        except AttributeError:
            mode = Mode.KEYWORD

        header = random.choice(self.headers)

        if (mode == Mode.KEYWORD):
            url = "https://www.amazon.com/s/ref=nb_sb_noss_2?url=search-alias%3Daps&field-keywords=" + self.keyword
            yield scrapy.Request(url=url, callback=self.parse, headers={"user-agent": header}, cookies=self.cookies)
        else:
            links = readFile(file)
            notif(header)
            header = random.choice(self.headers)
            for link in links:
                if "http" in link:
                    yield scrapy.Request(url=link, callback=self.parse_product, headers={"user-agent": header}, cookies=self.cookies)
                else:
                    notif("INVALID LINK: " + link)
Exemplo n.º 9
0
def _initMyEpisodes():
    username = utils.getSetting('Username')
    password = utils.getSetting('Password')

    login_notif = _language(32912)
    if not username or not password:
        utils.notif(login_notif, time=2500)
        return None

    mye = MyEpisodes(username, password)
    mye.login()
    if mye.is_logged:
        login_notif = "%s %s" % (username, _language(32911))
    utils.notif(login_notif, time=2500)

    if mye.is_logged and (not mye.populate_shows()):
        utils.notif(_language(32927), time=2500)
    return mye
Exemplo n.º 10
0
def _initMyEpisodes():
    username = utils.getSetting('Username')
    password = utils.getSetting('Password')

    login_notif = _language(32912)
    if not username or not password:
        utils.notif(login_notif, time=2500)
        return None

    mye = MyEpisodes(username, password)
    mye.login()
    if mye.is_logged:
        login_notif = "%s %s" % (username, _language(32911))
    utils.notif(login_notif, time=2500)

    if mye.is_logged and (not mye.populate_shows()):
        utils.notif(_language(32927), time=2500)
    return mye
Exemplo n.º 11
0
    if SpotifyPlayer().is_playing():
        player = SpotifyPlayer()
    elif DeadbeefPlayer().is_playing():
        player = DeadbeefPlayer()
    elif MocpPlayer().is_playing():
        player = MocpPlayer()
    elif SpotifyPlayer().is_running():
        player = SpotifyPlayer()
    elif DeadbeefPlayer().is_running():
        player = DeadbeefPlayer()
    elif MocpPlayer().is_running():
        player = MocpPlayer()
    elif YoutubePlayer().is_running():
        player = YoutubePlayer()
    elif action != "status":
        notif("Aucun lecteur n\'est activé !")

    if action == "next":
        player.next()
    elif action == "prev":
        player.previous()
    elif action == "stop":
        player.stop()
    elif action == "toggle":
        player.toggle()
    elif action == "status":
        print(player)
    elif action == "artist":
        print(player.get_song().artist, end='')
    elif action == "title":
        print(player.get_song().title, end='')
Exemplo n.º 12
0
 def previous(self):
     notif(self.msg)
Exemplo n.º 13
0
 def next(self):
     notif(self.msg)
Exemplo n.º 14
0
 def stop(self):
     notif(self.msg)
Exemplo n.º 15
0
 def pause(self):
     notif(self.msg)
Exemplo n.º 16
0
 def play(self):
     notif(self.msg)
Exemplo n.º 17
0
 def toggle(self):
     notif(self.msg)
Exemplo n.º 18
0
    def parse_product(self, response):
        captcha = response.xpath('//*[@id="captchacharacters"]').extract_first()
        if response.status == 404:
            print("404")
            item = AmazonItem()
            item["Identifier"] = self.count_fail
            item["Name"] = "404 Not Found"
            item["ExternalURL"] = response.url
            self.count_fail += 1
            yield item
        elif (captcha is None):
            temp_title = response.xpath('//*[@id="productTitle"]/text()').extract_first()
            if temp_title is not None:
                temp_title = removeSpaceAndStrip(printableString(temp_title))

            # Handle description
            temp_short_description = response.xpath('//*[@id="feature-bullets"]//*  ').extract_first()

            # Handle price
            temp_price = response.xpath('//span[@id="priceblock_ourprice"]/text()').extract_first()
            if temp_price is not None:
                if len(temp_price) > 5:
                    temp_price = temp_price.split(" - ")[0]
            else:
                temp_price = response.xpath('//*[@id="priceblock_snsprice_Based"]/span/text()').extract_first()
                if temp_price is None:
                    temp_price = "can't get"

            # Handle description
            temp_description = response.xpath('//*[@id="productDescription"]//*').extract_first()
            if temp_description is None:
                temp_description = "Nothing"

            # Handle SKU
            temp_sku = response.url.split("/")[-1]

            # Handle image link
            temp_images = response.xpath('//*[@id="landingImage"]/@data-old-hires').extract_first()

            # Handle external URL
            temp_external_url = "https://www.amazon.com/dp/" + response.url.split("/")[-1] + "/?tag=vttgreat-20"


            item = AmazonItem()
            item["Identifier"] = self.count
            item["Type"] = "external"
            item["SKU"] = temp_sku
            item["Name"] = printableString(temp_title)
            item["Published"] = "1"
            item["IsFeatured"] = "0"
            item["VisibilityInCatalogue"] = "visible"
            item["ShortDescription"] = printableString(temp_short_description)
            item["Description"] = printableString(temp_description)
            item["TaxStatus"] = "taxable"
            item["InStock"] = "100"
            item["AllowCustomerReviews"] = "1"
            item["Price"] = temp_price
            item["Categories"] = "Fashion"
            item["Tags"] = ""
            item["Images"] = temp_images
            item["ExternalURL"] = temp_external_url
            item["Position"] = "0"

            self.count += 1
            notif("Success " + response.url.split("/")[-1])
            yield item
        else:
            item = AmazonItem()
            item["Identifier"] = self.count_fail
            item["Name"] = "CAPTCHA"
            item["ExternalURL"] = "https://www.amazon.com/dp/" + response.url.split("/")[-1] + "?tag=vttgreat-20"
            self.count_fail += 1
            yield item