예제 #1
0
    def run(self):
        """ Main function, downloads videos by their id while emitting progress data"""
        # Download
        mp4_path = os.path.join(self.download_path, "mp4")
        try:
            os.mkdir(mp4_path)
        except FileExistsError:
            pass

        time0 = time.time()
        video_properties = (
            (
                key_value,
                (self.download_path, mp4_path),
                self.playlist_properties[index],
                self.save_as_mp4,
            ) for index, key_value in enumerate(self.videos_dict.items(
            ))  # dict is naturally sorted in iteration
        )
        utils.map_threads(utils.thread_query_youtube, video_properties)
        shutil.rmtree(mp4_path)  # remove mp4 dir
        time1 = time.time()

        delta_t = time1 - time0
        self.downloadCount.emit(delta_t)
예제 #2
0
    def run(self):
        """ Main function, downloads videos by their id while emitting progress data"""
        # Download
        mp4_path = os.path.join(self.download_path, "mp4")
        try:
            os.mkdir(mp4_path)
        except FileExistsError:
            pass
        except FileNotFoundError:
            # If the user downloads to a folder, deletes the folder, and reattempts
            # to download to the same folder within the same session.
            raise RuntimeError(
                f'"{os.path.abspath(os.path.dirname(mp4_path))}" does not exist.\nEnsure this directory exists prior to executing download.'
            )

        time0 = time.time()
        video_properties = (
            (
                key_value,
                (self.download_path, mp4_path),
                self.playlist_properties[index],
                self.save_as_mp4,
            ) for index, key_value in enumerate(self.videos_dict.items(
            ))  # dict is naturally sorted in iteration
        )
        utils.map_threads(utils.thread_query_youtube, video_properties)
        shutil.rmtree(mp4_path)  # remove mp4 dir
        time1 = time.time()

        delta_t = time1 - time0
        self.downloadCount.emit(delta_t)
예제 #3
0
    def run(self):
        """Multithread query to iTunes - return tuple."""
        try:
            query_iter = ((row_index, key_value) for row_index, key_value in
                          enumerate(self.videos_dict.items()))
        except AttributeError:  # i.e. no content in table -- exit early
            return
        itunes_query = utils.map_threads(utils.thread_query_itunes, query_iter)
        itunes_query_tuple = tuple(itunes_query)
        if not self.check_itunes_nonetype(itunes_query_tuple):
            query_status = False
        else:
            query_status = True

        self.loadFinished.emit(itunes_query_tuple, query_status)
예제 #4
0
def add_new_posts(email_obj, new_posts_dtfm):
    """Add post attributes to email object if post is
    valid."""
    if new_posts_dtfm.shape[0] == 0:
        return None

    new_posts = [post for _, post in new_posts_dtfm.iterrows()]
    response = utils.map_threads(parse_verify_posts, new_posts)

    for post in response:
        if post is None:
            continue
        email_obj.body(
            post["location"],
            post["price"],
            post["bedrooms"],
            post["url"],
            post["title"],
        )

    return email_obj