Exemplo n.º 1
0
    def read(self):
        if '/directory/' in self.url.lower():
            raise errors.Invalid(
                '[twitch] Directory is unsupported: {}'.format(self.url))

        if self.url.count('/') == 3:
            if 'www.twitch.tv' in self.url or '//twitch.tv' in self.url:
                filter = 'videos'
            else:
                filter = None
        elif self.url.count('/') == 4:
            filter = re.find(r'filter=([0-9a-zA-Z_]+)', self.url) or re.find(
                r'[0-9a-zA-Z_]+',
                self.url.split('/')[-1])
            if filter is not None and filter.isdigit():
                filter = None
        else:
            filter = None

        if filter is None:
            video = Video(self.url, self.cw)
            video.url()
            self.urls.append(video.url)
            self.title = video.title
        elif filter == 'clips':
            info = get_videos(self.url, cw=self.cw)
            video = self.process_playlist('[Clip] {}'.format(info['name']),
                                          info['videos'])
        else:
            raise NotImplementedError(filter)

        self.setIcon(video.thumb)
Exemplo n.º 2
0
    def read(self):
        ui_setting = self.ui_setting
        if self.cw.format:
            self._format = self.cw.format

        if self._format == 'mp3':
            self.cw.setMusic(True)

        if ui_setting.nicoBox.isChecked():
            username = compatstr(ui_setting.nico_id.text())
            password = compatstr(ui_setting.nico_pw.text())
        else:
            username = ''
            password = ''

        try:
            session = login(username, password)
        except Exception as e:
            logout()
            raise errors.Invalid(u'Failed to login: {}'.format(self.url),
                                 fail=True)

        self.session = session
        try:
            video = get_video(session, self.url, self._format, self.cw)
        except Exception as e:
            logout()
            raise

        self.urls.append(video.url)
        self.setIcon(video.thumb)

        self.enableSegment()

        self.title = video.title
    def init(self):
        if u'bdsmlr.com/post/' in self.url:
            raise errors.Invalid(
                tr_(u'개별 다운로드는 지원하지 않습니다: {}').format(self.url))

        self.url = 'https://{}.bdsmlr.com'.format(self.id_)
        self.session = Session()
        clf2.solve(self.url, session=self.session, cw=self.cw)
    def read(self):
        self.__init()
        cw = self.cw
        if cw:
            cw._torrent_s = None
        title = self.url
        self._dn = self.get_dn(self.url)
        info = getattr(cw, 'info?', None)
        if info is not None:
            self.print_('cached info')
            self._info = info
        if self._info is None:
            try:
                self._info = torrent.get_info(self.url,
                                              cw,
                                              timeout=TIMEOUT,
                                              callback=self.callback)
                if CACHE_INFO:
                    setattr(cw, 'info?', self._info)
            except Exception as e:
                self.update_pause()
                if not cw.paused:
                    raise errors.Invalid('Faild to read metadata: {}'.format(
                        self.url),
                                         fail=True)
        if self._info is None:
            cw.paused = True
        if cw.paused:
            return
        hash_ = self._info.hash.hex()
        self.print_('v2: {}'.format(self._info.v2))
        self.print_('Hash: {}'.format(hash_))
        if not self._info.v2:
            self.url = 'magnet:?xt=urn:btih:{}'.format(hash_)  #
        date = datetime.fromtimestamp(self._info.creation_date())
        date = date.strftime('%y-%m-%d %H:%M:%S')
        self.print_('Created on: {}'.format(date))
        self.print_('Total size: {}'.format(fs.size(self._info.total_size())))
        self.print_('Pieces: {} x {}'.format(
            self._info.num_pieces(), fs.size(self._info.piece_length())))
        self.print_('Creator: {}'.format(self._info.creator()))
        self.print_('Comment: {}'.format(self._info.comment()))
        cw.setTotalFileSize(self._info.total_size())

        cw.imgs.clear()
        cw.dones.clear()

        self.urls = [self.url]
        self.title = self.name
        self.update_files()

        if not self.single and not os.path.isdir(self.dir):  #4698
            downloader.makedir_event(self.dir, cw)

        cw.pbar.show()
