def _download_file(self, f): l = util.make_url(self._file_playlist.url, f['file']) name = urlparse.urlparse(f['file']).path.split('/')[-1] path = os.path.join(self.path, name) d = self._download_page(l, path) d.addCallback(self._got_file, l, f) return d
def _playlist_updated(self, pl): if pl.has_programs(): # if we got a program playlist, save it and start a program self._program_playlist = pl (program_url, _) = pl.get_program_playlist(self.program, self.bitrate) l = util.make_url(self.url, program_url) return self._reload_playlist(M3U8(l)) elif pl.has_files(): # we got sequence playlist, start reloading it regularly, and get files self._file_playlist = pl if not self._files: self._files = pl.iter_files() if not pl.endlist(): reactor.callLater(pl.reload_delay(), self._reload_playlist, pl) if self._file_playlisted: self._file_playlisted.callback(pl) self._file_playlisted = None else: raise return pl
def detail_parse(self, response): cate = response.meta['cate'] img = response.css('div.cont img::attr(src)').extract() img.append( response.css( 'div.detailArea div.keyImg img::attr("src")').extract_first()) price = response.css( 'meta[property="product:price:amount"]::attr(content)' ).extract_first() price_unit = response.css( 'meta[property="product:price:currency"]::attr(content)' ).extract_first() url = response.url product_no = url[42 + len('product_no='):].split('&')[0] image_url = response.css( 'meta[property="og:image"]::attr(content)').extract()[1] if image_url not in inserted_image: yield { 'host_url': self.domain, 'tag': cate, 'product_name': response.css( 'meta[property="og:title"]::attr(content)').extract()[1], 'image_url': make_url(self.domain, image_url), 'product_price': price, 'currency_unit': price_unit, 'product_url': url, 'product_no': product_no, 'main': '1', 'nation': 'ko' } inserted_image.append(image_url) for im in img: if im not in inserted_image: yield { 'host_url': self.domain, 'tag': cate, 'product_name': response.css('meta[property="og:title"]::attr(content)'). extract()[1], 'image_url': make_url(self.domain, im), 'product_price': price, 'currency_unit': price_unit, 'product_url': url, 'product_no': product_no, 'main': '0', 'nation': 'ko' } inserted_image.append(im)