<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def _handle_resource(self, url, fmt, lecture_filename, callback, last_update):
 """ Handle resource. This function builds up resource file name and downloads it if necessary. @param url: URL of the resource. @type url: str @param fmt: Format of the resource (pdf, csv, etc) @type fmt: str @param lecture_filename: File name of the lecture. @type lecture_filename: str @param callback: Callback that will be called when file has been downloaded. It will be called even if exception occurred. @type callback: callable(url, result) where result may be Exception @param last_update: Timestamp of the newest file so far. @type last_update: int @return: Updated latest mtime. @rtype: int """

        overwrite = self._args.overwrite
        resume = self._args.resume
        skip_download = self._args.skip_download

        # Decide whether we need to download it
        if overwrite or not os.path.exists(lecture_filename) or resume:
            if not skip_download:
                if url.startswith(IN_MEMORY_MARKER):
                    page_content = url[len(IN_MEMORY_MARKER):]
                    logging.info('Saving page contents to: %s', lecture_filename)
                    with codecs.open(lecture_filename, 'w', 'utf-8') as file_object:
                        file_object.write(page_content)
                else:
                    if self.skipped_urls is not None and skip_format_url(fmt, url):
                        self.skipped_urls.append(url)
                    else:
                        logging.info('Downloading: %s', lecture_filename)
                        self._downloader.download(callback, url, lecture_filename, resume=resume)
            else:
                open(lecture_filename, 'w').close()  # touch
            last_update = time.time()
        else:
            logging.info('%s already downloaded', lecture_filename)
            # if this file hasn't been modified in a long time,
            # record that time
            last_update = max(last_update,
                              os.path.getmtime(lecture_filename))
        return last_update