├── .gitattributes ├── .gitignore ├── MIUIThemeDownlaoder.sln ├── MIUIThemeDownlaoder ├── Downloader.cpp ├── Downloader.h ├── HttpRequest.cpp ├── HttpRequest.h ├── MIUIThemeDownlaoder.vcxproj ├── MIUIThemeDownlaoder.vcxproj.filters ├── MIUIThemeDownlaoder.vcxproj.user ├── MainWindow.cpp ├── amd64_dpi_aware.manifest ├── appicon.ico ├── applicationicon.ico ├── resource.rc ├── urlcoding.cpp └── urlcoding.h ├── picture └── mainwindow.png ├── readme.md └── readme_zh.md /.gitattributes: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # Set default behavior to automatically normalize line endings. 3 | ############################################################################### 4 | * text=auto 5 | 6 | ############################################################################### 7 | # Set default behavior for command prompt diff. 8 | # 9 | # This is need for earlier builds of msysgit that does not have it on by 10 | # default for csharp files. 11 | # Note: This is only used by command line 12 | ############################################################################### 13 | #*.cs diff=csharp 14 | 15 | ############################################################################### 16 | # Set the merge driver for project and solution files 17 | # 18 | # Merging from the command prompt will add diff markers to the files if there 19 | # are conflicts (Merging from VS is not affected by the settings below, in VS 20 | # the diff markers are never inserted). Diff markers may cause the following 21 | # file extensions to fail to load in VS. An alternative would be to treat 22 | # these files as binary and thus will always conflict and require user 23 | # intervention with every merge. To do so, just uncomment the entries below 24 | ############################################################################### 25 | #*.sln merge=binary 26 | #*.csproj merge=binary 27 | #*.vbproj merge=binary 28 | #*.vcxproj merge=binary 29 | #*.vcproj merge=binary 30 | #*.dbproj merge=binary 31 | #*.fsproj merge=binary 32 | #*.lsproj merge=binary 33 | #*.wixproj merge=binary 34 | #*.modelproj merge=binary 35 | #*.sqlproj merge=binary 36 | #*.wwaproj merge=binary 37 | 38 | ############################################################################### 39 | # behavior for image files 40 | # 41 | # image files are treated as binary by default. 42 | ############################################################################### 43 | #*.jpg binary 44 | #*.png binary 45 | #*.gif binary 46 | 47 | ############################################################################### 48 | # diff behavior for common document formats 49 | # 50 | # Convert binary document formats to text before diffing them. This feature 51 | # is only available from the command line. Turn it on by uncommenting the 52 | # entries below. 53 | ############################################################################### 54 | #*.doc diff=astextplain 55 | #*.DOC diff=astextplain 56 | #*.docx diff=astextplain 57 | #*.DOCX diff=astextplain 58 | #*.dot diff=astextplain 59 | #*.DOT diff=astextplain 60 | #*.pdf diff=astextplain 61 | #*.PDF diff=astextplain 62 | #*.rtf diff=astextplain 63 | #*.RTF diff=astextplain 64 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .vs 2 | Debug 3 | Release 4 | .vscode 5 | *.mtz 6 | -------------------------------------------------------------------------------- /MIUIThemeDownlaoder.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 17 4 | VisualStudioVersion = 17.1.32228.430 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "MIUIThemeDownlaoder", "MIUIThemeDownlaoder\MIUIThemeDownlaoder.vcxproj", "{901A2BF5-4BBC-4228-9434-636AA90A3DD4}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|x64 = Debug|x64 11 | Debug|x86 = Debug|x86 12 | Release|x64 = Release|x64 13 | Release|x86 = Release|x86 14 | EndGlobalSection 15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 16 | {901A2BF5-4BBC-4228-9434-636AA90A3DD4}.Debug|x64.ActiveCfg = Debug|x64 17 | {901A2BF5-4BBC-4228-9434-636AA90A3DD4}.Debug|x64.Build.0 = Debug|x64 18 | {901A2BF5-4BBC-4228-9434-636AA90A3DD4}.Debug|x86.ActiveCfg = Debug|Win32 19 | {901A2BF5-4BBC-4228-9434-636AA90A3DD4}.Debug|x86.Build.0 = Debug|Win32 20 | {901A2BF5-4BBC-4228-9434-636AA90A3DD4}.Release|x64.ActiveCfg = Release|x64 21 | {901A2BF5-4BBC-4228-9434-636AA90A3DD4}.Release|x64.Build.0 = Release|x64 22 | {901A2BF5-4BBC-4228-9434-636AA90A3DD4}.Release|x86.ActiveCfg = Release|Win32 23 | {901A2BF5-4BBC-4228-9434-636AA90A3DD4}.Release|x86.Build.0 = Release|Win32 24 | EndGlobalSection 25 | GlobalSection(SolutionProperties) = preSolution 26 | HideSolutionNode = FALSE 27 | EndGlobalSection 28 | GlobalSection(ExtensibilityGlobals) = postSolution 29 | SolutionGuid = {77F5BA5D-9E42-4C53-80DE-B1023267FD62} 30 | EndGlobalSection 31 | EndGlobal 32 | -------------------------------------------------------------------------------- /MIUIThemeDownlaoder/Downloader.cpp: -------------------------------------------------------------------------------- 1 | #include "Downloader.h" 2 | #include 3 | #include 4 | #include 5 | #include "HttpRequest.h" 6 | #include 7 | #include "urlcoding.h" 8 | 9 | Downloader::Downloader(DownloadCallBack* cb) :mCallBack(cb) 10 | { 11 | mDownloading.store(false); 12 | } 13 | 14 | Downloader::~Downloader() 15 | { 16 | } 17 | 18 | bool Downloader::isDownloading() 19 | { 20 | return false; 21 | } 22 | 23 | bool Downloader::setDownloadState() 24 | { 25 | return false; 26 | } 27 | 28 | void Downloader::tryget(const std::string& url, TRY_GEY_TYPE type, const std::string& version) 29 | { 30 | 31 | switch (type) 32 | { 33 | case GET_DOWNLOAD_LINK_URL: 34 | { 35 | mCallBack->onStart(); 36 | if (isValidMiuiThemeUrl(url)) { 37 | if (url != mUrl) { 38 | mCallBack->onURLChanged(); 39 | mUrl = url; 40 | } 41 | std::string themeId = url.substr(strlen("http://zhuti.xiaomi.com/detail/")); 42 | std::string themeLinkApi = "https://thm.market.xiaomi.com/thm/download/v2/" + themeId + "?capability=w%2Cb%2Cs%2Cm%2Ch5%2Cv%3A8%2Cvw&miuiUIVersion=" + version; 43 | std::string resp; 44 | 45 | if (httpRequestIme(themeLinkApi, resp) && checkResponseValid(resp)) 46 | { 47 | mCallBack->onMessage(mDownloadLink, GET_LINK_SUCCESS); 48 | } 49 | else 50 | { 51 | mCallBack->onMessage(resp, GET_LINK_FAILED); 52 | } 53 | } 54 | else 55 | { 56 | mCallBack->onMessage(url, INVALID_MIUI_THEME_URL); 57 | } 58 | mCallBack->onFinished(); 59 | } 60 | break; 61 | case DOWNLOAD_THEME_AS_FILE: 62 | { 63 | mCallBack->onStart(); 64 | strCoding urlcoding; 65 | std::string filename = urlcoding.getName(url.c_str()); 66 | FILE* file = mCallBack->onSave(filename); 67 | if (file) 68 | { 69 | httpRequest(url, file, mCallBack); 70 | } 71 | mCallBack->onFinished(); 72 | } 73 | break; 74 | default: 75 | break; 76 | } 77 | } 78 | 79 | bool Downloader::isValidMiuiThemeUrl(const std::string& url) 80 | { 81 | if (strncmp(url.c_str(), "http://zhuti.xiaomi.com/detail/", strlen("http://zhuti.xiaomi.com/detail/")) == 0) 82 | { 83 | static std::regex pattern("^http://zhuti.xiaomi.com/detail/[0-9a-z]{8}-[0-9a-z]{4}-[0-9a-z]{4}-[0-9a-z]{4}-[0-9a-z]{12}$"); 84 | return std::regex_match(url, pattern); 85 | } 86 | return false; 87 | } 88 | 89 | bool Downloader::checkResponseValid(const std::string& resp) 90 | { 91 | Json::Value rootValue; 92 | Json::Reader reader; 93 | if (reader.parse(resp, rootValue)) 94 | { 95 | if (rootValue.isMember("apiCode") && rootValue.isMember("apiData") && rootValue["apiData"].isObject()) 96 | { 97 | Json::Value apidata = rootValue["apiData"]; 98 | if (apidata.isMember("downloadUrl") && apidata.isMember("fileSize")) 99 | { 100 | mDownloadLink = apidata["downloadUrl"].asString(); 101 | return true; 102 | } 103 | } 104 | } 105 | return false; 106 | } 107 | -------------------------------------------------------------------------------- /MIUIThemeDownlaoder/Downloader.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | #include 7 | 8 | 9 | enum TRY_GEY_TYPE 10 | { 11 | GET_DOWNLOAD_LINK_URL = 0, 12 | DOWNLOAD_THEME_AS_FILE = 1, 13 | }; 14 | 15 | enum MESSAGE_TYPE 16 | { 17 | GET_LINK_SUCCESS = 0, 18 | GET_LINK_FAILED = 1, 19 | DOWNLAOD_SUCCESS = 2, 20 | DOWNLOAD_FAILED = 3, 21 | INVALID_MIUI_THEME_URL = 4, 22 | }; 23 | 24 | class DownloadCallBack 25 | { 26 | public: 27 | virtual void onMessage(const std::string& str, MESSAGE_TYPE type) = 0; 28 | virtual void onProgress(size_t total, size_t current) = 0; 29 | virtual void onStart() = 0; 30 | virtual void onFinished() = 0; 31 | virtual FILE* onSave(std::string filename) = 0; 32 | virtual void onURLChanged() = 0; 33 | }; 34 | 35 | class Downloader 36 | { 37 | public: 38 | Downloader(DownloadCallBack* cb); 39 | ~Downloader(); 40 | bool isDownloading(); 41 | bool setDownloadState(); 42 | void tryget(const std::string& url, TRY_GEY_TYPE type,const std::string& version); 43 | private: 44 | DownloadCallBack* mCallBack; 45 | std::atomic_bool mDownloading; 46 | std::string mUrl; 47 | std::string mDownloadLink; 48 | 49 | bool isValidMiuiThemeUrl(const std::string& url); 50 | bool checkResponseValid(const std::string& resp); 51 | }; 52 | -------------------------------------------------------------------------------- /MIUIThemeDownlaoder/HttpRequest.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BDZNH/MIUI-Theme-Download-Link-Generator/dd1c56503bad2be08a33b86f100d0054b28bb34d/MIUIThemeDownlaoder/HttpRequest.cpp -------------------------------------------------------------------------------- /MIUIThemeDownlaoder/HttpRequest.h: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "Downloader.h" 4 | 5 | bool httpRequestIme(const std::string& url,std::string& resp); 6 | bool httpRequest(const std::string& url, FILE* file, DownloadCallBack* callback); -------------------------------------------------------------------------------- /MIUIThemeDownlaoder/MIUIThemeDownlaoder.vcxproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | Debug 14 | x64 15 | 16 | 17 | Release 18 | x64 19 | 20 | 21 | 22 | 16.0 23 | Win32Proj 24 | {901a2bf5-4bbc-4228-9434-636aa90a3dd4} 25 | MIUIThemeDownlaoder 26 | 10.0 27 | 28 | 29 | 30 | Application 31 | true 32 | v143 33 | Unicode 34 | 35 | 36 | Application 37 | false 38 | v143 39 | true 40 | Unicode 41 | 42 | 43 | Application 44 | true 45 | v143 46 | Unicode 47 | 48 | 49 | Application 50 | false 51 | v143 52 | true 53 | Unicode 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | true 75 | 76 | 77 | false 78 | 79 | 80 | true 81 | 82 | 83 | false 84 | 85 | 86 | 87 | Level3 88 | true 89 | WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) 90 | true 91 | 92 | 93 | Windows 94 | true 95 | 96 | 97 | 98 | 99 | Level3 100 | true 101 | true 102 | true 103 | WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) 104 | true 105 | 106 | 107 | Windows 108 | true 109 | true 110 | true 111 | 112 | 113 | 114 | 115 | Level3 116 | true 117 | _DEBUG;_CONSOLE;%(PreprocessorDefinitions) 118 | true 119 | 120 | 121 | Windows 122 | true 123 | 124 | 125 | amd64_dpi_aware.manifest 126 | 127 | 128 | 129 | 130 | Level3 131 | true 132 | true 133 | true 134 | NDEBUG;_CONSOLE;%(PreprocessorDefinitions) 135 | true 136 | 137 | 138 | Windows 139 | true 140 | true 141 | true 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | -------------------------------------------------------------------------------- /MIUIThemeDownlaoder/MIUIThemeDownlaoder.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | 源文件 20 | 21 | 22 | 源文件 23 | 24 | 25 | 源文件 26 | 27 | 28 | 源文件 29 | 30 | 31 | 32 | 33 | 头文件 34 | 35 | 36 | 头文件 37 | 38 | 39 | 头文件 40 | 41 | 42 | 43 | 44 | 资源文件 45 | 46 | 47 | -------------------------------------------------------------------------------- /MIUIThemeDownlaoder/MIUIThemeDownlaoder.vcxproj.user: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | -------------------------------------------------------------------------------- /MIUIThemeDownlaoder/MainWindow.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BDZNH/MIUI-Theme-Download-Link-Generator/dd1c56503bad2be08a33b86f100d0054b28bb34d/MIUIThemeDownlaoder/MainWindow.cpp -------------------------------------------------------------------------------- /MIUIThemeDownlaoder/amd64_dpi_aware.manifest: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | true 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /MIUIThemeDownlaoder/appicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BDZNH/MIUI-Theme-Download-Link-Generator/dd1c56503bad2be08a33b86f100d0054b28bb34d/MIUIThemeDownlaoder/appicon.ico -------------------------------------------------------------------------------- /MIUIThemeDownlaoder/applicationicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BDZNH/MIUI-Theme-Download-Link-Generator/dd1c56503bad2be08a33b86f100d0054b28bb34d/MIUIThemeDownlaoder/applicationicon.ico -------------------------------------------------------------------------------- /MIUIThemeDownlaoder/resource.rc: -------------------------------------------------------------------------------- 1 | aaaa ICON "appicon.ico" 2 | 3 | // this icon is used with wxFrame::SetIcon() 4 | appicon ICON "applicationicon.ico" 5 | 6 | // set this to 1 if you don't want to use manifest resource (manifest resource 7 | // is needed to enable visual styles on Windows XP - see docs/msw/winxp.txt 8 | // for more information) 9 | #define wxUSE_NO_MANIFEST 0 10 | 11 | // To get DPI change events, we need to opt in into per monitor DPI support. 12 | #define wxUSE_DPI_AWARE_MANIFEST 2 13 | 14 | // this is not always needed but doesn't hurt (except making the executable 15 | // very slightly larger): this file contains the standard icons, cursors, ... 16 | #include "wx/msw/wx.rc" -------------------------------------------------------------------------------- /MIUIThemeDownlaoder/urlcoding.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BDZNH/MIUI-Theme-Download-Link-Generator/dd1c56503bad2be08a33b86f100d0054b28bb34d/MIUIThemeDownlaoder/urlcoding.cpp -------------------------------------------------------------------------------- /MIUIThemeDownlaoder/urlcoding.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BDZNH/MIUI-Theme-Download-Link-Generator/dd1c56503bad2be08a33b86f100d0054b28bb34d/MIUIThemeDownlaoder/urlcoding.h -------------------------------------------------------------------------------- /picture/mainwindow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BDZNH/MIUI-Theme-Download-Link-Generator/dd1c56503bad2be08a33b86f100d0054b28bb34d/picture/mainwindow.png -------------------------------------------------------------------------------- /readme.md: -------------------------------------------------------------------------------- 1 | [中文](readme_zh.md) 2 | 3 | # UWP version 4 | 5 | see it at [https://www.microsoft.com/store/productId/9N12V6XN5PRG](https://www.microsoft.com/store/productId/9N12V6XN5PRG) 6 | 7 | # Generate the download link of MIUI theme. 8 | ![image](picture/mainwindow.png) 9 | 10 | ## Animation 11 | 12 | ![usage](https://i.loli.net/2019/02/25/5c73d17995cd6.gif) 13 | ----- 14 | If you want to compile it by yourself. You need [libcurl](https://curl.haxx.se/download.html) installed. 15 | 16 | ----- 17 | # Dependence 18 | - [jsoncpp](https://github.com/open-source-parsers/jsoncpp) 19 | - [libcurl](https://curl.haxx.se/download.html) 20 | - [wxWidgets](https://github.com/wxWidgets/wxWidgets) 21 | it highly recommended to use vcpkg to install dependences above. 22 | 23 | ----- 24 | ##Attention: 25 | maybe there are different .mtz package for different version for one miui theme. 26 | 27 | just like this 28 | ![](https://i.loli.net/2019/02/23/5c70f140d57c3.jpg) 29 | -------------------------------------------------------------------------------- /readme_zh.md: -------------------------------------------------------------------------------- 1 | [English](readme.md) 2 | # UWP 版 3 | UWP 现已支持: [https://www.microsoft.com/store/productId/9N12V6XN5PRG](https://www.microsoft.com/store/productId/9N12V6XN5PRG) 4 | 5 | 6 | # 生成小米主题下载链接 7 | ![等待输入链接.jpg](https://i.loli.net/2019/02/23/5c70f47d135f7.jpg) 8 | ![链接解析成功.jpg](https://i.loli.net/2019/02/23/5c70f47e017e3.jpg) 9 | ![链接解析失败.jpg](https://i.loli.net/2019/02/23/5c70f47e4a856.jpg) 10 | ![轻雨主题V9版本.jpg](https://i.loli.net/2019/02/23/5c70f47e7c611.jpg) 11 | ![轻雨主题V10版本.jpg](https://i.loli.net/2019/02/23/5c70f47e7d213.jpg) 12 | 13 | ## 下载中 14 | 15 | ![下载中.jpg](https://i.loli.net/2019/02/23/5c70f47e89852.jpg) 16 | 17 | ## Animation 18 | 19 | ![usage](https://i.loli.net/2019/02/25/5c73d17995cd6.gif) 20 | 21 | ----- 22 | 如果你想自己编译的话,你需要 [libcurl](https://curl.haxx.se/download.html) 。 23 | 24 | ----- 25 | # 依赖 26 | - [rapidjson](https://github.com/Tencent/rapidjson) 27 | - [libcurl](https://curl.haxx.se/download.html) 28 | 29 | ----- 30 | 注意: 31 | 并非所有的主题都有不同版本的主题包,有些主题miui9和miui10共用一个包,区分版本下载时,请自行确定是否存在不同版本的不同主题包。 32 | 33 | 如下图: 34 | 35 | ![](https://i.loli.net/2019/02/23/5c70f140d57c3.jpg) 36 | --------------------------------------------------------------------------------