Exemplo n.º 5
0
 def read(self):
     if '/post/' in self.url:
         raise errors.Invalid(
             tr_('개별 다운로드는 지원하지 않습니다: {}').format(self.url))
     self._popular = 'search-Popular.' in self.url
     self.title = clean_title(self.name)
     qs = query_url(self.url)
     q = qs['q'][0]
     for id in get_ids_multi(q, self._popular, self.cw):
         img = Image(id, self.url)
         self.urls.append(img.url)
    def read(self):
        video = Video(self.url, format, cw=self.cw)
        try:
            video.url()#
        except EmbedUrlError as e:
            raise errors.Invalid(e.args[0])

        self.urls.append(video.url)
        self.setIcon(video.thumb)

        self.enableSegment()

        self.title = video.title
Exemplo n.º 7
0
    def read(self):
        token_guild_id_list = self.url.split(
            "/"
        )  # 값을 어떻게 받을지 몰라서 일단 나눴어요. discord_이메일/비밀번호/서버아이디 또는 discord_토큰/서버아이디 이런식으로 받게 해놨어요.

        if len(token_guild_id_list) == 2:
            token = token_guild_id_list[0]
            guild_id = token_guild_id_list[1]
        elif len(token_guild_id_list) == 3:
            email = token_guild_id_list[0]
            password = token_guild_id_list[1]
            guild_id = token_guild_id_list[2]

            response = self.post_account_info(email, password)
            account_info = response.json()
            if response.status_code == 400:
                if account_info.get("captcha_key"):
                    raise errors.Invalid("먼저 웹 또는 디스코드 앱에서 로그인하신후 캡차를 인증해주세요."
                                         )  # 메세지 박스 return하니까 멈춰서 raise로 해놨어요
                else:
                    raise errors.Invalid(
                        "이메일 또는 비밀번호가 잘못되었습니다. 확인후 다시 시도해주세요.")
            else:
                if not account_info["token"]:
                    raise errors.Invalid(
                        "토큰을 받아오지 못했어요. 2단계인증을 사용중이신경우 토큰을 이용해 요청해주세요.")
                else:
                    token = account_info["token"]
        else:
            raise errors.Invalid("인자값이 더 많이왔어요.")

        guild_info_response = self.get_emoji_list(
            token, int(guild_id))  # 토큰과 함께 get요청함

        if guild_info_response.status_code != 200:
            raise errors.Invalid(
                "정상적인 토큰이 아니거나 서버를 찾을수없어요. 맞는 토큰인지, 해당 서버에 접속해있는지 확인해주세요.")
        else:
            guild_info = guild_info_response.json()

        if guild_info["emojis"]:
            base_url = "https://cdn.discordapp.com/emojis/"
            for emoji in guild_info["emojis"]:  # 이모지 리스트로 가져옴
                if emoji["animated"] is True:  # 만약 gif면 gif 다운로드
                    param = emoji["id"] + ".gif"
                else:  # 아닐경우 png로
                    param = emoji["id"] + ".png"

                self.title = clean_title(
                    f'{guild_info["name"]}({guild_info["id"]})'  # 폴더 이름은 서버 이름, id
                )
                self.urls.append(base_url + param + "?v=1")  # 인자 합치기
        else:
            raise errors.Invalid("해당 서버에는 이모지가 없어요")
    def read(self):
        file = None
        files = None
        title = None
        if '/users/' in self.url or '/user/' in self.url:
            type_ = 'videos'
            try:
                if self.url.split('/users/')[1].split('/')[1] == 'images':
                    type_ = 'images'
            except:
                pass
            info = read_channel(self.url, type_, self.session, self.cw)
            title = info['title']
            urls = info['urls']
            if type_ == 'videos':
                files = [LazyFile(url, type_, self.session) for url in urls]
                file = self.process_playlist('[Channel] [{}] {}'.format(type_.capitalize(), title), files)
            elif type_ == 'images': #4499
                files = []
                for i, url in enumerate(urls):
                    check_alive(self.cw)
                    files += get_files(url, self.session, multi_post=True, cw=self.cw) #4728
                    self.title = '{} {} - {} / {}'.format(tr_('읽는 중...'), title, i, len(urls))
                title = '[Channel] [{}] {}'.format(type_.capitalize(), title)
            else:
                raise NotImplementedError(type_)

        if file is None:
            if files is None:
                files = get_files(self.url, self.session, cw=self.cw)
            for file in files:
                self.urls.append(file.url)
            file = files[0]

            if file.type == 'youtube':
                raise errors.Invalid('[iwara] Youtube: {}'.format(self.url))
            
            if file.type == 'image':
                self.single = False
            title = title or file.title
            if not self.single:
                title = clean_title(title)
            self.title = title
            
        if file.thumb is not None:
            self.setIcon(file.thumb)
