资源简介

Google为用户提供了一种通过Google TakeOut从Google照片下载数据的方法。用户可以下载包含所有(真的吗?)照片的zip文件。问题是Google选择性地将Json文件替换为zip中的图像文件。该json文件包含实际图像所在的链接

资源截图

代码片段和文件信息

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Json;
using System.IO;
using System.Net;
namespace GoogleTakeoutImageDownloader
{
    public interface IDownloadProgressNotifier
    {
        void OnCurrentFileProgress(String sCurrentFileName int processedFilesCount int totalFileCount);
        void onerror(String sFileName String sErrorInformation);

        void PreDownload(int TotalFilesCount);
        void OnDownloadFinish();
    }
    public class DownloadManager
    {
        bool stoponerror = false;
        String inputRootFolder;
        String outputRootFolder;
        bool overwriteOutputFolder = false;
        IDownloadProgressNotifier Notifier;
        const String JSON_JPEG_FILE_FILTER = @“*.jpg.json“;

        int TotalFilesCount = 0;
        int ProcessedFilesCount = 0;

        public DownloadManager(String RootFolder String outRootFolder bool bOverwrite bool bStoponerror IDownloadProgressNotifier notificationHandler)
        {
            stoponerror = bStoponerror;
            inputRootFolder = RootFolder;
            outputRootFolder = outRootFolder;
            overwriteOutputFolder = bOverwrite;
            Notifier = notificationHandler;


            //
            // Count all files needs to be processes.
            //
            TotalFilesCount = Directory.EnumerateFiles(inputRootFolder JSON_JPEG_FILE_FILTER SearchOption.AllDirectories).Count();

        }

        public void StartDownload()
        {

            if (Notifier != null)
                Notifier.PreDownload(TotalFilesCount);

            //
            //Create Folder structure in the output directory.
            //

            CreateDirectory(new DirectoryInfo(Path.GetDirectoryName(inputRootFolder)));

            TraverseFolderTree(inputRootFolder);

            if (Notifier != null)
                Notifier.OnDownloadFinish();
        }

