├── .gitignore ├── LICENSE ├── README.md ├── cmd ├── links.go ├── pages.go ├── root.go └── version.go ├── dl ├── init.go ├── parser.go └── run.go ├── go.mod ├── go.sum ├── m3u8 ├── downloader │ └── dowloader.go ├── m3u8.go ├── parse │ ├── m3u8.go │ └── parser.go └── tool │ ├── crypt.go │ ├── crypt_test.go │ ├── http.go │ ├── http_test.go │ ├── util.go │ └── util_test.go ├── main.go └── utils └── http.go /.gitignore: -------------------------------------------------------------------------------- 1 | # Binaries for programs and plugins 2 | *.exe 3 | *.exe~ 4 | *.dll 5 | *.so 6 | *.dylib 7 | 8 | # Test binary, build with `go test -c` 9 | *.test 10 | 11 | # Output of the go coverage tool, specifically when used with LiteIDE 12 | *.out 13 | 14 | 91dl 15 | 91videos/ 16 | 17 | .DS_Store 18 | 19 | .vscode -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # 91dl 2 | 91porn视频下载器 3 | 4 | WARNING: *小撸怡情,中撸伤身,强撸灰飞烟灭* 5 | 6 | ## 下载安装 7 | 8 | 需要go 1.16版本 9 | 10 | ```go 11 | go get -u github.com/ilove91/91dl 12 | ``` 13 | 14 | ## 使用方法 15 | 16 | ``` 17 | 91porn视频下载器 18 | WARNING: *小撸怡情,中撸伤身,强撸灰飞烟灭* 19 | 20 | 类别代码: 21 | ori-91原创 new-最新 hot-当前最热 top-本月最热 mf-收藏最多 22 | long-10分钟以上 longer-20分钟以上 md-本月讨论 tf-本月收藏 23 | rf-最近加精 hd-高清 lasttop-上月最热 24 | 25 | Usage: 26 | 91dl [command] 27 | 28 | Available Commands: 29 | help Help about any command 30 | links 按照链接下载 31 | pages 按照页面下载 32 | version 打印版本号 33 | 34 | Flags: 35 | --config string 配置文件 (默认不需要) 36 | -d, --dir string 下载到指定文件夹 (默认下载到 ./91videos/) 37 | -h, --help help for 91dl 38 | --proxy string 网络代理, 默认支持http/socks5 39 | 40 | Use "91dl [command] --help" for more information about a command. 41 | ``` 42 | 43 | ### 按照页面下载 44 | 45 | 默认下载:“当前最热”第1页下载到当前目录下91videos/ 46 | 47 | ```bash 48 | 91dl pages 49 | ``` 50 | 51 | “本月最热”第1页到第3页下载到~/mydir 52 | 53 | ```bash 54 | 91dl pages --st 1 --ed 3 -t top -d ~/mydir 55 | ``` 56 | 57 | ### 按照链接下载 58 | 59 | ```bash 60 | 91dl links -d ~/mydir -v "http://91porn.com/view_video.php?viewkey=0ff9f3af6e42aab264df&page=1&viewtype=basic&category=hot,http://91porn.com/view_video.php?viewkey=71fd50381078e11ca7eb&page=1&viewtype=basic&category=hot,http://91porn.com/view_video.php?viewkey=4a2512cf4bdf9fb8abe9&page=1&viewtype=basic&category=hot" 61 | ``` 62 | 63 | ### 使用代理 64 | 65 | 支持http/socks5 66 | 67 | ```bash 68 | 91dl pages --proxy http://127.0.0.1:1234 69 | ``` -------------------------------------------------------------------------------- /cmd/links.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2018 ilove91 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package cmd 16 | 17 | import ( 18 | "github.com/ilove91/91dl/dl" 19 | "github.com/spf13/cobra" 20 | ) 21 | 22 | var vlinks []string 23 | 24 | // linksCmd represents the links command 25 | var linksCmd = &cobra.Command{ 26 | Use: "links", 27 | Short: "按照链接下载", 28 | Long: `按照链接下载`, 29 | Run: func(cmd *cobra.Command, args []string) { 30 | dl.Initialize() 31 | dl.LinksDl(vlinks) 32 | }, 33 | } 34 | 35 | func init() { 36 | rootCmd.AddCommand(linksCmd) 37 | 38 | linksCmd.Flags().StringSliceVarP(&vlinks, "videos", "v", nil, "视频页面链接") 39 | } 40 | -------------------------------------------------------------------------------- /cmd/pages.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2018 ilove91 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package cmd 16 | 17 | import ( 18 | "github.com/ilove91/91dl/dl" 19 | "github.com/spf13/cobra" 20 | ) 21 | 22 | var p1 int 23 | var p2 int 24 | var t string 25 | 26 | // pagesCmd represents the hot command 27 | var pagesCmd = &cobra.Command{ 28 | Use: "pages", 29 | Short: "按照页面下载", 30 | Long: `按照页面下载`, 31 | Run: func(cmd *cobra.Command, args []string) { 32 | dl.Initialize() 33 | dl.PagesDl(p1, p2, t) 34 | }, 35 | } 36 | 37 | func init() { 38 | rootCmd.AddCommand(pagesCmd) 39 | 40 | pagesCmd.Flags().StringVarP(&t, "type", "t", "hot", "类别: [ori new hot rp long md tf mf rf top lasttop hd]") 41 | pagesCmd.Flags().IntVar(&p1, "st", 1, "开始页") 42 | pagesCmd.Flags().IntVar(&p2, "ed", 1, "结束页") 43 | } 44 | -------------------------------------------------------------------------------- /cmd/root.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2018 ilove91 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package cmd 16 | 17 | import ( 18 | "fmt" 19 | "os" 20 | 21 | "github.com/spf13/cobra" 22 | "github.com/spf13/viper" 23 | ) 24 | 25 | var cfgFile string 26 | 27 | // rootCmd represents the base command when called without any subcommands 28 | var rootCmd = &cobra.Command{ 29 | Use: "91dl", 30 | Short: "91porn视频下载器", 31 | Long: `91porn视频下载器 32 | WARNING: *小撸怡情,中撸伤身,强撸灰飞烟灭* 33 | 34 | 类别代码: 35 | ori-91原创 new-最新 hot-当前最热 top-本月最热 mf-收藏最多 36 | long-10分钟以上 longer-20分钟以上 md-本月讨论 tf-本月收藏 37 | rf-最近加精 hd-高清 lasttop-上月最热 38 | `, 39 | } 40 | 41 | // Execute adds all child commands to the root command and sets flags appropriately. 42 | // This is called by main.main(). It only needs to happen once to the rootCmd. 43 | func Execute() { 44 | if err := rootCmd.Execute(); err != nil { 45 | fmt.Println(err) 46 | os.Exit(1) 47 | } 48 | } 49 | 50 | func init() { 51 | cobra.OnInitialize(initConfig) 52 | 53 | rootCmd.PersistentFlags().StringVar(&cfgFile, "config", "", "配置文件 (默认不需要)") 54 | rootCmd.PersistentFlags().StringP("dir", "d", "", "下载到指定文件夹 (默认下载到 ./91videos/)") 55 | rootCmd.PersistentFlags().String("proxy", "", "网络代理, 默认支持http/socks5") 56 | viper.BindPFlags(rootCmd.PersistentFlags()) 57 | } 58 | 59 | // initConfig reads in config file and ENV variables if set. 60 | func initConfig() { 61 | if cfgFile != "" { 62 | // Use config file from the flag. 63 | viper.SetConfigFile(cfgFile) 64 | } else { 65 | // PWD directory. 66 | pwd, err := os.Getwd() 67 | if err != nil { 68 | fmt.Println(err) 69 | os.Exit(1) 70 | } 71 | 72 | // Search config in home directory with name "config" (without extension). 73 | viper.AddConfigPath(pwd) 74 | viper.SetConfigName("config") 75 | } 76 | 77 | viper.AutomaticEnv() // read in environment variables that match 78 | 79 | // If a config file is found, read it in. 80 | if err := viper.ReadInConfig(); err == nil { 81 | fmt.Println("Using config file:", viper.ConfigFileUsed()) 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /cmd/version.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2018 ilove91 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package cmd 16 | 17 | import ( 18 | "fmt" 19 | 20 | "github.com/spf13/cobra" 21 | ) 22 | 23 | var version = "2.1.2 20220211" 24 | 25 | // versionCmd represents the version command 26 | var versionCmd = &cobra.Command{ 27 | Use: "version", 28 | Short: "打印版本号", 29 | Long: `打印版本号`, 30 | Run: func(cmd *cobra.Command, args []string) { 31 | fmt.Printf("91dl v%s - for 91porn lovers\n", version) 32 | }, 33 | } 34 | 35 | func init() { 36 | rootCmd.AddCommand(versionCmd) 37 | } 38 | -------------------------------------------------------------------------------- /dl/init.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2018 ilove91 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package dl 16 | 17 | import ( 18 | "net/http" 19 | "os" 20 | 21 | "github.com/cavaliergopher/grab/v3" 22 | "github.com/ilove91/91dl/utils" 23 | "github.com/robertkrimen/otto" 24 | log "github.com/sirupsen/logrus" 25 | "github.com/spf13/viper" 26 | ) 27 | 28 | const ( 29 | jsCode = `;var encode_version = 'jsjiami.com.v5', eexda = '__0x9ff10', __0x9ff10=['w7FkXcKcwqs=','VMKAw7Fhw6Q=','w5nDlTY7w4A=','wqQ5w4pKwok=','dcKnwrTCtBg=','w45yHsO3woU=','54u75py15Y6177y0PcKk5L665a2j5pyo5b2156i677yg6L+S6K2D5pW65o6D5oqo5Lmn55i/5bSn5L21','RsOzwq5fGQ==','woHDiMK0w7HDiA==','54uS5pyR5Y6r7764wr3DleS+ouWtgeaesOW/sOeooe+/nei/ruitteaWsuaOmeaKiuS4o+eateW2i+S8ng==','bMOKwqA=','V8Knwpo=','csOIwoVsG1rCiUFU','5YmL6ZiV54qm5pyC5Y2i776Lw4LCrOS+muWssOacteW8lOeqtg==','w75fMA==','YsOUwpU=','wqzDtsKcw5fDvQ==','wqNMOGfCn13DmjTClg==','wozDisOlHHI=','GiPConNN','XcKzwrDCvSg=','U8K+wofCmcO6'];(function(_0x1f2e93,_0x60307d){var _0x1f9a0b=function(_0x35f19b){while(--_0x35f19b){_0x1f2e93['push'](_0x1f2e93['shift']());}};_0x1f9a0b(++_0x60307d);}(__0x9ff10,0x152));var _0x43d9=function(_0x13228a,_0x2ce452){_0x13228a=_0x13228a-0x0;var _0x424175=__0x9ff10[_0x13228a];if(_0x43d9['initialized']===undefined){(function(){var _0x270d2c=typeof window!=='undefined'?window:typeof process==='object'&&typeof require==='function'&&typeof global==='object'?global:this;var _0x58680b='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';_0x270d2c['atob']||(_0x270d2c['atob']=function(_0x5536e1){var _0x15e9d3=String(_0x5536e1)['replace'](/=+$/,'');for(var _0x4e6299=0x0,_0x3590d2,_0x48c90b,_0x557f6a=0x0,_0x2b086d='';_0x48c90b=_0x15e9d3['charAt'](_0x557f6a++);~_0x48c90b&&(_0x3590d2=_0x4e6299%0x4?_0x3590d2*0x40+_0x48c90b:_0x48c90b,_0x4e6299++%0x4)?_0x2b086d+=String['fromCharCode'](0xff&_0x3590d2>>(-0x2*_0x4e6299&0x6)):0x0){_0x48c90b=_0x58680b['indexOf'](_0x48c90b);}return _0x2b086d;});}());var _0x4a2d38=function(_0x1f120d,_0x1d6e11){var _0x4c36f9=[],_0x1c4b64=0x0,_0x18ce5c,_0x39c9fa='',_0x6d02b2='';_0x1f120d=atob(_0x1f120d);for(var _0x13b203=0x0,_0x24d88b=_0x1f120d['length'];_0x13b203<_0x24d88b;_0x13b203++){_0x6d02b2+='%'+('00'+_0x1f120d['charCodeAt'](_0x13b203)['toString'](0x10))['slice'](-0x2);}_0x1f120d=decodeURIComponent(_0x6d02b2);for(var _0x1f76f3=0x0;_0x1f76f3<0x100;_0x1f76f3++){_0x4c36f9[_0x1f76f3]=_0x1f76f3;}for(_0x1f76f3=0x0;_0x1f76f3<0x100;_0x1f76f3++){_0x1c4b64=(_0x1c4b64+_0x4c36f9[_0x1f76f3]+_0x1d6e11['charCodeAt'](_0x1f76f3%_0x1d6e11['length']))%0x100;_0x18ce5c=_0x4c36f9[_0x1f76f3];_0x4c36f9[_0x1f76f3]=_0x4c36f9[_0x1c4b64];_0x4c36f9[_0x1c4b64]=_0x18ce5c;}_0x1f76f3=0x0;_0x1c4b64=0x0;for(var _0x2b6a92=0x0;_0x2b6a92<_0x1f120d['length'];_0x2b6a92++){_0x1f76f3=(_0x1f76f3+0x1)%0x100;_0x1c4b64=(_0x1c4b64+_0x4c36f9[_0x1f76f3])%0x100;_0x18ce5c=_0x4c36f9[_0x1f76f3];_0x4c36f9[_0x1f76f3]=_0x4c36f9[_0x1c4b64];_0x4c36f9[_0x1c4b64]=_0x18ce5c;_0x39c9fa+=String['fromCharCode'](_0x1f120d['charCodeAt'](_0x2b6a92)^_0x4c36f9[(_0x4c36f9[_0x1f76f3]+_0x4c36f9[_0x1c4b64])%0x100]);}return _0x39c9fa;};_0x43d9['rc4']=_0x4a2d38;_0x43d9['data']={};_0x43d9['initialized']=!![];}var _0x302f80=_0x43d9['data'][_0x13228a];if(_0x302f80===undefined){if(_0x43d9['once']===undefined){_0x43d9['once']=!![];}_0x424175=_0x43d9['rc4'](_0x424175,_0x2ce452);_0x43d9['data'][_0x13228a]=_0x424175;}else{_0x424175=_0x302f80;}return _0x424175;};function strencode2(_0x4f0d7a){var _0x4c6de5={'Anfny':function _0x4f6a21(_0x51d0ce,_0x5a5f36){return _0x51d0ce(_0x5a5f36);}};return _0x4c6de5[_0x43d9('0x0','fo#E')](unescape,_0x4f0d7a);};(function(_0x17883e,_0x4a42d3,_0xe4080c){var _0x301ffc={'lPNHL':function _0x1c947e(_0x4d57b6,_0x51f6a5){return _0x4d57b6!==_0x51f6a5;},'EPdUx':function _0x55f4cc(_0x34b7bc,_0x9f930c){return _0x34b7bc===_0x9f930c;},'kjFfJ':'jsjiami.com.v5','DFsBH':function _0x5f08ac(_0x1e6fa1,_0x4c0aef){return _0x1e6fa1+_0x4c0aef;},'akiuH':_0x43d9('0x1','KYjt'),'VtfeI':function _0x4f3b7b(_0x572344,_0x5f0cde){return _0x572344(_0x5f0cde);},'Deqmq':_0x43d9('0x2','oYRG'),'oKQDc':_0x43d9('0x3','i^vo'),'UMyIE':_0x43d9('0x4','oYRG'),'lRwKx':function _0x5b71b4(_0x163a75,_0x4d3998){return _0x163a75===_0x4d3998;},'TOBCR':function _0x314af8(_0x3e6efe,_0x275766){return _0x3e6efe+_0x275766;},'AUOVd':_0x43d9('0x5','lALy')};_0xe4080c='al';try{if('EqF'!==_0x43d9('0x6','xSW]')){_0xe4080c+=_0x43d9('0x7','oYRG');_0x4a42d3=encode_version;if(!(_0x301ffc[_0x43d9('0x8','fo#E')](typeof _0x4a42d3,_0x43d9('0x9','*oMH'))&&_0x301ffc[_0x43d9('0xa','ov6D')](_0x4a42d3,_0x301ffc[_0x43d9('0xb','3k]D')]))){_0x17883e[_0xe4080c](_0x301ffc[_0x43d9('0xc','@&#[')]('ɾ��',_0x301ffc[_0x43d9('0xd','i^vo')]));}}else{return _0x301ffc[_0x43d9('0xe','rvlM')](unescape,input);}}catch(_0x23e6c5){if('svo'!==_0x301ffc[_0x43d9('0xf','TpCD')]){_0x17883e[_0xe4080c]('ɾ���汾�ţ�js�ᶨ�ڵ���');}else{_0xe4080c='al';try{_0xe4080c+=_0x301ffc[_0x43d9('0x10','doK*')];_0x4a42d3=encode_version;if(!(_0x301ffc[_0x43d9('0x11','ZRZ4')](typeof _0x4a42d3,_0x301ffc['UMyIE'])&&_0x301ffc[_0x43d9('0x12','@&#[')](_0x4a42d3,_0x301ffc['kjFfJ']))){_0x17883e[_0xe4080c](_0x301ffc[_0x43d9('0x13','KYjt')]('ɾ��',_0x43d9('0x14','xSW]')));}}catch(_0x4202f6){_0x17883e[_0xe4080c](_0x301ffc[_0x43d9('0x15','oYRG')]);}}}}(window));;encode_version = 'jsjiami.com.v5';` 30 | ) 31 | 32 | var ( 33 | destDir string 34 | client *http.Client 35 | grabClient *grab.Client 36 | jsvm *otto.Otto 37 | ) 38 | 39 | // Initialize on root 40 | func Initialize() { 41 | log.SetFormatter( 42 | &log.TextFormatter{ 43 | ForceColors: true, 44 | FullTimestamp: true, 45 | TimestampFormat: "2006-01-02 15:04:05", 46 | }, 47 | ) 48 | 49 | // client init 50 | client = utils.GetNewHttpClient(10) 51 | grabClient = grab.NewClient() 52 | grabClient.HTTPClient = utils.GetNewHttpClient(0) 53 | grabClient.UserAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36" 54 | 55 | // saving dir 56 | destDir = viper.GetString("dir") 57 | if destDir == "" { 58 | destDir = "91videos" 59 | } 60 | if _, err := os.Stat(destDir); os.IsNotExist(err) { 61 | if err := os.MkdirAll(destDir, 0700); err != nil { 62 | log.Fatalf("Create Dir Error: %s", err) 63 | } 64 | } 65 | 66 | // js vm 67 | jsvm = otto.New() 68 | jsvm.Run(jsCode) 69 | 70 | log.Info("======================================") 71 | proxy := viper.GetString("proxy") 72 | if proxy != "" { 73 | log.Infof("Proxy on: %v", proxy) 74 | } 75 | log.Infof("Saving Videos to: %s", destDir) 76 | } 77 | -------------------------------------------------------------------------------- /dl/parser.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2018 ilove91 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package dl 16 | 17 | import ( 18 | "fmt" 19 | "net/http" 20 | "net/url" 21 | "regexp" 22 | "strings" 23 | 24 | "github.com/Pallinder/go-randomdata" 25 | "github.com/PuerkitoBio/goquery" 26 | log "github.com/sirupsen/logrus" 27 | ) 28 | 29 | type video struct { 30 | webURL string 31 | title string 32 | videoSrc string 33 | mediaType string 34 | } 35 | 36 | func getHTML(u string) (*goquery.Document, error) { 37 | req := buildReq(u) 38 | 39 | resp, err := client.Do(req) 40 | if err != nil { 41 | return nil, err 42 | } 43 | 44 | doc, err := goquery.NewDocumentFromReader(resp.Body) 45 | if err != nil { 46 | return nil, err 47 | } 48 | return doc, nil 49 | } 50 | 51 | func parsePage(u string) []string { 52 | doc, err := getHTML(u) 53 | if err != nil { 54 | log.Fatal(err) 55 | } 56 | 57 | var links []string 58 | doc.Find(".videos-text-align a").Each(func(index int, item *goquery.Selection) { 59 | link, _ := item.Attr("href") 60 | log.Infof("%3d url: %v", index+1, link) 61 | if strings.HasPrefix(link, "http://91porn.com/view_video.php?viewkey=") { 62 | links = append(links, link) 63 | } 64 | }) 65 | return links 66 | } 67 | 68 | func parseVideo(u string) (*video, error) { 69 | doc, err := getHTML(u) 70 | if err != nil { 71 | return nil, err 72 | } 73 | 74 | title := doc.Find("title").Text() 75 | title = strings.ReplaceAll(title, ".", " ") 76 | title = strings.ReplaceAll(title, "Chinese homemade video", "") 77 | title = strings.TrimSpace(title) 78 | title = strings.ReplaceAll(title, "\n", "") 79 | 80 | author := doc.Find(".title-yakov a span").Text() 81 | author = strings.TrimSpace(author) 82 | 83 | encrypted := doc.Find("video").Find("script").Text() 84 | if encrypted == "" { 85 | return nil, fmt.Errorf("found no encrypt str") 86 | } 87 | compile := regexp.MustCompile(`document.write\(strencode2\("(.*)"`) 88 | submatch := compile.FindAllStringSubmatch(encrypted, -1) 89 | if len(submatch) != 1 { 90 | return nil, fmt.Errorf("parse encrypt str err, encrypt str: %s, submatch: %s", encrypted, submatch) 91 | } 92 | encrypted = submatch[0][1] 93 | 94 | decrypted, err := jsvm.Call("strencode2", nil, encrypted) 95 | if err != nil { 96 | return nil, fmt.Errorf("js decrypt err: %v, encrypt str: %v", err, encrypted) 97 | } 98 | 99 | compile = regexp.MustCompile(`", " ", "|", " ") 112 | title = r.Replace(title) 113 | 114 | return &video{u, title, videoSrc, mediaType}, nil 115 | } 116 | 117 | func parseMedia(src string) (vNumber, mediaType string, err error) { 118 | // m3u8 119 | compile := regexp.MustCompile(`m3u8/[\d]*/([\d]*).m3u8`) 120 | submatch := compile.FindAllStringSubmatch(src, -1) 121 | if len(submatch) == 1 { 122 | vNumber := submatch[0][1] 123 | return vNumber, "m3u8", nil 124 | } 125 | 126 | // mp4 127 | compile = regexp.MustCompile(`mp43/([\d]*).mp4\?st=.*`) 128 | submatch = compile.FindAllStringSubmatch(src, -1) 129 | if len(submatch) == 1 { 130 | vNumber := submatch[0][1] 131 | return vNumber, "mp4", nil 132 | } 133 | 134 | return "", "", fmt.Errorf("no media found in video src: %v", src) 135 | } 136 | 137 | func buildReq(u string) *http.Request { 138 | req, err := http.NewRequest("GET", u, nil) 139 | if err != nil { 140 | log.Fatal(err) 141 | } 142 | 143 | req.Header.Set("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8") 144 | req.Header.Set("Accept-Encoding", "") 145 | req.Header.Set("Accept-Language", "zh-CN,zh;q=0.9,en;q=0.8") 146 | req.Header.Set("Cache-Control", "max-age=0") 147 | req.Header.Set("Connection", "keep-alive") 148 | req.Header.Set("Host", "91porn.com") 149 | req.Header.Set("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36") 150 | req.Header.Set("X-Forwarded-For", randomdata.IpV4Address()) 151 | 152 | return req 153 | } 154 | -------------------------------------------------------------------------------- /dl/run.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2018 ilove91 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package dl 16 | 17 | import ( 18 | "fmt" 19 | "os" 20 | "path/filepath" 21 | "time" 22 | 23 | "github.com/cavaliergopher/grab/v3" 24 | "github.com/ilove91/91dl/m3u8" 25 | "github.com/schollz/progressbar/v3" 26 | log "github.com/sirupsen/logrus" 27 | ) 28 | 29 | var baseURL = "http://91porn.com" 30 | 31 | // LinksDl download by links 32 | func LinksDl(vlinks []string) { 33 | var vs []*video 34 | for _, u := range vlinks { 35 | v, err := parseVideo(u) 36 | if err != nil { 37 | log.Errorf("video parse err: %v, url: %v", err, u) 38 | continue 39 | } 40 | vs = append(vs, v) 41 | } 42 | 43 | log.Infof("Total videos: %d", len(vs)) 44 | 45 | for i, v := range vs { 46 | if _, err := os.Stat(filepath.Join(destDir, v.title+".mp4")); os.IsNotExist(err) { 47 | download(i, v) 48 | } else { 49 | log.Infof("Exists %3d %s ...", i+1, v.title) 50 | } 51 | } 52 | } 53 | 54 | // PagesDl download by pages 55 | // category: new hot rp long md tf mf rf top top-1 hd 56 | func PagesDl(p1 int, p2 int, t string) { 57 | if p1 > p2 { 58 | p1 = p2 59 | } 60 | log.Infof("Download category %s from page %d to %d", t, p1, p2) 61 | log.Info("======================================") 62 | 63 | var url string 64 | for i := p1; i <= p2; i++ { 65 | switch t { 66 | case "new": 67 | url = fmt.Sprintf("%s/v.php?next=watch&page=%d", baseURL, i) 68 | case "lasttop": 69 | url = fmt.Sprintf("%s/v.php?category=top&m=-1&viewtype=basic&page=%d", baseURL, i) 70 | default: 71 | url = fmt.Sprintf("%s/v.php?category=%s&viewtype=basic&page=%d", baseURL, t, i) 72 | } 73 | log.Infof("Category %s page %d url: %v", t, i, url) 74 | vl := parsePage(url) 75 | log.Infof("Downloading category %s page %d ...", t, i) 76 | LinksDl(vl) 77 | log.Info("======================================") 78 | } 79 | } 80 | 81 | func download(i int, v *video) { 82 | toFile := filepath.Join(destDir, v.title+".mp4") 83 | log.Infof("Downloading %3d %s ...", i+1, v.title) 84 | 85 | if v.mediaType == "m3u8" { 86 | err := m3u8.Download(v.videoSrc, v.title, destDir, 25) 87 | if err != nil { 88 | log.Error(err) 89 | return 90 | } 91 | } 92 | 93 | if v.mediaType == "mp4" { 94 | tmpFile := toFile + ".tmp" 95 | req, _ := grab.NewRequest(tmpFile, v.videoSrc) 96 | resp := grabClient.Do(req) 97 | 98 | // start UI loop 99 | t := time.NewTicker(1 * time.Second) 100 | defer t.Stop() 101 | 102 | bar := progressbar.DefaultBytes(resp.Size()) 103 | 104 | Loop: 105 | for { 106 | select { 107 | case <-t.C: 108 | bar.Set64(resp.BytesComplete()) 109 | case <-resp.Done: 110 | bar.Set64(resp.BytesComplete()) 111 | if resp.BytesComplete() == resp.Size() { 112 | bar.Finish() 113 | } 114 | break Loop 115 | } 116 | } 117 | 118 | // check for errors 119 | if err := resp.Err(); err != nil { 120 | log.Errorf("Download failed: %v, v: %v", err, v.title) 121 | return 122 | } 123 | os.Rename(tmpFile, toFile) 124 | } 125 | 126 | log.Info("[Done] ", toFile) 127 | } 128 | -------------------------------------------------------------------------------- /go.mod: -------------------------------------------------------------------------------- 1 | module github.com/ilove91/91dl 2 | 3 | go 1.16 4 | 5 | require ( 6 | github.com/Pallinder/go-randomdata v1.2.0 7 | github.com/PuerkitoBio/goquery v1.6.1 8 | github.com/cavaliergopher/grab/v3 v3.0.1 9 | github.com/konsorten/go-windows-terminal-sequences v1.0.3 // indirect 10 | github.com/robertkrimen/otto v0.0.0-20200922221731-ef014fd054ac 11 | github.com/schollz/progressbar/v3 v3.8.6 12 | github.com/sirupsen/logrus v1.2.0 13 | github.com/spf13/cobra v1.1.3 14 | github.com/spf13/viper v1.7.1 15 | golang.org/x/crypto v0.0.0-20220210151621-f4118a5b28e2 // indirect 16 | golang.org/x/sys v0.0.0-20220209214540-3681064d5158 // indirect 17 | gopkg.in/sourcemap.v1 v1.0.5 // indirect 18 | ) 19 | -------------------------------------------------------------------------------- /go.sum: -------------------------------------------------------------------------------- 1 | cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= 2 | cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= 3 | cloud.google.com/go v0.38.0/go.mod h1:990N+gfupTy94rShfmMCWGDn0LpTmnzTp2qbd1dvSRU= 4 | cloud.google.com/go v0.44.1/go.mod h1:iSa0KzasP4Uvy3f1mN/7PiObzGgflwredwwASm/v6AU= 5 | cloud.google.com/go v0.44.2/go.mod h1:60680Gw3Yr4ikxnPRS/oxxkBccT6SA1yMk63TGekxKY= 6 | cloud.google.com/go v0.45.1/go.mod h1:RpBamKRgapWJb87xiFSdk4g1CME7QZg3uwTez+TSTjc= 7 | cloud.google.com/go v0.46.3/go.mod h1:a6bKKbmY7er1mI7TEI4lsAkts/mkhTSZK8w33B4RAg0= 8 | cloud.google.com/go/bigquery v1.0.1/go.mod h1:i/xbL2UlR5RvWAURpBYZTtm/cXjCha9lbfbpx4poX+o= 9 | cloud.google.com/go/datastore v1.0.0/go.mod h1:LXYbyblFSglQ5pkeyhO+Qmw7ukd3C+pD7TKLgZqpHYE= 10 | cloud.google.com/go/firestore v1.1.0/go.mod h1:ulACoGHTpvq5r8rxGJ4ddJZBZqakUQqClKRT5SZwBmk= 11 | cloud.google.com/go/pubsub v1.0.1/go.mod h1:R0Gpsv3s54REJCy4fxDixWD93lHJMoZTyQ2kNxGRt3I= 12 | cloud.google.com/go/storage v1.0.0/go.mod h1:IhtSnM/ZTZV8YYJWCY8RULGVqBDmpoyjwiyrjsg+URw= 13 | dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= 14 | github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ= 15 | github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= 16 | github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= 17 | github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU= 18 | github.com/Pallinder/go-randomdata v1.2.0 h1:DZ41wBchNRb/0GfsePLiSwb0PHZmT67XY00lCDlaYPg= 19 | github.com/Pallinder/go-randomdata v1.2.0/go.mod h1:yHmJgulpD2Nfrm0cR9tI/+oAgRqCQQixsA8HyRZfV9Y= 20 | github.com/PuerkitoBio/goquery v1.6.1 h1:FgjbQZKl5HTmcn4sKBgvx8vv63nhyhIpv7lJpFGCWpk= 21 | github.com/PuerkitoBio/goquery v1.6.1/go.mod h1:GsLWisAFVj4WgDibEWF4pvYnkVQBpKBKeU+7zCJoLcc= 22 | github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= 23 | github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= 24 | github.com/andybalholm/cascadia v1.1.0 h1:BuuO6sSfQNFRu1LppgbD25Hr2vLYW25JvxHs5zzsLTo= 25 | github.com/andybalholm/cascadia v1.1.0/go.mod h1:GsXiBklL0woXo1j/WYWtSYYC4ouU9PqHO0sqidkEA4Y= 26 | github.com/armon/circbuf v0.0.0-20150827004946-bbbad097214e/go.mod h1:3U/XgcO3hCbHZ8TKRvWD2dDTCfh9M9ya+I9JpbB7O8o= 27 | github.com/armon/go-metrics v0.0.0-20180917152333-f0300d1749da/go.mod h1:Q73ZrmVTwzkszR9V5SSuryQ31EELlFMUz1kKyl939pY= 28 | github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8= 29 | github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= 30 | github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8= 31 | github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs= 32 | github.com/bketelsen/crypt v0.0.3-0.20200106085610-5cbc8cc4026c/go.mod h1:MKsuJmJgSg28kpZDP6UIiPt0e0Oz0kqKNGyRaWEPv84= 33 | github.com/cavaliergopher/grab/v3 v3.0.1 h1:4z7TkBfmPjmLAAmkkAZNX/6QJ1nNFdv3SdIHXju0Fr4= 34 | github.com/cavaliergopher/grab/v3 v3.0.1/go.mod h1:1U/KNnD+Ft6JJiYoYBAimKH2XrYptb8Kl3DFGmsjpq4= 35 | github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc= 36 | github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= 37 | github.com/coreos/bbolt v1.3.2/go.mod h1:iRUV2dpdMOn7Bo10OQBFzIJO9kkE559Wcmn+qkEiiKk= 38 | github.com/coreos/etcd v3.3.13+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE= 39 | github.com/coreos/go-semver v0.3.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= 40 | github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= 41 | github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA= 42 | github.com/cpuguy83/go-md2man/v2 v2.0.0/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU= 43 | github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= 44 | github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= 45 | github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= 46 | github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ= 47 | github.com/dgryski/go-sip13 v0.0.0-20181026042036-e10d5fee7954/go.mod h1:vAd38F8PWV+bWy6jNmig1y/TA+kYO4g3RSRF0IAv0no= 48 | github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= 49 | github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV9I= 50 | github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= 51 | github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= 52 | github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU= 53 | github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= 54 | github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE= 55 | github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk= 56 | github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= 57 | github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= 58 | github.com/gogo/protobuf v1.2.1/go.mod h1:hp+jE20tsWTFYpLwKvXlhS1hjn+gTNwPg2I6zVXpSg4= 59 | github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= 60 | github.com/golang/groupcache v0.0.0-20190129154638-5b532d6fd5ef/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= 61 | github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= 62 | github.com/golang/mock v1.2.0/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= 63 | github.com/golang/mock v1.3.1/go.mod h1:sBzyDLLjw3U8JLTeZvSv8jJB+tU5PVekmnlKIyFUx0Y= 64 | github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= 65 | github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= 66 | github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= 67 | github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= 68 | github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= 69 | github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= 70 | github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= 71 | github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs= 72 | github.com/google/pprof v0.0.0-20181206194817-3ea8567a2e57/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= 73 | github.com/google/pprof v0.0.0-20190515194954-54271f7e092f/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= 74 | github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= 75 | github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg= 76 | github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk= 77 | github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1 h1:EGx4pi6eqNxGaHF6qqu48+N2wcFQ5qg5FXgOdqsJ5d8= 78 | github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= 79 | github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= 80 | github.com/grpc-ecosystem/go-grpc-middleware v1.0.0/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs= 81 | github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0/go.mod h1:8NvIoxWQoOIhqOTXgfV/d3M/q6VIi02HzZEHgUlZvzk= 82 | github.com/grpc-ecosystem/grpc-gateway v1.9.0/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY= 83 | github.com/hashicorp/consul/api v1.1.0/go.mod h1:VmuI/Lkw1nC05EYQWNKwWGbkg+FbDBtguAZLlVdkD9Q= 84 | github.com/hashicorp/consul/sdk v0.1.1/go.mod h1:VKf9jXwCTEY1QZP2MOLRhb5i/I/ssyNV1vwHyQBF0x8= 85 | github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= 86 | github.com/hashicorp/go-cleanhttp v0.5.1/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80= 87 | github.com/hashicorp/go-immutable-radix v1.0.0/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60= 88 | github.com/hashicorp/go-msgpack v0.5.3/go.mod h1:ahLV/dePpqEmjfWmKiqvPkv/twdG7iPBM1vqhUKIvfM= 89 | github.com/hashicorp/go-multierror v1.0.0/go.mod h1:dHtQlpGsu+cZNNAkkCN/P3hoUDHhCYQXV3UM06sGGrk= 90 | github.com/hashicorp/go-rootcerts v1.0.0/go.mod h1:K6zTfqpRlCUIjkwsN4Z+hiSfzSTQa6eBIzfwKfwNnHU= 91 | github.com/hashicorp/go-sockaddr v1.0.0/go.mod h1:7Xibr9yA9JjQq1JpNB2Vw7kxv8xerXegt+ozgdvDeDU= 92 | github.com/hashicorp/go-syslog v1.0.0/go.mod h1:qPfqrKkXGihmCqbJM2mZgkZGvKG1dFdvsLplgctolz4= 93 | github.com/hashicorp/go-uuid v1.0.0/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= 94 | github.com/hashicorp/go-uuid v1.0.1/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= 95 | github.com/hashicorp/go.net v0.0.1/go.mod h1:hjKkEWcCURg++eb33jQU7oqQcI9XDCnUzHA0oac0k90= 96 | github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= 97 | github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= 98 | github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4= 99 | github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ= 100 | github.com/hashicorp/logutils v1.0.0/go.mod h1:QIAnNjmIWmVIIkWDTG1z5v++HQmx9WQRO+LraFDTW64= 101 | github.com/hashicorp/mdns v1.0.0/go.mod h1:tL+uN++7HEJ6SQLQ2/p+z2pH24WQKWjBPkE0mNTz8vQ= 102 | github.com/hashicorp/memberlist v0.1.3/go.mod h1:ajVTdAv/9Im8oMAAj5G31PhhMCZJV2pPBoIllUwCN7I= 103 | github.com/hashicorp/serf v0.8.2/go.mod h1:6hOLApaqBFA1NXqRQAsxw9QxuDEvNxSQRwA/JwenrHc= 104 | github.com/inconshreveable/mousetrap v1.0.0 h1:Z8tu5sraLXCXIcARxBp/8cbvlwVa7Z1NHg9XEKhtSvM= 105 | github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= 106 | github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo= 107 | github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= 108 | github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU= 109 | github.com/jtolds/gls v4.20.0+incompatible h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7C0MuV77Wo= 110 | github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU= 111 | github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w= 112 | github.com/k0kubun/go-ansi v0.0.0-20180517002512-3bf9e2903213/go.mod h1:vNUNkEQ1e29fT/6vq2aBdFsgNPmy8qMdSay1npru+Sw= 113 | github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvWXihfKN4Q= 114 | github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= 115 | github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= 116 | github.com/konsorten/go-windows-terminal-sequences v1.0.3 h1:CE8S1cTafDpPvMhIxNJKvHsGVBgn1xWYf1NbHQhywc8= 117 | github.com/konsorten/go-windows-terminal-sequences v1.0.3/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= 118 | github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc= 119 | github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI= 120 | github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= 121 | github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= 122 | github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= 123 | github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= 124 | github.com/magiconair/properties v1.8.1 h1:ZC2Vc7/ZFkGmsVC9KvOjumD+G5lXy2RtTKyzRKO2BQ4= 125 | github.com/magiconair/properties v1.8.1/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ= 126 | github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU= 127 | github.com/mattn/go-isatty v0.0.3/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= 128 | github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94= 129 | github.com/mattn/go-runewidth v0.0.13 h1:lTGmDsbAYt5DmK6OnoV7EuIF1wEIFAcxld6ypU4OSgU= 130 | github.com/mattn/go-runewidth v0.0.13/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= 131 | github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= 132 | github.com/miekg/dns v1.0.14/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3Nrg= 133 | github.com/mitchellh/cli v1.0.0/go.mod h1:hNIlj7HEI86fIcpObd7a0FcrxTWetlwJDGcceTlRvqc= 134 | github.com/mitchellh/colorstring v0.0.0-20190213212951-d06e56a500db h1:62I3jR2EmQ4l5rM/4FEfDWcRD+abF5XlKShorW5LRoQ= 135 | github.com/mitchellh/colorstring v0.0.0-20190213212951-d06e56a500db/go.mod h1:l0dey0ia/Uv7NcFFVbCLtqEBQbrT4OCwCSKTEv6enCw= 136 | github.com/mitchellh/go-homedir v1.0.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= 137 | github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= 138 | github.com/mitchellh/go-testing-interface v1.0.0/go.mod h1:kRemZodwjscx+RGhAo8eIhFbs2+BFgRtFPeD/KE+zxI= 139 | github.com/mitchellh/gox v0.4.0/go.mod h1:Sd9lOJ0+aimLBi73mGofS1ycjY8lL3uZM3JPS42BGNg= 140 | github.com/mitchellh/iochan v1.0.0/go.mod h1:JwYml1nuB7xOzsp52dPpHFffvOCDupsG0QubkSMEySY= 141 | github.com/mitchellh/mapstructure v0.0.0-20160808181253-ca63d7c062ee/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= 142 | github.com/mitchellh/mapstructure v1.1.2 h1:fmNYVwqnSfB9mZU6OS2O6GsXM+wcskZDuKQzvN1EDeE= 143 | github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= 144 | github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= 145 | github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= 146 | github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= 147 | github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn4U= 148 | github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= 149 | github.com/pelletier/go-toml v1.2.0 h1:T5zMGML61Wp+FlcbWjRDT7yAxhJNAiPPLOFECq181zc= 150 | github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic= 151 | github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= 152 | github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= 153 | github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= 154 | github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= 155 | github.com/posener/complete v1.1.1/go.mod h1:em0nMJCgc9GFtwrmVmEMR/ZL6WyhyjMBndrE9hABlRI= 156 | github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw= 157 | github.com/prometheus/client_golang v0.9.3/go.mod h1:/TN21ttK/J9q6uSwhBd54HahCDft0ttaMvbicHlPoso= 158 | github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= 159 | github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= 160 | github.com/prometheus/common v0.0.0-20181113130724-41aa239b4cce/go.mod h1:daVV7qP5qjZbuso7PdcryaAu0sAZbrN9i7WWcTMWvro= 161 | github.com/prometheus/common v0.4.0/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4= 162 | github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= 163 | github.com/prometheus/procfs v0.0.0-20190507164030-5867b95ac084/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= 164 | github.com/prometheus/tsdb v0.7.1/go.mod h1:qhTCs0VvXwvX/y3TZrWD7rabWM+ijKTux40TwIPHuXU= 165 | github.com/rivo/uniseg v0.2.0 h1:S1pD9weZBuJdFmowNwbpi7BJ8TNftyUImj/0WQi72jY= 166 | github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc= 167 | github.com/robertkrimen/otto v0.0.0-20200922221731-ef014fd054ac h1:kYPjbEN6YPYWWHI6ky1J813KzIq/8+Wg4TO4xU7A/KU= 168 | github.com/robertkrimen/otto v0.0.0-20200922221731-ef014fd054ac/go.mod h1:xvqspoSXJTIpemEonrMDFq6XzwHYYgToXWj5eRX1OtY= 169 | github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg= 170 | github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= 171 | github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= 172 | github.com/ryanuber/columnize v0.0.0-20160712163229-9b3edd62028f/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts= 173 | github.com/schollz/progressbar/v3 v3.8.6 h1:QruMUdzZ1TbEP++S1m73OqRJk20ON11m6Wqv4EoGg8c= 174 | github.com/schollz/progressbar/v3 v3.8.6/go.mod h1:W5IEwbJecncFGBvuEh4A7HT1nZZ6WNIL2i3qbnI0WKY= 175 | github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc= 176 | github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc= 177 | github.com/sirupsen/logrus v1.2.0 h1:juTguoYk5qI21pwyTXY3B3Y5cOTH3ZUyZCg1v/mihuo= 178 | github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= 179 | github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d h1:zE9ykElWQ6/NYmHa3jpm/yHnI4xSofP+UP6SpjHcSeM= 180 | github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc= 181 | github.com/smartystreets/goconvey v1.6.4 h1:fv0U8FUIMPNf1L9lnHLvLhgicrIVChEkdzIKYqbNC9s= 182 | github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA= 183 | github.com/soheilhy/cmux v0.1.4/go.mod h1:IM3LyeVVIOuxMH7sFAkER9+bJ4dT7Ms6E4xg4kGIyLM= 184 | github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA= 185 | github.com/spf13/afero v1.1.2 h1:m8/z1t7/fwjysjQRYbP0RD+bUIF/8tJwPdEZsI83ACI= 186 | github.com/spf13/afero v1.1.2/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ= 187 | github.com/spf13/cast v1.3.0 h1:oget//CVOEoFewqQxwr0Ej5yjygnqGkvggSE/gB35Q8= 188 | github.com/spf13/cast v1.3.0/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE= 189 | github.com/spf13/cobra v1.1.3 h1:xghbfqPkxzxP3C/f3n5DdpAbdKLj4ZE4BWQI362l53M= 190 | github.com/spf13/cobra v1.1.3/go.mod h1:pGADOWyqRD/YMrPZigI/zbliZ2wVD/23d+is3pSWzOo= 191 | github.com/spf13/jwalterweatherman v1.0.0 h1:XHEdyB+EcvlqZamSM4ZOMGlc93t6AcsBEu9Gc1vn7yk= 192 | github.com/spf13/jwalterweatherman v1.0.0/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb68N+wFjFa4jdeBTo= 193 | github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= 194 | github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= 195 | github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= 196 | github.com/spf13/viper v1.7.0/go.mod h1:8WkrPz2fc9jxqZNCJI/76HCieCp4Q8HaLFoCha5qpdg= 197 | github.com/spf13/viper v1.7.1 h1:pM5oEahlgWv/WnHXpgbKz7iLIxRf65tye2Ci+XFK5sk= 198 | github.com/spf13/viper v1.7.1/go.mod h1:8WkrPz2fc9jxqZNCJI/76HCieCp4Q8HaLFoCha5qpdg= 199 | github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= 200 | github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= 201 | github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= 202 | github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q= 203 | github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= 204 | github.com/subosito/gotenv v1.2.0 h1:Slr1R9HxAlEKefgq5jn9U+DnETlIUa6HfgEzj0g5d7s= 205 | github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw= 206 | github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= 207 | github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU= 208 | go.etcd.io/bbolt v1.3.2/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU= 209 | go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU= 210 | go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8= 211 | go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= 212 | go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0= 213 | go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q= 214 | golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= 215 | golang.org/x/crypto v0.0.0-20181029021203-45a5f77698d3/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= 216 | golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= 217 | golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= 218 | golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= 219 | golang.org/x/crypto v0.0.0-20220131195533-30dcbda58838/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= 220 | golang.org/x/crypto v0.0.0-20220210151621-f4118a5b28e2 h1:XdAboW3BNMv9ocSCOk/u1MFioZGzCNkiJZ19v9Oe3Ig= 221 | golang.org/x/crypto v0.0.0-20220210151621-f4118a5b28e2/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= 222 | golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= 223 | golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= 224 | golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= 225 | golang.org/x/exp v0.0.0-20190829153037-c13cbed26979/go.mod h1:86+5VVa7VpoJ4kLfm080zCjGlMRFzhUhsZKEZO7MGek= 226 | golang.org/x/exp v0.0.0-20191030013958-a1ab85dbe136/go.mod h1:JXzH8nQsPlswgeRAPE3MuO9GYsAcnJvJ4vnMwN/5qkY= 227 | golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js= 228 | golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= 229 | golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= 230 | golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= 231 | golang.org/x/lint v0.0.0-20190301231843-5614ed5bae6f/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= 232 | golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= 233 | golang.org/x/lint v0.0.0-20190409202823-959b441ac422/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= 234 | golang.org/x/lint v0.0.0-20190909230951-414d861bb4ac/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= 235 | golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= 236 | golang.org/x/mobile v0.0.0-20190312151609-d3739f865fa6/go.mod h1:z+o9i4GpDbdi3rU15maQ/Ox0txvL9dWGYEHz965HBQE= 237 | golang.org/x/mobile v0.0.0-20190719004257-d2bd2a29d028/go.mod h1:E/iHnbuqvinMTCcRqshq8CkpyQDoeVncDDYHnLhea+o= 238 | golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc= 239 | golang.org/x/mod v0.1.0/go.mod h1:0QHyrYULN0/3qlju5TqG8bIK38QM8yzMo5ekMj3DlcY= 240 | golang.org/x/net v0.0.0-20180218175443-cbe0f9307d01/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= 241 | golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= 242 | golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= 243 | golang.org/x/net v0.0.0-20181023162649-9b4f9f5ad519/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= 244 | golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= 245 | golang.org/x/net v0.0.0-20181201002055-351d144fa1fc/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= 246 | golang.org/x/net v0.0.0-20181220203305-927f97764cc3/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= 247 | golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= 248 | golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= 249 | golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= 250 | golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= 251 | golang.org/x/net v0.0.0-20190501004415-9ce7a6920f09/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= 252 | golang.org/x/net v0.0.0-20190503192946-f4e77d36d62c/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= 253 | golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= 254 | golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= 255 | golang.org/x/net v0.0.0-20200202094626-16171245cfb2/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= 256 | golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2 h1:CIJ76btIcR3eFI5EgSo6k1qKw9KJexJuRLI9G7Hp5wE= 257 | golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= 258 | golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= 259 | golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= 260 | golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= 261 | golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= 262 | golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= 263 | golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= 264 | golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= 265 | golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= 266 | golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= 267 | golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= 268 | golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= 269 | golang.org/x/sys v0.0.0-20181026203630-95b1ffbd15a5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= 270 | golang.org/x/sys v0.0.0-20181107165924-66b7b1311ac8/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= 271 | golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= 272 | golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= 273 | golang.org/x/sys v0.0.0-20190312061237-fead79001313/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 274 | golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 275 | golang.org/x/sys v0.0.0-20190502145724-3ef323f4f1fd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 276 | golang.org/x/sys v0.0.0-20190507160741-ecd444e8653b/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 277 | golang.org/x/sys v0.0.0-20190606165138-5da285871e9c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 278 | golang.org/x/sys v0.0.0-20190624142023-c5567b49c5d0/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 279 | golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 280 | golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 281 | golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= 282 | golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= 283 | golang.org/x/sys v0.0.0-20220128215802-99c3d69c2c27/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= 284 | golang.org/x/sys v0.0.0-20220209214540-3681064d5158 h1:rm+CHSpPEEW2IsXUib1ThaHIjuBVZjxNgSKmBLFfD4c= 285 | golang.org/x/sys v0.0.0-20220209214540-3681064d5158/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= 286 | golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= 287 | golang.org/x/term v0.0.0-20210927222741-03fcf44c2211 h1:JGgROgKl9N8DuW20oFS5gxc+lE67/N3FcwmBPMe7ArY= 288 | golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= 289 | golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= 290 | golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= 291 | golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= 292 | golang.org/x/text v0.3.6 h1:aRYxNxv6iGQlyVaZmk6ZgYEDa+Jg18DxebPSrd6bg1M= 293 | golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= 294 | golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= 295 | golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= 296 | golang.org/x/tools v0.0.0-20180221164845-07fd8470d635/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= 297 | golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= 298 | golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= 299 | golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= 300 | golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= 301 | golang.org/x/tools v0.0.0-20190312151545-0bb0c0a6e846/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= 302 | golang.org/x/tools v0.0.0-20190312170243-e65039ee4138/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= 303 | golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= 304 | golang.org/x/tools v0.0.0-20190425150028-36563e24a262/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= 305 | golang.org/x/tools v0.0.0-20190506145303-2d16b83fe98c/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= 306 | golang.org/x/tools v0.0.0-20190606124116-d0a3d012864b/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= 307 | golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= 308 | golang.org/x/tools v0.0.0-20190628153133-6cdbf07be9d0/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= 309 | golang.org/x/tools v0.0.0-20190816200558-6889da9d5479/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= 310 | golang.org/x/tools v0.0.0-20190911174233-4f2ddba30aff/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= 311 | golang.org/x/tools v0.0.0-20191012152004-8de300cfc20a/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= 312 | golang.org/x/tools v0.0.0-20191112195655-aa38f8e97acc/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= 313 | golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= 314 | google.golang.org/api v0.4.0/go.mod h1:8k5glujaEP+g9n7WNsDg8QP6cUVNI86fCNMcbazEtwE= 315 | google.golang.org/api v0.7.0/go.mod h1:WtwebWUNSVBH/HAw79HIFXZNqEvBhG+Ra+ax0hx3E3M= 316 | google.golang.org/api v0.8.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg= 317 | google.golang.org/api v0.9.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg= 318 | google.golang.org/api v0.13.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI= 319 | google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= 320 | google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= 321 | google.golang.org/appengine v1.5.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= 322 | google.golang.org/appengine v1.6.1/go.mod h1:i06prIuMbXzDqacNJfV5OdTW448YApPu5ww/cMBSeb0= 323 | google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= 324 | google.golang.org/genproto v0.0.0-20190307195333-5fe7a883aa19/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= 325 | google.golang.org/genproto v0.0.0-20190418145605-e7d98fc518a7/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= 326 | google.golang.org/genproto v0.0.0-20190425155659-357c62f0e4bb/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= 327 | google.golang.org/genproto v0.0.0-20190502173448-54afdca5d873/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= 328 | google.golang.org/genproto v0.0.0-20190801165951-fa694d86fc64/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= 329 | google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= 330 | google.golang.org/genproto v0.0.0-20190911173649-1774047e7e51/go.mod h1:IbNlFCBrqXvoKpeg0TB2l7cyZUmoaFKYIwrEpbDKLA8= 331 | google.golang.org/genproto v0.0.0-20191108220845-16a3f7862a1a/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= 332 | google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= 333 | google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38= 334 | google.golang.org/grpc v1.21.1/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM= 335 | gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= 336 | gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= 337 | gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY= 338 | gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= 339 | gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= 340 | gopkg.in/ini.v1 v1.51.0 h1:AQvPpx3LzTDM0AjnIRlVFwFFGC+npRopjZxLJj6gdno= 341 | gopkg.in/ini.v1 v1.51.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= 342 | gopkg.in/resty.v1 v1.12.0/go.mod h1:mDo4pnntr5jdWRML875a/NmxYqAlA73dVijT2AXvQQo= 343 | gopkg.in/sourcemap.v1 v1.0.5 h1:inv58fC9f9J3TK2Y2R1NPntXEn3/wjWHkonhIUODNTI= 344 | gopkg.in/sourcemap.v1 v1.0.5/go.mod h1:2RlvNNSMglmRrcvhfuzp4hQHwOtjxlbjX7UPY/GXb78= 345 | gopkg.in/yaml.v2 v2.0.0-20170812160011-eb3733d160e7/go.mod h1:JAlM8MvJe8wmxCU4Bli9HhUf9+ttbYbLASfIpnQbh74= 346 | gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= 347 | gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= 348 | gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= 349 | gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= 350 | honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= 351 | honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= 352 | honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= 353 | honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg= 354 | rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8= 355 | -------------------------------------------------------------------------------- /m3u8/downloader/dowloader.go: -------------------------------------------------------------------------------- 1 | package downloader 2 | 3 | import ( 4 | "bufio" 5 | "fmt" 6 | "io/ioutil" 7 | "os" 8 | "path/filepath" 9 | "strconv" 10 | "sync" 11 | "sync/atomic" 12 | 13 | "github.com/ilove91/91dl/m3u8/parse" 14 | "github.com/ilove91/91dl/m3u8/tool" 15 | "github.com/schollz/progressbar/v3" 16 | log "github.com/sirupsen/logrus" 17 | ) 18 | 19 | const ( 20 | tsExt = ".ts" 21 | tsFolderName = "ts" 22 | tsTempFileSuffix = "_tmp" 23 | progressWidth = 40 24 | ) 25 | 26 | type Downloader struct { 27 | lock sync.Mutex 28 | queue []int 29 | folder string 30 | tsFolder string 31 | finish int32 32 | segLen int 33 | title string 34 | pb *progressbar.ProgressBar 35 | 36 | result *parse.Result 37 | } 38 | 39 | // NewTask returns a Task instance 40 | func NewTask(destDir, url, title string) (*Downloader, error) { 41 | result, err := parse.FromURL(url) 42 | if err != nil { 43 | return nil, err 44 | } 45 | 46 | tsFolder := filepath.Join(destDir, tsFolderName) 47 | if err := os.MkdirAll(tsFolder, os.ModePerm); err != nil { 48 | return nil, fmt.Errorf("create ts folder '[%s]' failed: %s", tsFolder, err.Error()) 49 | } 50 | d := &Downloader{ 51 | folder: destDir, 52 | tsFolder: tsFolder, 53 | result: result, 54 | title: fmt.Sprintf("%s.mp4", title), 55 | } 56 | d.segLen = len(result.M3u8.Segments) 57 | d.pb = progressbar.Default(int64(d.segLen)) 58 | d.queue = genSlice(d.segLen) 59 | return d, nil 60 | } 61 | 62 | // Start runs downloader 63 | func (d *Downloader) Start(concurrency int) error { 64 | var wg sync.WaitGroup 65 | // struct{} zero size 66 | limitChan := make(chan struct{}, concurrency) 67 | for { 68 | tsIdx, end, err := d.next() 69 | if err != nil { 70 | if end { 71 | break 72 | } 73 | continue 74 | } 75 | wg.Add(1) 76 | go func(idx int) { 77 | defer wg.Done() 78 | if err := d.download(idx); err != nil { 79 | // Back into the queue, retry request 80 | log.Error("[failed] ", err.Error()) 81 | if err := d.back(idx); err != nil { 82 | log.Error(err.Error()) 83 | } 84 | } 85 | <-limitChan 86 | }(tsIdx) 87 | limitChan <- struct{}{} 88 | } 89 | wg.Wait() 90 | if err := d.merge(); err != nil { 91 | return err 92 | } 93 | return nil 94 | } 95 | 96 | func (d *Downloader) download(segIndex int) error { 97 | tsFilename := tsFilename(segIndex) 98 | tsURL := d.tsURL(segIndex) 99 | b, e := tool.Get(tsURL) 100 | if e != nil { 101 | return fmt.Errorf("request %s, %s", tsURL, e.Error()) 102 | } 103 | //noinspection GoUnhandledErrorResult 104 | defer b.Close() 105 | fPath := filepath.Join(d.tsFolder, tsFilename) 106 | fTemp := fPath + tsTempFileSuffix 107 | f, err := os.Create(fTemp) 108 | if err != nil { 109 | return fmt.Errorf("create file: %s, %s", tsFilename, err.Error()) 110 | } 111 | bytes, err := ioutil.ReadAll(b) 112 | if err != nil { 113 | return fmt.Errorf("read bytes: %s", tsURL) 114 | } 115 | sf := d.result.M3u8.Segments[segIndex] 116 | if sf == nil { 117 | return fmt.Errorf("invalid segment index: %d", segIndex) 118 | } 119 | key, ok := d.result.Keys[sf.KeyIndex] 120 | if ok && key != "" { 121 | bytes, err = tool.AES128Decrypt(bytes, []byte(key), 122 | []byte(d.result.M3u8.Keys[sf.KeyIndex].IV)) 123 | if err != nil { 124 | return fmt.Errorf("decryt: %s, %s", tsURL, err.Error()) 125 | } 126 | } 127 | // https://en.wikipedia.org/wiki/MPEG_transport_stream 128 | // Some TS files do not start with SyncByte 0x47, they can not be played after merging, 129 | // Need to remove the bytes before the SyncByte 0x47(71). 130 | syncByte := uint8(71) //0x47 131 | bLen := len(bytes) 132 | for j := 0; j < bLen; j++ { 133 | if bytes[j] == syncByte { 134 | bytes = bytes[j:] 135 | break 136 | } 137 | } 138 | w := bufio.NewWriter(f) 139 | if _, err := w.Write(bytes); err != nil { 140 | return fmt.Errorf("write to %s: %s", fTemp, err.Error()) 141 | } 142 | // Release file resource to rename file 143 | _ = f.Close() 144 | if err = os.Rename(fTemp, fPath); err != nil { 145 | return err 146 | } 147 | // Maybe it will be safer in this way... 148 | atomic.AddInt32(&d.finish, 1) 149 | // tool.DrawProgressBar("Downloading", float32(d.finish)/float32(d.segLen), progressWidth) 150 | // log.Infof("[downloaded %3d/%d] %s", d.finish, d.segLen, tsURL) 151 | d.pb.Add(1) 152 | return nil 153 | } 154 | 155 | func (d *Downloader) next() (segIndex int, end bool, err error) { 156 | d.lock.Lock() 157 | defer d.lock.Unlock() 158 | if len(d.queue) == 0 { 159 | err = fmt.Errorf("queue empty") 160 | if d.finish == int32(d.segLen) { 161 | end = true 162 | return 163 | } 164 | // Some segment indexes are still running. 165 | end = false 166 | return 167 | } 168 | segIndex = d.queue[0] 169 | d.queue = d.queue[1:] 170 | return 171 | } 172 | 173 | func (d *Downloader) back(segIndex int) error { 174 | d.lock.Lock() 175 | defer d.lock.Unlock() 176 | if sf := d.result.M3u8.Segments[segIndex]; sf == nil { 177 | return fmt.Errorf("invalid segment index: %d", segIndex) 178 | } 179 | d.queue = append(d.queue, segIndex) 180 | return nil 181 | } 182 | 183 | func (d *Downloader) merge() error { 184 | // In fact, the number of downloaded segments should be equal to number of m3u8 segments 185 | missingCount := 0 186 | for idx := 0; idx < d.segLen; idx++ { 187 | tsFilename := tsFilename(idx) 188 | f := filepath.Join(d.tsFolder, tsFilename) 189 | if _, err := os.Stat(f); err != nil { 190 | missingCount++ 191 | } 192 | } 193 | if missingCount > 0 { 194 | log.Errorf("[warning] %d files missing", missingCount) 195 | } 196 | 197 | // Create a TS file for merging, all segment files will be written to this file. 198 | mFilePath := filepath.Join(d.folder, d.title) 199 | mFile, err := os.Create(mFilePath) 200 | if err != nil { 201 | return fmt.Errorf("create main TS file failed:%s", err.Error()) 202 | } 203 | //noinspection GoUnhandledErrorResult 204 | defer mFile.Close() 205 | 206 | writer := bufio.NewWriter(mFile) 207 | mergedCount := 0 208 | for segIndex := 0; segIndex < d.segLen; segIndex++ { 209 | tsFilename := tsFilename(segIndex) 210 | bytes, _ := ioutil.ReadFile(filepath.Join(d.tsFolder, tsFilename)) 211 | _, err = writer.Write(bytes) 212 | if err != nil { 213 | continue 214 | } 215 | mergedCount++ 216 | // tool.DrawProgressBar("merge", float32(mergedCount)/float32(d.segLen), progressWidth) 217 | } 218 | _ = writer.Flush() 219 | // Remove `ts` folder 220 | _ = os.RemoveAll(d.tsFolder) 221 | 222 | if mergedCount != d.segLen { 223 | log.Errorf("[FAIL] %v %d files merge failed", d.title, d.segLen-mergedCount) 224 | os.Remove(mFilePath) 225 | return fmt.Errorf("%v incomplete", d.title) 226 | } 227 | 228 | d.pb.Finish() 229 | 230 | return nil 231 | } 232 | 233 | func (d *Downloader) tsURL(segIndex int) string { 234 | seg := d.result.M3u8.Segments[segIndex] 235 | return tool.ResolveURL(d.result.URL, seg.URI) 236 | } 237 | 238 | func tsFilename(ts int) string { 239 | return strconv.Itoa(ts) + tsExt 240 | } 241 | 242 | func genSlice(len int) []int { 243 | s := make([]int, 0) 244 | for i := 0; i < len; i++ { 245 | s = append(s, i) 246 | } 247 | return s 248 | } 249 | -------------------------------------------------------------------------------- /m3u8/m3u8.go: -------------------------------------------------------------------------------- 1 | package m3u8 2 | 3 | import ( 4 | "github.com/ilove91/91dl/m3u8/downloader" 5 | ) 6 | 7 | // Download m3u8 8 | func Download(url, title, destDir string, concurrency int) error { 9 | downloader, err := downloader.NewTask(destDir, url, title) 10 | if err != nil { 11 | return err 12 | } 13 | if err := downloader.Start(concurrency); err != nil { 14 | return err 15 | } 16 | return nil 17 | } 18 | -------------------------------------------------------------------------------- /m3u8/parse/m3u8.go: -------------------------------------------------------------------------------- 1 | // Partial reference https://github.com/grafov/m3u8/blob/master/reader.go 2 | package parse 3 | 4 | import ( 5 | "bufio" 6 | "errors" 7 | "fmt" 8 | "io" 9 | "regexp" 10 | "strconv" 11 | "strings" 12 | ) 13 | 14 | type ( 15 | PlaylistType string 16 | CryptMethod string 17 | ) 18 | 19 | const ( 20 | PlaylistTypeVOD PlaylistType = "VOD" 21 | PlaylistTypeEvent PlaylistType = "EVENT" 22 | 23 | CryptMethodAES CryptMethod = "AES-128" 24 | CryptMethodNONE CryptMethod = "NONE" 25 | ) 26 | 27 | // regex pattern for extracting `key=value` parameters from a line 28 | var linePattern = regexp.MustCompile(`([a-zA-Z-]+)=("[^"]+"|[^",]+)`) 29 | 30 | type M3u8 struct { 31 | Version int8 // EXT-X-VERSION:version 32 | MediaSequence uint64 // Default 0, #EXT-X-MEDIA-SEQUENCE:sequence 33 | Segments []*Segment 34 | MasterPlaylist []*MasterPlaylist 35 | Keys map[int]*Key 36 | EndList bool // #EXT-X-ENDLIST 37 | PlaylistType PlaylistType // VOD or EVENT 38 | TargetDuration float64 // #EXT-X-TARGETDURATION:duration 39 | } 40 | 41 | type Segment struct { 42 | URI string 43 | KeyIndex int 44 | Title string // #EXTINF: duration, 45 | Duration float32 // #EXTINF: duration,<title> 46 | Length uint64 // #EXT-X-BYTERANGE: length[@offset] 47 | Offset uint64 // #EXT-X-BYTERANGE: length[@offset] 48 | } 49 | 50 | // #EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=240000,RESOLUTION=416x234,CODECS="avc1.42e00a,mp4a.40.2" 51 | type MasterPlaylist struct { 52 | URI string 53 | BandWidth uint32 54 | Resolution string 55 | Codecs string 56 | ProgramID uint32 57 | } 58 | 59 | // #EXT-X-KEY:METHOD=AES-128,URI="key.key" 60 | type Key struct { 61 | // 'AES-128' or 'NONE' 62 | // If the encryption method is NONE, the URI and the IV attributes MUST NOT be present 63 | Method CryptMethod 64 | URI string 65 | IV string 66 | } 67 | 68 | func parse(reader io.Reader) (*M3u8, error) { 69 | s := bufio.NewScanner(reader) 70 | var lines []string 71 | for s.Scan() { 72 | lines = append(lines, s.Text()) 73 | } 74 | 75 | var ( 76 | i = 0 77 | count = len(lines) 78 | m3u8 = &M3u8{ 79 | Keys: make(map[int]*Key), 80 | } 81 | keyIndex = 0 82 | 83 | key *Key 84 | seg *Segment 85 | extInf bool 86 | extByte bool 87 | ) 88 | 89 | for ; i < count; i++ { 90 | line := strings.TrimSpace(lines[i]) 91 | if i == 0 { 92 | if "#EXTM3U" != line { 93 | return nil, fmt.Errorf("invalid m3u8, missing #EXTM3U in line 1") 94 | } 95 | continue 96 | } 97 | switch { 98 | case line == "": 99 | continue 100 | case strings.HasPrefix(line, "#EXT-X-PLAYLIST-TYPE:"): 101 | if _, err := fmt.Sscanf(line, "#EXT-X-PLAYLIST-TYPE:%s", &m3u8.PlaylistType); err != nil { 102 | return nil, err 103 | } 104 | isValid := m3u8.PlaylistType == "" || m3u8.PlaylistType == PlaylistTypeVOD || m3u8.PlaylistType == PlaylistTypeEvent 105 | if !isValid { 106 | return nil, fmt.Errorf("invalid playlist type: %s, line: %d", m3u8.PlaylistType, i+1) 107 | } 108 | case strings.HasPrefix(line, "#EXT-X-TARGETDURATION:"): 109 | if _, err := fmt.Sscanf(line, "#EXT-X-TARGETDURATION:%f", &m3u8.TargetDuration); err != nil { 110 | return nil, err 111 | } 112 | case strings.HasPrefix(line, "#EXT-X-MEDIA-SEQUENCE:"): 113 | if _, err := fmt.Sscanf(line, "#EXT-X-MEDIA-SEQUENCE:%d", &m3u8.MediaSequence); err != nil { 114 | return nil, err 115 | } 116 | case strings.HasPrefix(line, "#EXT-X-VERSION:"): 117 | if _, err := fmt.Sscanf(line, "#EXT-X-VERSION:%d", &m3u8.Version); err != nil { 118 | return nil, err 119 | } 120 | // Parse master playlist 121 | case strings.HasPrefix(line, "#EXT-X-STREAM-INF:"): 122 | mp, err := parseMasterPlaylist(line) 123 | if err != nil { 124 | return nil, err 125 | } 126 | i++ 127 | mp.URI = lines[i] 128 | if mp.URI == "" || strings.HasPrefix(mp.URI, "#") { 129 | return nil, fmt.Errorf("invalid EXT-X-STREAM-INF URI, line: %d", i+1) 130 | } 131 | m3u8.MasterPlaylist = append(m3u8.MasterPlaylist, mp) 132 | continue 133 | case strings.HasPrefix(line, "#EXTINF:"): 134 | if extInf { 135 | return nil, fmt.Errorf("duplicate EXTINF: %s, line: %d", line, i+1) 136 | } 137 | if seg == nil { 138 | seg = new(Segment) 139 | } 140 | var s string 141 | if _, err := fmt.Sscanf(line, "#EXTINF:%s", &s); err != nil { 142 | return nil, err 143 | } 144 | if strings.Contains(s, ",") { 145 | split := strings.Split(s, ",") 146 | seg.Title = split[1] 147 | s = split[0] 148 | } 149 | df, err := strconv.ParseFloat(s, 32) 150 | if err != nil { 151 | return nil, err 152 | } 153 | seg.Duration = float32(df) 154 | seg.KeyIndex = keyIndex 155 | extInf = true 156 | case strings.HasPrefix(line, "#EXT-X-BYTERANGE:"): 157 | if extByte { 158 | return nil, fmt.Errorf("duplicate EXT-X-BYTERANGE: %s, line: %d", line, i+1) 159 | } 160 | if seg == nil { 161 | seg = new(Segment) 162 | } 163 | var b string 164 | if _, err := fmt.Sscanf(line, "#EXT-X-BYTERANGE:%s", &b); err != nil { 165 | return nil, err 166 | } 167 | if b == "" { 168 | return nil, fmt.Errorf("invalid EXT-X-BYTERANGE, line: %d", i+1) 169 | } 170 | if strings.Contains(b, "@") { 171 | split := strings.Split(b, "@") 172 | offset, err := strconv.ParseUint(split[1], 10, 64) 173 | if err != nil { 174 | return nil, err 175 | } 176 | seg.Offset = uint64(offset) 177 | b = split[0] 178 | } 179 | length, err := strconv.ParseUint(b, 10, 64) 180 | if err != nil { 181 | return nil, err 182 | } 183 | seg.Length = uint64(length) 184 | extByte = true 185 | // Parse segments URI 186 | case !strings.HasPrefix(line, "#"): 187 | if extInf { 188 | if seg == nil { 189 | return nil, fmt.Errorf("invalid line: %s", line) 190 | } 191 | seg.URI = line 192 | extByte = false 193 | extInf = false 194 | m3u8.Segments = append(m3u8.Segments, seg) 195 | seg = nil 196 | continue 197 | } 198 | // Parse key 199 | case strings.HasPrefix(line, "#EXT-X-KEY"): 200 | params := parseLineParameters(line) 201 | if len(params) == 0 { 202 | return nil, fmt.Errorf("invalid EXT-X-KEY: %s, line: %d", line, i+1) 203 | } 204 | method := CryptMethod(params["METHOD"]) 205 | if method != "" && method != CryptMethodAES && method != CryptMethodNONE { 206 | return nil, fmt.Errorf("invalid EXT-X-KEY method: %s, line: %d", method, i+1) 207 | } 208 | keyIndex++ 209 | key = new(Key) 210 | key.Method = method 211 | key.URI = params["URI"] 212 | key.IV = params["IV"] 213 | m3u8.Keys[keyIndex] = key 214 | case line == "#EndList": 215 | m3u8.EndList = true 216 | default: 217 | continue 218 | } 219 | } 220 | 221 | return m3u8, nil 222 | } 223 | 224 | func parseMasterPlaylist(line string) (*MasterPlaylist, error) { 225 | params := parseLineParameters(line) 226 | if len(params) == 0 { 227 | return nil, errors.New("empty parameter") 228 | } 229 | mp := new(MasterPlaylist) 230 | for k, v := range params { 231 | switch { 232 | case k == "BANDWIDTH": 233 | v, err := strconv.ParseUint(v, 10, 32) 234 | if err != nil { 235 | return nil, err 236 | } 237 | mp.BandWidth = uint32(v) 238 | case k == "RESOLUTION": 239 | mp.Resolution = v 240 | case k == "PROGRAM-ID": 241 | v, err := strconv.ParseUint(v, 10, 32) 242 | if err != nil { 243 | return nil, err 244 | } 245 | mp.ProgramID = uint32(v) 246 | case k == "CODECS": 247 | mp.Codecs = v 248 | } 249 | } 250 | return mp, nil 251 | } 252 | 253 | // parseLineParameters extra parameters in string `line` 254 | func parseLineParameters(line string) map[string]string { 255 | r := linePattern.FindAllStringSubmatch(line, -1) 256 | params := make(map[string]string) 257 | for _, arr := range r { 258 | params[arr[1]] = strings.Trim(arr[2], "\"") 259 | } 260 | return params 261 | } 262 | -------------------------------------------------------------------------------- /m3u8/parse/parser.go: -------------------------------------------------------------------------------- 1 | package parse 2 | 3 | import ( 4 | "errors" 5 | "fmt" 6 | "io/ioutil" 7 | "net/url" 8 | 9 | "github.com/ilove91/91dl/m3u8/tool" 10 | ) 11 | 12 | type Result struct { 13 | URL *url.URL 14 | M3u8 *M3u8 15 | Keys map[int]string 16 | } 17 | 18 | func FromURL(link string) (*Result, error) { 19 | u, err := url.Parse(link) 20 | if err != nil { 21 | return nil, err 22 | } 23 | link = u.String() 24 | body, err := tool.Get(link) 25 | if err != nil { 26 | return nil, fmt.Errorf("request m3u8 URL failed: %s", err.Error()) 27 | } 28 | //noinspection GoUnhandledErrorResult 29 | defer body.Close() 30 | m3u8, err := parse(body) 31 | if err != nil { 32 | return nil, err 33 | } 34 | if len(m3u8.MasterPlaylist) != 0 { 35 | sf := m3u8.MasterPlaylist[0] 36 | return FromURL(tool.ResolveURL(u, sf.URI)) 37 | } 38 | if len(m3u8.Segments) == 0 { 39 | return nil, errors.New("can not found any TS file description") 40 | } 41 | result := &Result{ 42 | URL: u, 43 | M3u8: m3u8, 44 | Keys: make(map[int]string), 45 | } 46 | 47 | for idx, key := range m3u8.Keys { 48 | switch { 49 | case key.Method == "" || key.Method == CryptMethodNONE: 50 | continue 51 | case key.Method == CryptMethodAES: 52 | // Request URL to extract decryption key 53 | keyURL := key.URI 54 | keyURL = tool.ResolveURL(u, keyURL) 55 | resp, err := tool.Get(keyURL) 56 | if err != nil { 57 | return nil, fmt.Errorf("extract key failed: %s", err.Error()) 58 | } 59 | keyByte, err := ioutil.ReadAll(resp) 60 | _ = resp.Close() 61 | if err != nil { 62 | return nil, err 63 | } 64 | fmt.Println("decryption key: ", string(keyByte)) 65 | result.Keys[idx] = string(keyByte) 66 | default: 67 | return nil, fmt.Errorf("unknown or unsupported cryption method: %s", key.Method) 68 | } 69 | } 70 | return result, nil 71 | } 72 | -------------------------------------------------------------------------------- /m3u8/tool/crypt.go: -------------------------------------------------------------------------------- 1 | package tool 2 | 3 | import ( 4 | "bytes" 5 | "crypto/aes" 6 | "crypto/cipher" 7 | ) 8 | 9 | func AES128Encrypt(origData, key, iv []byte) ([]byte, error) { 10 | block, err := aes.NewCipher(key) 11 | if err != nil { 12 | return nil, err 13 | } 14 | blockSize := block.BlockSize() 15 | if len(iv) == 0 { 16 | iv = key 17 | } 18 | origData = pkcs5Padding(origData, blockSize) 19 | blockMode := cipher.NewCBCEncrypter(block, iv[:blockSize]) 20 | crypted := make([]byte, len(origData)) 21 | blockMode.CryptBlocks(crypted, origData) 22 | return crypted, nil 23 | } 24 | 25 | func AES128Decrypt(crypted, key, iv []byte) ([]byte, error) { 26 | block, err := aes.NewCipher(key) 27 | if err != nil { 28 | return nil, err 29 | } 30 | blockSize := block.BlockSize() 31 | if len(iv) == 0 { 32 | iv = key 33 | } 34 | blockMode := cipher.NewCBCDecrypter(block, iv[:blockSize]) 35 | origData := make([]byte, len(crypted)) 36 | blockMode.CryptBlocks(origData, crypted) 37 | origData = pkcs5UnPadding(origData) 38 | return origData, nil 39 | } 40 | 41 | func pkcs5Padding(cipherText []byte, blockSize int) []byte { 42 | padding := blockSize - len(cipherText)%blockSize 43 | padText := bytes.Repeat([]byte{byte(padding)}, padding) 44 | return append(cipherText, padText...) 45 | } 46 | 47 | func pkcs5UnPadding(origData []byte) []byte { 48 | length := len(origData) 49 | unPadding := int(origData[length-1]) 50 | return origData[:(length - unPadding)] 51 | } 52 | -------------------------------------------------------------------------------- /m3u8/tool/crypt_test.go: -------------------------------------------------------------------------------- 1 | package tool 2 | 3 | import ( 4 | "testing" 5 | ) 6 | 7 | func Test_AES128Encrypt_AND_AES128Decrypt(t *testing.T) { 8 | expected := "helloworld" 9 | key := "8dv4byf8b9e6bc1x" 10 | iv := "xduio1f8a12348u4" 11 | encrypt, err := AES128Encrypt([]byte(expected), []byte(key), []byte(iv)) 12 | if err != nil { 13 | t.Fatal(err) 14 | } 15 | decrypt, err := AES128Decrypt(encrypt, []byte(key), []byte(iv)) 16 | if err != nil { 17 | t.Fatal(err) 18 | } 19 | de := string(decrypt) 20 | if de != expected { 21 | t.Fatalf("expected: %s, result: %s", expected, de) 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /m3u8/tool/http.go: -------------------------------------------------------------------------------- 1 | package tool 2 | 3 | import ( 4 | "fmt" 5 | "io" 6 | 7 | "github.com/ilove91/91dl/utils" 8 | ) 9 | 10 | func Get(url string) (io.ReadCloser, error) { 11 | c := utils.GetNewHttpClient(60) 12 | resp, err := c.Get(url) 13 | if err != nil { 14 | return nil, err 15 | } 16 | if resp.StatusCode != 200 { 17 | return nil, fmt.Errorf("http error: status code %d", resp.StatusCode) 18 | } 19 | return resp.Body, nil 20 | } 21 | -------------------------------------------------------------------------------- /m3u8/tool/http_test.go: -------------------------------------------------------------------------------- 1 | package tool 2 | 3 | import ( 4 | "io/ioutil" 5 | "testing" 6 | ) 7 | 8 | func TestGet(t *testing.T) { 9 | body, err := Get("https://raw.githubusercontent.com/oopsguy/m3u8/master/README.md") 10 | if err != nil { 11 | t.Error(err) 12 | } 13 | defer body.Close() 14 | _, err = ioutil.ReadAll(body) 15 | if err != nil { 16 | t.Error(err) 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /m3u8/tool/util.go: -------------------------------------------------------------------------------- 1 | package tool 2 | 3 | import ( 4 | "fmt" 5 | "net/url" 6 | "os" 7 | "path" 8 | "path/filepath" 9 | "strings" 10 | ) 11 | 12 | func CurrentDir(joinPath ...string) (string, error) { 13 | dir, err := filepath.Abs(filepath.Dir(os.Args[0])) 14 | if err != nil { 15 | return "", err 16 | } 17 | p := strings.Replace(dir, "\\", "/", -1) 18 | whole := filepath.Join(joinPath...) 19 | whole = filepath.Join(p, whole) 20 | return whole, nil 21 | } 22 | 23 | func ResolveURL(u *url.URL, p string) string { 24 | if strings.HasPrefix(p, "https://") || strings.HasPrefix(p, "http://") { 25 | return p 26 | } 27 | var baseURL string 28 | if strings.Index(p, "/") == 0 { 29 | baseURL = u.Scheme + "://" + u.Host 30 | } else { 31 | tU := u.String() 32 | baseURL = tU[0:strings.LastIndex(tU, "/")] 33 | } 34 | return baseURL + path.Join("/", p) 35 | } 36 | 37 | func DrawProgressBar(prefix string, proportion float32, width int, suffix ...string) { 38 | pos := int(proportion * float32(width)) 39 | s := fmt.Sprintf("[%s] %s%*s %6.2f%% %s", 40 | prefix, strings.Repeat("■", pos), width-pos, "", proportion*100, strings.Join(suffix, "")) 41 | fmt.Print("\r" + s) 42 | } 43 | -------------------------------------------------------------------------------- /m3u8/tool/util_test.go: -------------------------------------------------------------------------------- 1 | package tool 2 | 3 | import ( 4 | "net/url" 5 | "testing" 6 | ) 7 | 8 | func TestResolveURL(t *testing.T) { 9 | testURL := "http://www.example.com/test/index.m3m8" 10 | u, err := url.Parse(testURL) 11 | if err != nil { 12 | t.Error(err) 13 | } 14 | 15 | result := ResolveURL(u, "videos/111111.ts") 16 | expected := "http://www.example.com/test/videos/111111.ts" 17 | if result != expected { 18 | t.Fatalf("wrong URL, expected: %s, result: %s", expected, result) 19 | } 20 | 21 | result = ResolveURL(u, "/videos/2222222.ts") 22 | expected = "http://www.example.com/videos/2222222.ts" 23 | if result != expected { 24 | t.Fatalf("wrong URL, expected: %s, result: %s", expected, result) 25 | } 26 | 27 | result = ResolveURL(u, "https://test.com/11111.key") 28 | expected = "https://test.com/11111.key" 29 | if result != expected { 30 | t.Fatalf("wrong URL, expected: %s, result: %s", expected, result) 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /main.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2018 NAME HERE <EMAIL ADDRESS> 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package main 16 | 17 | import "github.com/ilove91/91dl/cmd" 18 | 19 | func main() { 20 | cmd.Execute() 21 | } 22 | -------------------------------------------------------------------------------- /utils/http.go: -------------------------------------------------------------------------------- 1 | package utils 2 | 3 | import ( 4 | "net/http" 5 | "net/url" 6 | "time" 7 | 8 | "github.com/spf13/viper" 9 | ) 10 | 11 | func GetNewHttpClient(timeout int64) *http.Client { 12 | client := &http.Client{ 13 | Timeout: time.Duration(timeout) * time.Second, 14 | } 15 | 16 | str := viper.GetString("proxy") 17 | proxy, _ := url.ParseRequestURI(str) 18 | if proxy != nil { 19 | client.Transport = &http.Transport{Proxy: http.ProxyURL(proxy)} 20 | } else { 21 | client.Transport = &http.Transport{Proxy: http.ProxyFromEnvironment} 22 | } 23 | 24 | return client 25 | } 26 | --------------------------------------------------------------------------------