Exemplo n.º 9
0
    def read(self):
        cw = self.cw
        title = self.url
        if self.url.startswith('magnet:'):
            qs = utils.query_url(self.url)
            if 'dn' in qs:
                self._dn = qs['dn'][0]
        info = getattr(cw, 'info?', None)
        if info is not None:
            self.print_('cached info')
            self._info = info
        if self._info is None:
            try:
                self._info = torrent.get_info(self.url, cw, timeout=TIMEOUT, callback=self.callback)
                if CACHE_INFO:
                    setattr(cw, 'info?', self._info)
            except Exception as e:
                self.update_pause()
                if not cw.paused:
                    raise errors.Invalid('Faild to read metadata: {}'.format(self.url), fail=True)
        if self._info is None:
            cw.paused = True
        if cw.paused:
            return
        hash_ = self._info.hash.hex()
        self.print_('v2: {}'.format(self._info.v2))
        self.print_('Hash: {}'.format(hash_))
        if not self._info.v2:
            self.url = 'magnet:?xt=urn:btih:{}'.format(hash_)#
        date = datetime.fromtimestamp(self._info.creation_date())
        date = date.strftime('%y-%m-%d %H:%M:%S')
        self.print_('Created on: {}'.format(date))
        self.print_('Total size: {}'.format(fs.size(self._info.total_size())))
        self.print_('Pieces: {} x {}'.format(self._info.num_pieces(), fs.size(self._info.piece_length())))
        self.print_('Creator: {}'.format(self._info.creator()))
        self.print_('Comment: {}'.format(self._info.comment()))
        cw.setTotalFileSize(self._info.total_size())
        
        cw.imgs.clear()
        cw.dones.clear()

        self.urls = [self.url]
        self.title = self.name
        self.update_files()
        
        cw.pbar.show()
Exemplo n.º 10
0
    def read(self):
        file = None
        files = None
        title = None
        if '/users/' in self.url or '/user/' in self.url:
            type_ = 'videos'
            try:
                if self.url.split('/users/')[1].split('/')[1] == 'images':
                    type_ = 'images'
            except:
                pass
            info = read_channel(self.url, type_, self.session, self.cw)
            title = info['title']
            urls = info['urls']
            if type_ == 'videos':
                files = [LazyFile(url, type_, self.session) for url in urls]
                file = self.process_playlist(
                    '[Channel] [{}] {}'.format(type_.capitalize(), title),
                    files)
            elif type_ == 'images':
                files = [LazyFile(url, type_, self.session) for url in urls]
                title = '[Channel] [{}] {}'.format(type_.capitalize(), title)
            else:
                raise NotImplementedError(type_)

        if file is None:
            if files is None:
                files = get_files(self.url, self.session, cw=self.cw)
            for file in files:
                self.urls.append(file.url)
            file = files[0]

            if file.type == 'youtube':
                raise errors.Invalid('[iwara] Youtube: {}'.format(self.url))

            if file.type == 'image':
                self.single = False
            self.title = clean_title(title or file.title)

        if file.thumb is not None:
            self.setIcon(file.thumb)
Exemplo n.º 11
0
 def init(self):
     if not self.cw.data_:
         link = 'https://github.com/KurtBestor/Hitomi-Downloader/wiki/Chrome-Extension'
         webbrowser.open(link)
         raise errors.Invalid('No data; See: {}'.format(link))
Exemplo n.º 12
0
 def init(self):
     if u'tumblr.com/post/' in self.url:
         raise errors.Invalid(
             tr_(u'개별 다운로드는 지원하지 않습니다: {}').format(self.url))
     self.session = Session()
 def init(self):
     username, pid = get_id(self.url)
     if username is None:
         raise errors.Invalid('Invalid format: {}'.format(self.url))
     self.url = 'https://blog.naver.com/{}/{}'.format(username, pid)
     self.headers = {'User-Agent': downloader.hdr['User-Agent']}
Exemplo n.º 14
0
 def init(self):
     self._soup, self.session = get_soup_session(self.url, self.cw)
     if not self.soup.find('ul', class_='manga-info'):
         raise errors.Invalid(u'{}: {}'.format(tr_(u'목록 주소를 입력해주세요'),
                                               self.url))
Exemplo n.º 15
0
 def init(self):
     if '/viewer/' in self.url:
         raise errors.Invalid(tr_('목록 주소를 입력해주세요: {}').format(self.url))