        public static void CreateDirectory(DirectoryInfo directory)
        {
            if (!directory.Parent.Exists)
                CreateDirectory(directory.Parent);
            directory.Create();
        }
        private void TraverseFolderTree(String sSeedFolder)
        {
            String sCurrentOutputFolder = sSeedFolder.Replace(inputRootFolder outputRootFolder) ;
            //
            //Create folder in output folder hierarchy. It will be skipped for first call.
            //
            if (sSeedFolder == string.Empty)
                Directory.CreateDirectory(sCurrentOutputFolder);

            //
            // Traverse through all directories recursively.
            //
            foreach (String strDirectory in Directory.EnumerateDirectories(sSeedFolder))
            {
                TraverseFolderTree(strDirectory);
            }

            //Create Output directory if not alreaday existed.
            if (!Di

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2017-12-28 03:43  GoogleTakeOutImageDownloader_source\
     目录           0  2017-12-28 03:43  GoogleTakeOutImageDownloader_source\GoogleTakeoutImageDownloader\
     目录           0  2017-12-28 03:43  GoogleTakeOutImageDownloader_source\GoogleTakeoutImageDownloader\.vs\
     目录           0  2017-12-28 03:43  GoogleTakeOutImageDownloader_source\GoogleTakeoutImageDownloader\.vs\GoogleTakeoutImageDownloader\
     目录           0  2017-12-28 03:43  GoogleTakeOutImageDownloader_source\GoogleTakeoutImageDownloader\.vs\GoogleTakeoutImageDownloader\v15\
     文件      221696  2017-12-28 03:41  GoogleTakeOutImageDownloader_source\GoogleTakeoutImageDownloader\.vs\GoogleTakeoutImageDownloader\v15\.suo
     目录           0  2017-12-28 03:43  GoogleTakeOutImageDownloader_source\GoogleTakeoutImageDownloader\.vs\GoogleTakeoutImageDownloader\v15\Server\
     目录           0  2017-12-28 03:43  GoogleTakeOutImageDownloader_source\GoogleTakeoutImageDownloader\.vs\GoogleTakeoutImageDownloader\v15\Server\sqlite3\
     文件           0  2017-12-09 20:10  GoogleTakeOutImageDownloader_source\GoogleTakeoutImageDownloader\.vs\GoogleTakeoutImageDownloader\v15\Server\sqlite3\db.lock
     文件      790528  2017-12-28 03:41  GoogleTakeOutImageDownloader_source\GoogleTakeoutImageDownloader\.vs\GoogleTakeoutImageDownloader\v15\Server\sqlite3\storage.ide
     目录           0  2017-12-28 03:43  GoogleTakeOutImageDownloader_source\GoogleTakeoutImageDownloader\GoogleTakeoutImageDownloader\
     文件        1183  2017-12-09 20:10  GoogleTakeOutImageDownloader_source\GoogleTakeoutImageDownloader\GoogleTakeoutImageDownloader.sln
     文件         189  2017-12-09 20:10  GoogleTakeOutImageDownloader_source\GoogleTakeoutImageDownloader\GoogleTakeoutImageDownloader\App.config
     目录           0  2017-12-28 03:43  GoogleTakeOutImageDownloader_source\GoogleTakeoutImageDownloader\GoogleTakeoutImageDownloader\bin\
     目录           0  2017-12-28 03:40  GoogleTakeOutImageDownloader_source\GoogleTakeoutImageDownloader\GoogleTakeoutImageDownloader\bin\Debug\
     目录           0  2017-12-28 03:40  GoogleTakeOutImageDownloader_source\GoogleTakeoutImageDownloader\GoogleTakeoutImageDownloader\bin\Release\
     文件        4810  2017-12-28 01:40  GoogleTakeOutImageDownloader_source\GoogleTakeoutImageDownloader\GoogleTakeoutImageDownloader\DownloadManager.cs
     文件        3421  2017-12-28 02:39  GoogleTakeOutImageDownloader_source\GoogleTakeoutImageDownloader\GoogleTakeoutImageDownloader\Form1.cs
     文件        7447  2017-12-28 02:24  GoogleTakeOutImageDownloader_source\GoogleTakeoutImageDownloader\GoogleTakeoutImageDownloader\Form1.Designer.cs
     文件        5817  2017-12-28 02:24  GoogleTakeOutImageDownloader_source\GoogleTakeoutImageDownloader\GoogleTakeoutImageDownloader\Form1.resx
     文件        3992  2017-12-10 15:27  GoogleTakeOutImageDownloader_source\GoogleTakeoutImageDownloader\GoogleTakeoutImageDownloader\GoogleTakeoutImageDownloader.csproj
     目录           0  2017-12-28 03:43  GoogleTakeOutImageDownloader_source\GoogleTakeoutImageDownloader\GoogleTakeoutImageDownloader\obj\
     目录           0  2017-12-28 03:43  GoogleTakeOutImageDownloader_source\GoogleTakeoutImageDownloader\GoogleTakeoutImageDownloader\obj\Debug\
     文件        1464  2017-12-23 13:16  GoogleTakeOutImageDownloader_source\GoogleTakeoutImageDownloader\GoogleTakeoutImageDownloader\obj\Debug\DesignTimeResolveAssemblyReferences.cache
     文件       24620  2017-12-28 03:40  GoogleTakeOutImageDownloader_source\GoogleTakeoutImageDownloader\GoogleTakeoutImageDownloader\obj\Debug\DesignTimeResolveAssemblyReferencesInput.cache
     文件           0  2017-12-28 02:39  GoogleTakeOutImageDownloader_source\GoogleTakeoutImageDownloader\GoogleTakeoutImageDownloader\obj\Debug\GoogleTakeoutImageDownloader.csproj.CopyComplete
     文件           0  2017-12-09 20:10  GoogleTakeOutImageDownloader_source\GoogleTakeoutImageDownloader\GoogleTakeoutImageDownloader\obj\Debug\TemporaryGeneratedFile_036C0B5B-1481-4323-8D20-8F5ADCB23D92.cs
     文件           0  2017-12-09 20:10  GoogleTakeOutImageDownloader_source\GoogleTakeoutImageDownloader\GoogleTakeoutImageDownloader\obj\Debug\TemporaryGeneratedFile_5937a670-0e60-4077-877b-f7221da3dda1.cs
     文件           0  2017-12-09 20:10  GoogleTakeOutImageDownloader_source\GoogleTakeoutImageDownloader\GoogleTakeoutImageDownloader\obj\Debug\TemporaryGeneratedFile_E7A71F73-0F8D-4B9B-B56E-8E70B10BC5D3.cs
     目录           0  2017-12-09 20:10  GoogleTakeOutImageDownloader_source\GoogleTakeoutImageDownloader\GoogleTakeoutImageDownloader\obj\Debug\TempPE\
     目录           0  2017-12-28 03:43  GoogleTakeOutImageDownloader_source\GoogleTakeoutImageDownloader\GoogleTakeoutImageDownloader\obj\Release\
............此处省略51个文件信息

评论

共有 条评论

相关资源