├── .gitattributes ├── .gitignore ├── .gitmodules ├── COPYING.LESSER.txt ├── COPYING.txt ├── README.md ├── TondarAPI.xcodeproj ├── project.pbxproj └── project.xcworkspace │ ├── contents.xcworkspacedata │ └── xcshareddata │ └── TondarAPI.xccheckout ├── TondarAPI ├── ConvertURL.h ├── ConvertURL.m ├── HYXunleiLixianAPI.h ├── HYXunleiLixianAPI.m ├── JSONKit │ ├── JSONKit.h │ └── JSONKit.m ├── Kuai.h ├── Kuai.m ├── LCHTTPConnection.h ├── LCHTTPConnection.m ├── NSData+Base64.h ├── NSData+Base64.m ├── NSString+Base64.h ├── NSString+Base64.m ├── NSString+RE.h ├── NSString+RE.m ├── ParseElements.h ├── ParseElements.m ├── TondarAPI-Info.plist ├── TondarAPI-Prefix.pch ├── URlEncode.h ├── URlEncode.m ├── XunleiItemInfo.h ├── XunleiItemInfo.m ├── en.lproj │ └── InfoPlist.strings ├── md5.h └── md5.m ├── TondarAPITests ├── TondarAPITests-Info.plist ├── TondarAPITests.h ├── TondarAPITests.m └── en.lproj │ └── InfoPlist.strings └── URLTesting ├── URLTesting-Info.plist ├── URLTesting-Prefix.pch ├── URLTesting.h ├── URLTesting.m └── en.lproj └── InfoPlist.strings /.gitattributes: -------------------------------------------------------------------------------- 1 | *.pbxproj -crlf -diff -merge 2 | 3 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | #xcode noise 2 | *.mode1v3 3 | *.pbxuser 4 | *.perspective 5 | *.perspectivev3 6 | *.pyc 7 | *~.nib/ 8 | build/* 9 | 10 | #new in Xcode 4 11 | xcuserdata 12 | 13 | # Textmate - if you build your xcode projects with it 14 | *.tm_build_errors 15 | 16 | # old skool 17 | .svn 18 | 19 | # osx noise 20 | .DS_Store 21 | profile 22 | #.xcode 23 | 24 | *.xcodeproj/project.xcworkspace/xcuserdata/liuchao.xcuserdatad/UserInterfaceState.xcuserstate 25 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lqik2004/xunlei-lixian-api-PureObjc/06e66fc151a4173184d6c71bee1fd8431eeb312a/.gitmodules -------------------------------------------------------------------------------- /COPYING.LESSER.txt: -------------------------------------------------------------------------------- 1 | GNU LESSER GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | 9 | This version of the GNU Lesser General Public License incorporates 10 | the terms and conditions of version 3 of the GNU General Public 11 | License, supplemented by the additional permissions listed below. 12 | 13 | 0. Additional Definitions. 14 | 15 | As used herein, "this License" refers to version 3 of the GNU Lesser 16 | General Public License, and the "GNU GPL" refers to version 3 of the GNU 17 | General Public License. 18 | 19 | "The Library" refers to a covered work governed by this License, 20 | other than an Application or a Combined Work as defined below. 21 | 22 | An "Application" is any work that makes use of an interface provided 23 | by the Library, but which is not otherwise based on the Library. 24 | Defining a subclass of a class defined by the Library is deemed a mode 25 | of using an interface provided by the Library. 26 | 27 | A "Combined Work" is a work produced by combining or linking an 28 | Application with the Library. The particular version of the Library 29 | with which the Combined Work was made is also called the "Linked 30 | Version". 31 | 32 | The "Minimal Corresponding Source" for a Combined Work means the 33 | Corresponding Source for the Combined Work, excluding any source code 34 | for portions of the Combined Work that, considered in isolation, are 35 | based on the Application, and not on the Linked Version. 36 | 37 | The "Corresponding Application Code" for a Combined Work means the 38 | object code and/or source code for the Application, including any data 39 | and utility programs needed for reproducing the Combined Work from the 40 | Application, but excluding the System Libraries of the Combined Work. 41 | 42 | 1. Exception to Section 3 of the GNU GPL. 43 | 44 | You may convey a covered work under sections 3 and 4 of this License 45 | without being bound by section 3 of the GNU GPL. 46 | 47 | 2. Conveying Modified Versions. 48 | 49 | If you modify a copy of the Library, and, in your modifications, a 50 | facility refers to a function or data to be supplied by an Application 51 | that uses the facility (other than as an argument passed when the 52 | facility is invoked), then you may convey a copy of the modified 53 | version: 54 | 55 | a) under this License, provided that you make a good faith effort to 56 | ensure that, in the event an Application does not supply the 57 | function or data, the facility still operates, and performs 58 | whatever part of its purpose remains meaningful, or 59 | 60 | b) under the GNU GPL, with none of the additional permissions of 61 | this License applicable to that copy. 62 | 63 | 3. Object Code Incorporating Material from Library Header Files. 64 | 65 | The object code form of an Application may incorporate material from 66 | a header file that is part of the Library. You may convey such object 67 | code under terms of your choice, provided that, if the incorporated 68 | material is not limited to numerical parameters, data structure 69 | layouts and accessors, or small macros, inline functions and templates 70 | (ten or fewer lines in length), you do both of the following: 71 | 72 | a) Give prominent notice with each copy of the object code that the 73 | Library is used in it and that the Library and its use are 74 | covered by this License. 75 | 76 | b) Accompany the object code with a copy of the GNU GPL and this license 77 | document. 78 | 79 | 4. Combined Works. 80 | 81 | You may convey a Combined Work under terms of your choice that, 82 | taken together, effectively do not restrict modification of the 83 | portions of the Library contained in the Combined Work and reverse 84 | engineering for debugging such modifications, if you also do each of 85 | the following: 86 | 87 | a) Give prominent notice with each copy of the Combined Work that 88 | the Library is used in it and that the Library and its use are 89 | covered by this License. 90 | 91 | b) Accompany the Combined Work with a copy of the GNU GPL and this license 92 | document. 93 | 94 | c) For a Combined Work that displays copyright notices during 95 | execution, include the copyright notice for the Library among 96 | these notices, as well as a reference directing the user to the 97 | copies of the GNU GPL and this license document. 98 | 99 | d) Do one of the following: 100 | 101 | 0) Convey the Minimal Corresponding Source under the terms of this 102 | License, and the Corresponding Application Code in a form 103 | suitable for, and under terms that permit, the user to 104 | recombine or relink the Application with a modified version of 105 | the Linked Version to produce a modified Combined Work, in the 106 | manner specified by section 6 of the GNU GPL for conveying 107 | Corresponding Source. 108 | 109 | 1) Use a suitable shared library mechanism for linking with the 110 | Library. A suitable mechanism is one that (a) uses at run time 111 | a copy of the Library already present on the user's computer 112 | system, and (b) will operate properly with a modified version 113 | of the Library that is interface-compatible with the Linked 114 | Version. 115 | 116 | e) Provide Installation Information, but only if you would otherwise 117 | be required to provide such information under section 6 of the 118 | GNU GPL, and only to the extent that such information is 119 | necessary to install and execute a modified version of the 120 | Combined Work produced by recombining or relinking the 121 | Application with a modified version of the Linked Version. (If 122 | you use option 4d0, the Installation Information must accompany 123 | the Minimal Corresponding Source and Corresponding Application 124 | Code. If you use option 4d1, you must provide the Installation 125 | Information in the manner specified by section 6 of the GNU GPL 126 | for conveying Corresponding Source.) 127 | 128 | 5. Combined Libraries. 129 | 130 | You may place library facilities that are a work based on the 131 | Library side by side in a single library together with other library 132 | facilities that are not Applications and are not covered by this 133 | License, and convey such a combined library under terms of your 134 | choice, if you do both of the following: 135 | 136 | a) Accompany the combined library with a copy of the same work based 137 | on the Library, uncombined with any other library facilities, 138 | conveyed under the terms of this License. 139 | 140 | b) Give prominent notice with the combined library that part of it 141 | is a work based on the Library, and explaining where to find the 142 | accompanying uncombined form of the same work. 143 | 144 | 6. Revised Versions of the GNU Lesser General Public License. 145 | 146 | The Free Software Foundation may publish revised and/or new versions 147 | of the GNU Lesser General Public License from time to time. Such new 148 | versions will be similar in spirit to the present version, but may 149 | differ in detail to address new problems or concerns. 150 | 151 | Each version is given a distinguishing version number. If the 152 | Library as you received it specifies that a certain numbered version 153 | of the GNU Lesser General Public License "or any later version" 154 | applies to it, you have the option of following the terms and 155 | conditions either of that published version or of any later version 156 | published by the Free Software Foundation. If the Library as you 157 | received it does not specify a version number of the GNU Lesser 158 | General Public License, you may choose any version of the GNU Lesser 159 | General Public License ever published by the Free Software Foundation. 160 | 161 | If the Library as you received it specifies that a proxy can decide 162 | whether future versions of the GNU Lesser General Public License shall 163 | apply, that proxy's public statement of acceptance of any version is 164 | permanent authorization for you to choose that version for the 165 | Library. -------------------------------------------------------------------------------- /COPYING.txt: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | 635 | Copyright (C) 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | Copyright (C) 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | #迅雷离线API (TondarAPI) 2 | *************** 3 | 本项目旨在提供一个纯由Objective-C写成的迅雷离线API,方便在Mac OS X和iOS上开发相应项目。 4 | **TondarAPI已经通过了iOS/Mac OS X兼容性测试** 5 | ###名称释义 6 | **Tondar**为波斯语(Persian),意为闪电 7 | ###功能概述 8 | * 迅雷离线账户登陆 9 | * 获取任务列表(返回返回每个任务的详细信息,参见XunleiItemInfo) 10 | * 任务类型识别 11 | * 获取BT任务列表(返回返回每个任务的详细信息,参见XunleiItemInfo) 12 | * http/ftp/thunder/ed2k/magnet等下载连接类型支持 13 | * 删除任务 14 | * 添加云转码任务(包括选择不同清晰度) 15 | * 获取云转码任务列表 16 | * 删除云转码任务 17 | * 云点播 18 | * 一键添加到迅雷快传 19 | * 对迅雷,旋风,Flashget多种专有连接的下载支持 20 | 21 | ###TODO 22 | * 完善获取“保留时间”方法 23 | * 增加对正在下载任务的进度获取 24 | * 支持批量任务添加 25 | 26 | ****************** 27 | ###使用迅雷离线API的项目 28 | * 迅雷离线 for iOS 29 | * fakeThunder 2 (Developing) 30 | * [TurboX](https://github.com/lqik2004/TurboX) 31 | 32 | 如果你使用了迅雷离线API,可以和我联系添加到这里 33 | 34 | ****************** 35 | ###要求 36 | **系统**:iOS 5.0及以上(支持ARC)和Mac OX 10.7 Lion及以上 37 | **Xcode**:4.3及其以上 38 | [**JSONKit**](https://github.com/johnezang/JSONKit/) 39 | ****************** 40 | ###源文件说明 41 | ####依赖的开源库 42 | 迅雷离线API依赖的开源库有:[**JSONKit**](https://github.com/johnezang/JSONKit/) 43 | 44 | [**JSONKit**](https://github.com/johnezang/JSONKit/) 处理JSON的开源库,详细情况可以查看项目主页 45 | 46 | #####开源库的使用###### 47 | 具体方法就不写了,Google或者到各个项目主页很容易就可以查到。 48 | 需要注意的是在启用了ARC环境下如果使用不开启ARC的库,可以找到Target->Build Phases->Compile Sources->找到需要关闭ARC的.m文件,然后加入**-fno-objc-arc** 49 | ![图示1](http://ww4.sinaimg.cn/large/62d85d3dtw1dvybqxgbt3j.jpg ) 50 | 关于开源库的使用,当时为了开发的方便加入了三个开源库能够让我用最快的时间开发出来,把主要精力放在写正则上,现在iOS和Mac OS X对JSON和正则的支持也很不错,所以可能会去掉这两个开源库,用起来方便一些。 51 | 52 | ####API结构说明 53 | 迅雷离线API包含了10个文件 54 | 对外调用需要以下文件: 55 | HYXunleiLixianAPI,XunleiItemInfo 和Kuai 56 | HYXunleiLixianAPI 提供了获取任务列表,添加任务删除任务等功能 57 | XunleiItemInfo 提供了任务返回信息(包含任务名称,dcid等) 58 | Kuai中对外调用为其中的KuaiItemInfo类,包含了从迅雷快传提取任务的各种信息 59 | ******************* 60 | ###更新日志 61 | * 2013-9-27 修改了部分Bug,增加了对BT文件的支持 62 | * 2012-10-8 v0.6.2 去掉了对regexKitLite的依赖 63 | * 2012-10-8 v0.6.1 去掉了对ASIHTTP的依赖 64 | * 2012-8-22 v0.5 fix some bugs && 增加了对迅雷,旋风,Flashget专有下载链接格式的支持 65 | * 2012-8-21 v0.4.1 fix some bugs && update README 66 | * 2012-8-20 v0.4 released!,增加了迅雷快传 67 | * 2012-8-19 重写了接口 68 | 69 | ******************* 70 | ###反馈问题 71 | 有任何问题可以和lqik2004#gmail.com进行联系 72 | 或者到我的博客[http://res0w.com](http://res0w.com)进行留言 73 | 也可以Follow我的Twitter:[@lqik2004](https://twitter.com/lqik2004) 74 | ******************** 75 | ###许可证 76 | *在适当的时候我可能会更改许可证为MIT* 77 | 本项目采用[LGPL](http://www.gnu.org/copyleft/lesser.html)许可 78 | ![LGPL](http://www.gnu.org/graphics/lgplv3-147x51.png) -------------------------------------------------------------------------------- /TondarAPI.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 020E1F4B15DCF40B00FF99ED /* HYXunleiLixianAPI.h in Headers */ = {isa = PBXBuildFile; fileRef = 020E1F4915DCF40B00FF99ED /* HYXunleiLixianAPI.h */; settings = {ATTRIBUTES = (Public, ); }; }; 11 | 020E1F4C15DCF40B00FF99ED /* HYXunleiLixianAPI.m in Sources */ = {isa = PBXBuildFile; fileRef = 020E1F4A15DCF40B00FF99ED /* HYXunleiLixianAPI.m */; }; 12 | 020E1F5015DCF41500FF99ED /* md5.h in Headers */ = {isa = PBXBuildFile; fileRef = 020E1F4E15DCF41400FF99ED /* md5.h */; }; 13 | 020E1F5115DCF41500FF99ED /* md5.m in Sources */ = {isa = PBXBuildFile; fileRef = 020E1F4F15DCF41500FF99ED /* md5.m */; }; 14 | 020E1F5415DCF42300FF99ED /* ParseElements.h in Headers */ = {isa = PBXBuildFile; fileRef = 020E1F5215DCF42100FF99ED /* ParseElements.h */; }; 15 | 020E1F5515DCF42300FF99ED /* ParseElements.m in Sources */ = {isa = PBXBuildFile; fileRef = 020E1F5315DCF42200FF99ED /* ParseElements.m */; }; 16 | 020E1F5815DCF45F00FF99ED /* URlEncode.h in Headers */ = {isa = PBXBuildFile; fileRef = 020E1F5615DCF45E00FF99ED /* URlEncode.h */; }; 17 | 020E1F5915DCF45F00FF99ED /* URlEncode.m in Sources */ = {isa = PBXBuildFile; fileRef = 020E1F5715DCF45F00FF99ED /* URlEncode.m */; }; 18 | 020E1F5C15DCF46B00FF99ED /* XunleiItemInfo.h in Headers */ = {isa = PBXBuildFile; fileRef = 020E1F5A15DCF46A00FF99ED /* XunleiItemInfo.h */; settings = {ATTRIBUTES = (Public, ); }; }; 19 | 020E1F5D15DCF46B00FF99ED /* XunleiItemInfo.m in Sources */ = {isa = PBXBuildFile; fileRef = 020E1F5B15DCF46A00FF99ED /* XunleiItemInfo.m */; }; 20 | 020E1F7115DCF5A900FF99ED /* JSONKit.h in Headers */ = {isa = PBXBuildFile; fileRef = 020E1F6F15DCF5A900FF99ED /* JSONKit.h */; }; 21 | 020E1F7215DCF5A900FF99ED /* JSONKit.m in Sources */ = {isa = PBXBuildFile; fileRef = 020E1F7015DCF5A900FF99ED /* JSONKit.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; }; 22 | 02C066B115DCF700008AF890 /* SystemConfiguration.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 02C066B015DCF700008AF890 /* SystemConfiguration.framework */; }; 23 | 02C066B315DCF70E008AF890 /* libz.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 02C066B215DCF70E008AF890 /* libz.dylib */; }; 24 | 02C066B515DCF80B008AF890 /* CFNetwork.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 02C066B415DCF80B008AF890 /* CFNetwork.framework */; }; 25 | 02F155BC15C547220054EF51 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 02F155BB15C547220054EF51 /* Cocoa.framework */; }; 26 | 02F155C615C547220054EF51 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 02F155C415C547220054EF51 /* InfoPlist.strings */; }; 27 | 02F155D215C547220054EF51 /* SenTestingKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 02F155D115C547220054EF51 /* SenTestingKit.framework */; }; 28 | 02F155D315C547220054EF51 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 02F155BB15C547220054EF51 /* Cocoa.framework */; }; 29 | 02F155D615C547220054EF51 /* TondarAPI.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 02F155B815C547220054EF51 /* TondarAPI.framework */; }; 30 | 02F155DC15C547220054EF51 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 02F155DA15C547220054EF51 /* InfoPlist.strings */; }; 31 | 02F155DF15C547220054EF51 /* TondarAPITests.m in Sources */ = {isa = PBXBuildFile; fileRef = 02F155DE15C547220054EF51 /* TondarAPITests.m */; }; 32 | A81275021622B2A2002A92F4 /* LCHTTPConnection.h in Headers */ = {isa = PBXBuildFile; fileRef = A81275001622B2A2002A92F4 /* LCHTTPConnection.h */; }; 33 | A81275031622B2A2002A92F4 /* LCHTTPConnection.m in Sources */ = {isa = PBXBuildFile; fileRef = A81275011622B2A2002A92F4 /* LCHTTPConnection.m */; }; 34 | A81275041622B2A2002A92F4 /* LCHTTPConnection.m in Sources */ = {isa = PBXBuildFile; fileRef = A81275011622B2A2002A92F4 /* LCHTTPConnection.m */; }; 35 | A81275051622B2A2002A92F4 /* LCHTTPConnection.m in Sources */ = {isa = PBXBuildFile; fileRef = A81275011622B2A2002A92F4 /* LCHTTPConnection.m */; }; 36 | A81275111622F0AF002A92F4 /* NSString+RE.h in Headers */ = {isa = PBXBuildFile; fileRef = A812750F1622F0AF002A92F4 /* NSString+RE.h */; }; 37 | A81275121622F0AF002A92F4 /* NSString+RE.m in Sources */ = {isa = PBXBuildFile; fileRef = A81275101622F0AF002A92F4 /* NSString+RE.m */; }; 38 | A81275131622F0AF002A92F4 /* NSString+RE.m in Sources */ = {isa = PBXBuildFile; fileRef = A81275101622F0AF002A92F4 /* NSString+RE.m */; }; 39 | A81275141622F0AF002A92F4 /* NSString+RE.m in Sources */ = {isa = PBXBuildFile; fileRef = A81275101622F0AF002A92F4 /* NSString+RE.m */; }; 40 | A83FEE7D15E3E23900FD8907 /* NSData+Base64.h in Headers */ = {isa = PBXBuildFile; fileRef = A83FEE7915E3E23900FD8907 /* NSData+Base64.h */; }; 41 | A83FEE7E15E3E23900FD8907 /* NSData+Base64.m in Sources */ = {isa = PBXBuildFile; fileRef = A83FEE7A15E3E23900FD8907 /* NSData+Base64.m */; }; 42 | A83FEE7F15E3E23900FD8907 /* NSData+Base64.m in Sources */ = {isa = PBXBuildFile; fileRef = A83FEE7A15E3E23900FD8907 /* NSData+Base64.m */; }; 43 | A83FEE8015E3E23900FD8907 /* NSString+Base64.h in Headers */ = {isa = PBXBuildFile; fileRef = A83FEE7B15E3E23900FD8907 /* NSString+Base64.h */; }; 44 | A83FEE8115E3E23900FD8907 /* NSString+Base64.m in Sources */ = {isa = PBXBuildFile; fileRef = A83FEE7C15E3E23900FD8907 /* NSString+Base64.m */; }; 45 | A83FEE8215E3E23900FD8907 /* NSString+Base64.m in Sources */ = {isa = PBXBuildFile; fileRef = A83FEE7C15E3E23900FD8907 /* NSString+Base64.m */; }; 46 | A83FEE8715E3E2AA00FD8907 /* ConvertURL.h in Headers */ = {isa = PBXBuildFile; fileRef = A83FEE8515E3E2AA00FD8907 /* ConvertURL.h */; }; 47 | A83FEE8815E3E2AA00FD8907 /* ConvertURL.m in Sources */ = {isa = PBXBuildFile; fileRef = A83FEE8615E3E2AA00FD8907 /* ConvertURL.m */; }; 48 | A83FEE8915E3E2AA00FD8907 /* ConvertURL.m in Sources */ = {isa = PBXBuildFile; fileRef = A83FEE8615E3E2AA00FD8907 /* ConvertURL.m */; }; 49 | A83FEE9015E3E5EF00FD8907 /* SenTestingKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 02F155D115C547220054EF51 /* SenTestingKit.framework */; }; 50 | A83FEE9A15E3E5EF00FD8907 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = A83FEE9815E3E5EF00FD8907 /* InfoPlist.strings */; }; 51 | A83FEE9D15E3E5EF00FD8907 /* URLTesting.m in Sources */ = {isa = PBXBuildFile; fileRef = A83FEE9C15E3E5EF00FD8907 /* URLTesting.m */; }; 52 | A83FEEA315E3E7A100FD8907 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A83FEEA215E3E7A100FD8907 /* Cocoa.framework */; }; 53 | A88FDA9C15E22E1800BCB116 /* Kuai.h in Headers */ = {isa = PBXBuildFile; fileRef = A88FDA9A15E22E1800BCB116 /* Kuai.h */; }; 54 | A88FDA9D15E22E1800BCB116 /* Kuai.m in Sources */ = {isa = PBXBuildFile; fileRef = A88FDA9B15E22E1800BCB116 /* Kuai.m */; }; 55 | A88FDA9E15E22E1800BCB116 /* Kuai.m in Sources */ = {isa = PBXBuildFile; fileRef = A88FDA9B15E22E1800BCB116 /* Kuai.m */; }; 56 | /* End PBXBuildFile section */ 57 | 58 | /* Begin PBXContainerItemProxy section */ 59 | 02F155D415C547220054EF51 /* PBXContainerItemProxy */ = { 60 | isa = PBXContainerItemProxy; 61 | containerPortal = 02F155AE15C547220054EF51 /* Project object */; 62 | proxyType = 1; 63 | remoteGlobalIDString = 02F155B715C547220054EF51; 64 | remoteInfo = TondarAPI; 65 | }; 66 | /* End PBXContainerItemProxy section */ 67 | 68 | /* Begin PBXFileReference section */ 69 | 020E1F4915DCF40B00FF99ED /* HYXunleiLixianAPI.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HYXunleiLixianAPI.h; sourceTree = ""; }; 70 | 020E1F4A15DCF40B00FF99ED /* HYXunleiLixianAPI.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HYXunleiLixianAPI.m; sourceTree = ""; }; 71 | 020E1F4E15DCF41400FF99ED /* md5.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = md5.h; sourceTree = ""; }; 72 | 020E1F4F15DCF41500FF99ED /* md5.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = md5.m; sourceTree = ""; }; 73 | 020E1F5215DCF42100FF99ED /* ParseElements.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ParseElements.h; sourceTree = ""; }; 74 | 020E1F5315DCF42200FF99ED /* ParseElements.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ParseElements.m; sourceTree = ""; }; 75 | 020E1F5615DCF45E00FF99ED /* URlEncode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = URlEncode.h; sourceTree = ""; }; 76 | 020E1F5715DCF45F00FF99ED /* URlEncode.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = URlEncode.m; sourceTree = ""; }; 77 | 020E1F5A15DCF46A00FF99ED /* XunleiItemInfo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = XunleiItemInfo.h; sourceTree = ""; }; 78 | 020E1F5B15DCF46A00FF99ED /* XunleiItemInfo.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = XunleiItemInfo.m; sourceTree = ""; }; 79 | 020E1F6F15DCF5A900FF99ED /* JSONKit.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = JSONKit.h; path = JSONKit/JSONKit.h; sourceTree = ""; }; 80 | 020E1F7015DCF5A900FF99ED /* JSONKit.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = JSONKit.m; path = JSONKit/JSONKit.m; sourceTree = ""; }; 81 | 02C066B015DCF700008AF890 /* SystemConfiguration.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SystemConfiguration.framework; path = System/Library/Frameworks/SystemConfiguration.framework; sourceTree = SDKROOT; }; 82 | 02C066B215DCF70E008AF890 /* libz.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libz.dylib; path = usr/lib/libz.dylib; sourceTree = SDKROOT; }; 83 | 02C066B415DCF80B008AF890 /* CFNetwork.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CFNetwork.framework; path = Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/CFNetwork.framework; sourceTree = DEVELOPER_DIR; }; 84 | 02F155B815C547220054EF51 /* TondarAPI.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = TondarAPI.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 85 | 02F155BB15C547220054EF51 /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = System/Library/Frameworks/Cocoa.framework; sourceTree = SDKROOT; }; 86 | 02F155BE15C547220054EF51 /* AppKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AppKit.framework; path = System/Library/Frameworks/AppKit.framework; sourceTree = SDKROOT; }; 87 | 02F155BF15C547220054EF51 /* CoreData.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreData.framework; path = System/Library/Frameworks/CoreData.framework; sourceTree = SDKROOT; }; 88 | 02F155C015C547220054EF51 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; 89 | 02F155C315C547220054EF51 /* TondarAPI-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "TondarAPI-Info.plist"; sourceTree = ""; }; 90 | 02F155C515C547220054EF51 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = ""; }; 91 | 02F155C715C547220054EF51 /* TondarAPI-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "TondarAPI-Prefix.pch"; sourceTree = ""; }; 92 | 02F155D015C547220054EF51 /* TondarAPITests.octest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = TondarAPITests.octest; sourceTree = BUILT_PRODUCTS_DIR; }; 93 | 02F155D115C547220054EF51 /* SenTestingKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SenTestingKit.framework; path = Library/Frameworks/SenTestingKit.framework; sourceTree = DEVELOPER_DIR; }; 94 | 02F155D915C547220054EF51 /* TondarAPITests-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "TondarAPITests-Info.plist"; sourceTree = ""; }; 95 | 02F155DB15C547220054EF51 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = ""; }; 96 | 02F155DD15C547220054EF51 /* TondarAPITests.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = TondarAPITests.h; sourceTree = ""; }; 97 | 02F155DE15C547220054EF51 /* TondarAPITests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = TondarAPITests.m; sourceTree = ""; }; 98 | A81275001622B2A2002A92F4 /* LCHTTPConnection.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LCHTTPConnection.h; sourceTree = ""; }; 99 | A81275011622B2A2002A92F4 /* LCHTTPConnection.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LCHTTPConnection.m; sourceTree = ""; }; 100 | A812750F1622F0AF002A92F4 /* NSString+RE.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSString+RE.h"; sourceTree = ""; }; 101 | A81275101622F0AF002A92F4 /* NSString+RE.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSString+RE.m"; sourceTree = ""; }; 102 | A83FEE7915E3E23900FD8907 /* NSData+Base64.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSData+Base64.h"; sourceTree = ""; }; 103 | A83FEE7A15E3E23900FD8907 /* NSData+Base64.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSData+Base64.m"; sourceTree = ""; }; 104 | A83FEE7B15E3E23900FD8907 /* NSString+Base64.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSString+Base64.h"; sourceTree = ""; }; 105 | A83FEE7C15E3E23900FD8907 /* NSString+Base64.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSString+Base64.m"; sourceTree = ""; }; 106 | A83FEE8515E3E2AA00FD8907 /* ConvertURL.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ConvertURL.h; sourceTree = ""; }; 107 | A83FEE8615E3E2AA00FD8907 /* ConvertURL.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ConvertURL.m; sourceTree = ""; }; 108 | A83FEE8F15E3E5EF00FD8907 /* URLTesting.octest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = URLTesting.octest; sourceTree = BUILT_PRODUCTS_DIR; }; 109 | A83FEE9115E3E5EF00FD8907 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = Library/Frameworks/UIKit.framework; sourceTree = DEVELOPER_DIR; }; 110 | A83FEE9315E3E5EF00FD8907 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = Library/Frameworks/Foundation.framework; sourceTree = DEVELOPER_DIR; }; 111 | A83FEE9715E3E5EF00FD8907 /* URLTesting-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "URLTesting-Info.plist"; sourceTree = ""; }; 112 | A83FEE9915E3E5EF00FD8907 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = ""; }; 113 | A83FEE9B15E3E5EF00FD8907 /* URLTesting.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = URLTesting.h; sourceTree = ""; }; 114 | A83FEE9C15E3E5EF00FD8907 /* URLTesting.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = URLTesting.m; sourceTree = ""; }; 115 | A83FEE9E15E3E5EF00FD8907 /* URLTesting-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "URLTesting-Prefix.pch"; sourceTree = ""; }; 116 | A83FEEA215E3E7A100FD8907 /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Cocoa.framework; sourceTree = DEVELOPER_DIR; }; 117 | A88FDA9A15E22E1800BCB116 /* Kuai.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Kuai.h; sourceTree = ""; }; 118 | A88FDA9B15E22E1800BCB116 /* Kuai.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Kuai.m; sourceTree = ""; }; 119 | /* End PBXFileReference section */ 120 | 121 | /* Begin PBXFrameworksBuildPhase section */ 122 | 02F155B415C547220054EF51 /* Frameworks */ = { 123 | isa = PBXFrameworksBuildPhase; 124 | buildActionMask = 2147483647; 125 | files = ( 126 | 02C066B515DCF80B008AF890 /* CFNetwork.framework in Frameworks */, 127 | 02C066B315DCF70E008AF890 /* libz.dylib in Frameworks */, 128 | 02C066B115DCF700008AF890 /* SystemConfiguration.framework in Frameworks */, 129 | 02F155BC15C547220054EF51 /* Cocoa.framework in Frameworks */, 130 | ); 131 | runOnlyForDeploymentPostprocessing = 0; 132 | }; 133 | 02F155CC15C547220054EF51 /* Frameworks */ = { 134 | isa = PBXFrameworksBuildPhase; 135 | buildActionMask = 2147483647; 136 | files = ( 137 | 02F155D215C547220054EF51 /* SenTestingKit.framework in Frameworks */, 138 | 02F155D315C547220054EF51 /* Cocoa.framework in Frameworks */, 139 | 02F155D615C547220054EF51 /* TondarAPI.framework in Frameworks */, 140 | ); 141 | runOnlyForDeploymentPostprocessing = 0; 142 | }; 143 | A83FEE8B15E3E5EF00FD8907 /* Frameworks */ = { 144 | isa = PBXFrameworksBuildPhase; 145 | buildActionMask = 2147483647; 146 | files = ( 147 | A83FEEA315E3E7A100FD8907 /* Cocoa.framework in Frameworks */, 148 | A83FEE9015E3E5EF00FD8907 /* SenTestingKit.framework in Frameworks */, 149 | ); 150 | runOnlyForDeploymentPostprocessing = 0; 151 | }; 152 | /* End PBXFrameworksBuildPhase section */ 153 | 154 | /* Begin PBXGroup section */ 155 | 020E1F7315DCF5AB00FF99ED /* JSONKit */ = { 156 | isa = PBXGroup; 157 | children = ( 158 | 020E1F6F15DCF5A900FF99ED /* JSONKit.h */, 159 | 020E1F7015DCF5A900FF99ED /* JSONKit.m */, 160 | ); 161 | name = JSONKit; 162 | sourceTree = ""; 163 | }; 164 | 026EB2D515C54C5F0005909F /* Utility */ = { 165 | isa = PBXGroup; 166 | children = ( 167 | A812750E1622F097002A92F4 /* LCRegexKit */, 168 | A83FEE8415E3E23D00FD8907 /* Base64 */, 169 | 02C066BF15DCFB22008AF890 /* LCHTTPConnection */, 170 | 020E1F7315DCF5AB00FF99ED /* JSONKit */, 171 | ); 172 | name = Utility; 173 | sourceTree = ""; 174 | }; 175 | 026EB2DA15C550E60005909F /* Tondar */ = { 176 | isa = PBXGroup; 177 | children = ( 178 | 020E1F4915DCF40B00FF99ED /* HYXunleiLixianAPI.h */, 179 | 020E1F4A15DCF40B00FF99ED /* HYXunleiLixianAPI.m */, 180 | 020E1F4E15DCF41400FF99ED /* md5.h */, 181 | 020E1F4F15DCF41500FF99ED /* md5.m */, 182 | 020E1F5215DCF42100FF99ED /* ParseElements.h */, 183 | 020E1F5315DCF42200FF99ED /* ParseElements.m */, 184 | 020E1F5615DCF45E00FF99ED /* URlEncode.h */, 185 | 020E1F5715DCF45F00FF99ED /* URlEncode.m */, 186 | 020E1F5A15DCF46A00FF99ED /* XunleiItemInfo.h */, 187 | 020E1F5B15DCF46A00FF99ED /* XunleiItemInfo.m */, 188 | A88FDA9A15E22E1800BCB116 /* Kuai.h */, 189 | A88FDA9B15E22E1800BCB116 /* Kuai.m */, 190 | A83FEE8515E3E2AA00FD8907 /* ConvertURL.h */, 191 | A83FEE8615E3E2AA00FD8907 /* ConvertURL.m */, 192 | ); 193 | name = Tondar; 194 | sourceTree = ""; 195 | }; 196 | 02C066BF15DCFB22008AF890 /* LCHTTPConnection */ = { 197 | isa = PBXGroup; 198 | children = ( 199 | A81275001622B2A2002A92F4 /* LCHTTPConnection.h */, 200 | A81275011622B2A2002A92F4 /* LCHTTPConnection.m */, 201 | ); 202 | name = LCHTTPConnection; 203 | sourceTree = ""; 204 | }; 205 | 02F155AC15C547220054EF51 = { 206 | isa = PBXGroup; 207 | children = ( 208 | 02F155C115C547220054EF51 /* TondarAPI */, 209 | 02F155D715C547220054EF51 /* TondarAPITests */, 210 | A83FEE9515E3E5EF00FD8907 /* URLTesting */, 211 | 02F155BA15C547220054EF51 /* Frameworks */, 212 | 02F155B915C547220054EF51 /* Products */, 213 | ); 214 | sourceTree = ""; 215 | }; 216 | 02F155B915C547220054EF51 /* Products */ = { 217 | isa = PBXGroup; 218 | children = ( 219 | 02F155B815C547220054EF51 /* TondarAPI.framework */, 220 | 02F155D015C547220054EF51 /* TondarAPITests.octest */, 221 | A83FEE8F15E3E5EF00FD8907 /* URLTesting.octest */, 222 | ); 223 | name = Products; 224 | sourceTree = ""; 225 | }; 226 | 02F155BA15C547220054EF51 /* Frameworks */ = { 227 | isa = PBXGroup; 228 | children = ( 229 | A83FEEA215E3E7A100FD8907 /* Cocoa.framework */, 230 | 02C066B215DCF70E008AF890 /* libz.dylib */, 231 | 02C066B415DCF80B008AF890 /* CFNetwork.framework */, 232 | 02C066B015DCF700008AF890 /* SystemConfiguration.framework */, 233 | 02F155BB15C547220054EF51 /* Cocoa.framework */, 234 | 02F155D115C547220054EF51 /* SenTestingKit.framework */, 235 | A83FEE9115E3E5EF00FD8907 /* UIKit.framework */, 236 | A83FEE9315E3E5EF00FD8907 /* Foundation.framework */, 237 | 02F155BD15C547220054EF51 /* Other Frameworks */, 238 | ); 239 | name = Frameworks; 240 | sourceTree = ""; 241 | }; 242 | 02F155BD15C547220054EF51 /* Other Frameworks */ = { 243 | isa = PBXGroup; 244 | children = ( 245 | 02F155BE15C547220054EF51 /* AppKit.framework */, 246 | 02F155BF15C547220054EF51 /* CoreData.framework */, 247 | 02F155C015C547220054EF51 /* Foundation.framework */, 248 | ); 249 | name = "Other Frameworks"; 250 | sourceTree = ""; 251 | }; 252 | 02F155C115C547220054EF51 /* TondarAPI */ = { 253 | isa = PBXGroup; 254 | children = ( 255 | 026EB2DA15C550E60005909F /* Tondar */, 256 | 026EB2D515C54C5F0005909F /* Utility */, 257 | 02F155C215C547220054EF51 /* Supporting Files */, 258 | ); 259 | path = TondarAPI; 260 | sourceTree = ""; 261 | }; 262 | 02F155C215C547220054EF51 /* Supporting Files */ = { 263 | isa = PBXGroup; 264 | children = ( 265 | 02F155C315C547220054EF51 /* TondarAPI-Info.plist */, 266 | 02F155C415C547220054EF51 /* InfoPlist.strings */, 267 | 02F155C715C547220054EF51 /* TondarAPI-Prefix.pch */, 268 | ); 269 | name = "Supporting Files"; 270 | sourceTree = ""; 271 | }; 272 | 02F155D715C547220054EF51 /* TondarAPITests */ = { 273 | isa = PBXGroup; 274 | children = ( 275 | 02F155DD15C547220054EF51 /* TondarAPITests.h */, 276 | 02F155DE15C547220054EF51 /* TondarAPITests.m */, 277 | 02F155D815C547220054EF51 /* Supporting Files */, 278 | ); 279 | path = TondarAPITests; 280 | sourceTree = ""; 281 | }; 282 | 02F155D815C547220054EF51 /* Supporting Files */ = { 283 | isa = PBXGroup; 284 | children = ( 285 | 02F155D915C547220054EF51 /* TondarAPITests-Info.plist */, 286 | 02F155DA15C547220054EF51 /* InfoPlist.strings */, 287 | ); 288 | name = "Supporting Files"; 289 | sourceTree = ""; 290 | }; 291 | A812750E1622F097002A92F4 /* LCRegexKit */ = { 292 | isa = PBXGroup; 293 | children = ( 294 | A812750F1622F0AF002A92F4 /* NSString+RE.h */, 295 | A81275101622F0AF002A92F4 /* NSString+RE.m */, 296 | ); 297 | name = LCRegexKit; 298 | sourceTree = ""; 299 | }; 300 | A83FEE8415E3E23D00FD8907 /* Base64 */ = { 301 | isa = PBXGroup; 302 | children = ( 303 | A83FEE7915E3E23900FD8907 /* NSData+Base64.h */, 304 | A83FEE7A15E3E23900FD8907 /* NSData+Base64.m */, 305 | A83FEE7B15E3E23900FD8907 /* NSString+Base64.h */, 306 | A83FEE7C15E3E23900FD8907 /* NSString+Base64.m */, 307 | ); 308 | name = Base64; 309 | sourceTree = ""; 310 | }; 311 | A83FEE9515E3E5EF00FD8907 /* URLTesting */ = { 312 | isa = PBXGroup; 313 | children = ( 314 | A83FEE9B15E3E5EF00FD8907 /* URLTesting.h */, 315 | A83FEE9C15E3E5EF00FD8907 /* URLTesting.m */, 316 | A83FEE9615E3E5EF00FD8907 /* Supporting Files */, 317 | ); 318 | path = URLTesting; 319 | sourceTree = ""; 320 | }; 321 | A83FEE9615E3E5EF00FD8907 /* Supporting Files */ = { 322 | isa = PBXGroup; 323 | children = ( 324 | A83FEE9715E3E5EF00FD8907 /* URLTesting-Info.plist */, 325 | A83FEE9815E3E5EF00FD8907 /* InfoPlist.strings */, 326 | A83FEE9E15E3E5EF00FD8907 /* URLTesting-Prefix.pch */, 327 | ); 328 | name = "Supporting Files"; 329 | sourceTree = ""; 330 | }; 331 | /* End PBXGroup section */ 332 | 333 | /* Begin PBXHeadersBuildPhase section */ 334 | 02F155B515C547220054EF51 /* Headers */ = { 335 | isa = PBXHeadersBuildPhase; 336 | buildActionMask = 2147483647; 337 | files = ( 338 | 020E1F4B15DCF40B00FF99ED /* HYXunleiLixianAPI.h in Headers */, 339 | 020E1F5C15DCF46B00FF99ED /* XunleiItemInfo.h in Headers */, 340 | 020E1F5015DCF41500FF99ED /* md5.h in Headers */, 341 | 020E1F5415DCF42300FF99ED /* ParseElements.h in Headers */, 342 | 020E1F5815DCF45F00FF99ED /* URlEncode.h in Headers */, 343 | 020E1F7115DCF5A900FF99ED /* JSONKit.h in Headers */, 344 | A88FDA9C15E22E1800BCB116 /* Kuai.h in Headers */, 345 | A83FEE7D15E3E23900FD8907 /* NSData+Base64.h in Headers */, 346 | A83FEE8015E3E23900FD8907 /* NSString+Base64.h in Headers */, 347 | A83FEE8715E3E2AA00FD8907 /* ConvertURL.h in Headers */, 348 | A81275021622B2A2002A92F4 /* LCHTTPConnection.h in Headers */, 349 | A81275111622F0AF002A92F4 /* NSString+RE.h in Headers */, 350 | ); 351 | runOnlyForDeploymentPostprocessing = 0; 352 | }; 353 | /* End PBXHeadersBuildPhase section */ 354 | 355 | /* Begin PBXNativeTarget section */ 356 | 02F155B715C547220054EF51 /* TondarAPI */ = { 357 | isa = PBXNativeTarget; 358 | buildConfigurationList = 02F155E215C547220054EF51 /* Build configuration list for PBXNativeTarget "TondarAPI" */; 359 | buildPhases = ( 360 | 02F155B315C547220054EF51 /* Sources */, 361 | 02F155B415C547220054EF51 /* Frameworks */, 362 | 02F155B515C547220054EF51 /* Headers */, 363 | 02F155B615C547220054EF51 /* Resources */, 364 | ); 365 | buildRules = ( 366 | ); 367 | dependencies = ( 368 | ); 369 | name = TondarAPI; 370 | productName = TondarAPI; 371 | productReference = 02F155B815C547220054EF51 /* TondarAPI.framework */; 372 | productType = "com.apple.product-type.framework"; 373 | }; 374 | 02F155CF15C547220054EF51 /* TondarAPITests */ = { 375 | isa = PBXNativeTarget; 376 | buildConfigurationList = 02F155E515C547220054EF51 /* Build configuration list for PBXNativeTarget "TondarAPITests" */; 377 | buildPhases = ( 378 | 02F155CB15C547220054EF51 /* Sources */, 379 | 02F155CC15C547220054EF51 /* Frameworks */, 380 | 02F155CD15C547220054EF51 /* Resources */, 381 | 02F155CE15C547220054EF51 /* ShellScript */, 382 | ); 383 | buildRules = ( 384 | ); 385 | dependencies = ( 386 | 02F155D515C547220054EF51 /* PBXTargetDependency */, 387 | ); 388 | name = TondarAPITests; 389 | productName = TondarAPITests; 390 | productReference = 02F155D015C547220054EF51 /* TondarAPITests.octest */; 391 | productType = "com.apple.product-type.bundle"; 392 | }; 393 | A83FEE8E15E3E5EF00FD8907 /* URLTesting */ = { 394 | isa = PBXNativeTarget; 395 | buildConfigurationList = A83FEE9F15E3E5EF00FD8907 /* Build configuration list for PBXNativeTarget "URLTesting" */; 396 | buildPhases = ( 397 | A83FEE8A15E3E5EF00FD8907 /* Sources */, 398 | A83FEE8B15E3E5EF00FD8907 /* Frameworks */, 399 | A83FEE8C15E3E5EF00FD8907 /* Resources */, 400 | A83FEE8D15E3E5EF00FD8907 /* ShellScript */, 401 | ); 402 | buildRules = ( 403 | ); 404 | dependencies = ( 405 | ); 406 | name = URLTesting; 407 | productName = URLTesting; 408 | productReference = A83FEE8F15E3E5EF00FD8907 /* URLTesting.octest */; 409 | productType = "com.apple.product-type.bundle"; 410 | }; 411 | /* End PBXNativeTarget section */ 412 | 413 | /* Begin PBXProject section */ 414 | 02F155AE15C547220054EF51 /* Project object */ = { 415 | isa = PBXProject; 416 | attributes = { 417 | LastUpgradeCheck = 0440; 418 | ORGANIZATIONNAME = MartianZ; 419 | }; 420 | buildConfigurationList = 02F155B115C547220054EF51 /* Build configuration list for PBXProject "TondarAPI" */; 421 | compatibilityVersion = "Xcode 3.2"; 422 | developmentRegion = English; 423 | hasScannedForEncodings = 0; 424 | knownRegions = ( 425 | en, 426 | ); 427 | mainGroup = 02F155AC15C547220054EF51; 428 | productRefGroup = 02F155B915C547220054EF51 /* Products */; 429 | projectDirPath = ""; 430 | projectRoot = ""; 431 | targets = ( 432 | 02F155B715C547220054EF51 /* TondarAPI */, 433 | 02F155CF15C547220054EF51 /* TondarAPITests */, 434 | A83FEE8E15E3E5EF00FD8907 /* URLTesting */, 435 | ); 436 | }; 437 | /* End PBXProject section */ 438 | 439 | /* Begin PBXResourcesBuildPhase section */ 440 | 02F155B615C547220054EF51 /* Resources */ = { 441 | isa = PBXResourcesBuildPhase; 442 | buildActionMask = 2147483647; 443 | files = ( 444 | 02F155C615C547220054EF51 /* InfoPlist.strings in Resources */, 445 | ); 446 | runOnlyForDeploymentPostprocessing = 0; 447 | }; 448 | 02F155CD15C547220054EF51 /* Resources */ = { 449 | isa = PBXResourcesBuildPhase; 450 | buildActionMask = 2147483647; 451 | files = ( 452 | 02F155DC15C547220054EF51 /* InfoPlist.strings in Resources */, 453 | ); 454 | runOnlyForDeploymentPostprocessing = 0; 455 | }; 456 | A83FEE8C15E3E5EF00FD8907 /* Resources */ = { 457 | isa = PBXResourcesBuildPhase; 458 | buildActionMask = 2147483647; 459 | files = ( 460 | A83FEE9A15E3E5EF00FD8907 /* InfoPlist.strings in Resources */, 461 | ); 462 | runOnlyForDeploymentPostprocessing = 0; 463 | }; 464 | /* End PBXResourcesBuildPhase section */ 465 | 466 | /* Begin PBXShellScriptBuildPhase section */ 467 | 02F155CE15C547220054EF51 /* ShellScript */ = { 468 | isa = PBXShellScriptBuildPhase; 469 | buildActionMask = 2147483647; 470 | files = ( 471 | ); 472 | inputPaths = ( 473 | ); 474 | outputPaths = ( 475 | ); 476 | runOnlyForDeploymentPostprocessing = 0; 477 | shellPath = /bin/sh; 478 | shellScript = "# Run the unit tests in this test bundle.\n\"${SYSTEM_DEVELOPER_DIR}/Tools/RunUnitTests\"\n"; 479 | }; 480 | A83FEE8D15E3E5EF00FD8907 /* ShellScript */ = { 481 | isa = PBXShellScriptBuildPhase; 482 | buildActionMask = 2147483647; 483 | files = ( 484 | ); 485 | inputPaths = ( 486 | ); 487 | outputPaths = ( 488 | ); 489 | runOnlyForDeploymentPostprocessing = 0; 490 | shellPath = /bin/sh; 491 | shellScript = "# Run the unit tests in this test bundle.\n\"${SYSTEM_DEVELOPER_DIR}/Tools/RunUnitTests\"\n"; 492 | }; 493 | /* End PBXShellScriptBuildPhase section */ 494 | 495 | /* Begin PBXSourcesBuildPhase section */ 496 | 02F155B315C547220054EF51 /* Sources */ = { 497 | isa = PBXSourcesBuildPhase; 498 | buildActionMask = 2147483647; 499 | files = ( 500 | 020E1F4C15DCF40B00FF99ED /* HYXunleiLixianAPI.m in Sources */, 501 | 020E1F5115DCF41500FF99ED /* md5.m in Sources */, 502 | 020E1F5515DCF42300FF99ED /* ParseElements.m in Sources */, 503 | 020E1F5915DCF45F00FF99ED /* URlEncode.m in Sources */, 504 | 020E1F5D15DCF46B00FF99ED /* XunleiItemInfo.m in Sources */, 505 | 020E1F7215DCF5A900FF99ED /* JSONKit.m in Sources */, 506 | A88FDA9D15E22E1800BCB116 /* Kuai.m in Sources */, 507 | A83FEE7E15E3E23900FD8907 /* NSData+Base64.m in Sources */, 508 | A83FEE8115E3E23900FD8907 /* NSString+Base64.m in Sources */, 509 | A83FEE8815E3E2AA00FD8907 /* ConvertURL.m in Sources */, 510 | A81275031622B2A2002A92F4 /* LCHTTPConnection.m in Sources */, 511 | A81275121622F0AF002A92F4 /* NSString+RE.m in Sources */, 512 | ); 513 | runOnlyForDeploymentPostprocessing = 0; 514 | }; 515 | 02F155CB15C547220054EF51 /* Sources */ = { 516 | isa = PBXSourcesBuildPhase; 517 | buildActionMask = 2147483647; 518 | files = ( 519 | 02F155DF15C547220054EF51 /* TondarAPITests.m in Sources */, 520 | A88FDA9E15E22E1800BCB116 /* Kuai.m in Sources */, 521 | A83FEE7F15E3E23900FD8907 /* NSData+Base64.m in Sources */, 522 | A83FEE8215E3E23900FD8907 /* NSString+Base64.m in Sources */, 523 | A83FEE8915E3E2AA00FD8907 /* ConvertURL.m in Sources */, 524 | A81275041622B2A2002A92F4 /* LCHTTPConnection.m in Sources */, 525 | A81275131622F0AF002A92F4 /* NSString+RE.m in Sources */, 526 | ); 527 | runOnlyForDeploymentPostprocessing = 0; 528 | }; 529 | A83FEE8A15E3E5EF00FD8907 /* Sources */ = { 530 | isa = PBXSourcesBuildPhase; 531 | buildActionMask = 2147483647; 532 | files = ( 533 | A83FEE9D15E3E5EF00FD8907 /* URLTesting.m in Sources */, 534 | A81275051622B2A2002A92F4 /* LCHTTPConnection.m in Sources */, 535 | A81275141622F0AF002A92F4 /* NSString+RE.m in Sources */, 536 | ); 537 | runOnlyForDeploymentPostprocessing = 0; 538 | }; 539 | /* End PBXSourcesBuildPhase section */ 540 | 541 | /* Begin PBXTargetDependency section */ 542 | 02F155D515C547220054EF51 /* PBXTargetDependency */ = { 543 | isa = PBXTargetDependency; 544 | target = 02F155B715C547220054EF51 /* TondarAPI */; 545 | targetProxy = 02F155D415C547220054EF51 /* PBXContainerItemProxy */; 546 | }; 547 | /* End PBXTargetDependency section */ 548 | 549 | /* Begin PBXVariantGroup section */ 550 | 02F155C415C547220054EF51 /* InfoPlist.strings */ = { 551 | isa = PBXVariantGroup; 552 | children = ( 553 | 02F155C515C547220054EF51 /* en */, 554 | ); 555 | name = InfoPlist.strings; 556 | sourceTree = ""; 557 | }; 558 | 02F155DA15C547220054EF51 /* InfoPlist.strings */ = { 559 | isa = PBXVariantGroup; 560 | children = ( 561 | 02F155DB15C547220054EF51 /* en */, 562 | ); 563 | name = InfoPlist.strings; 564 | sourceTree = ""; 565 | }; 566 | A83FEE9815E3E5EF00FD8907 /* InfoPlist.strings */ = { 567 | isa = PBXVariantGroup; 568 | children = ( 569 | A83FEE9915E3E5EF00FD8907 /* en */, 570 | ); 571 | name = InfoPlist.strings; 572 | sourceTree = ""; 573 | }; 574 | /* End PBXVariantGroup section */ 575 | 576 | /* Begin XCBuildConfiguration section */ 577 | 02F155E015C547220054EF51 /* Debug */ = { 578 | isa = XCBuildConfiguration; 579 | buildSettings = { 580 | ALWAYS_SEARCH_USER_PATHS = NO; 581 | ARCHS = "$(ARCHS_STANDARD_64_BIT)"; 582 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 583 | CLANG_ENABLE_OBJC_ARC = YES; 584 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 585 | COPY_PHASE_STRIP = NO; 586 | GCC_C_LANGUAGE_STANDARD = gnu99; 587 | GCC_DYNAMIC_NO_PIC = NO; 588 | GCC_ENABLE_OBJC_EXCEPTIONS = YES; 589 | GCC_OPTIMIZATION_LEVEL = 0; 590 | GCC_PREPROCESSOR_DEFINITIONS = ( 591 | "DEBUG=1", 592 | "$(inherited)", 593 | ); 594 | GCC_SYMBOLS_PRIVATE_EXTERN = NO; 595 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 596 | GCC_WARN_ABOUT_RETURN_TYPE = YES; 597 | GCC_WARN_UNINITIALIZED_AUTOS = YES; 598 | GCC_WARN_UNUSED_VARIABLE = YES; 599 | MACOSX_DEPLOYMENT_TARGET = 10.8; 600 | ONLY_ACTIVE_ARCH = YES; 601 | SDKROOT = macosx10.7; 602 | }; 603 | name = Debug; 604 | }; 605 | 02F155E115C547220054EF51 /* Release */ = { 606 | isa = XCBuildConfiguration; 607 | buildSettings = { 608 | ALWAYS_SEARCH_USER_PATHS = NO; 609 | ARCHS = "$(ARCHS_STANDARD_64_BIT)"; 610 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 611 | CLANG_ENABLE_OBJC_ARC = YES; 612 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 613 | COPY_PHASE_STRIP = YES; 614 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 615 | GCC_C_LANGUAGE_STANDARD = gnu99; 616 | GCC_ENABLE_OBJC_EXCEPTIONS = YES; 617 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 618 | GCC_WARN_ABOUT_RETURN_TYPE = YES; 619 | GCC_WARN_UNINITIALIZED_AUTOS = YES; 620 | GCC_WARN_UNUSED_VARIABLE = YES; 621 | MACOSX_DEPLOYMENT_TARGET = 10.8; 622 | SDKROOT = macosx10.7; 623 | }; 624 | name = Release; 625 | }; 626 | 02F155E315C547220054EF51 /* Debug */ = { 627 | isa = XCBuildConfiguration; 628 | buildSettings = { 629 | COMBINE_HIDPI_IMAGES = YES; 630 | DYLIB_COMPATIBILITY_VERSION = 1; 631 | DYLIB_CURRENT_VERSION = 1; 632 | FRAMEWORK_VERSION = A; 633 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 634 | GCC_PREFIX_HEADER = "TondarAPI/TondarAPI-Prefix.pch"; 635 | INFOPLIST_FILE = "TondarAPI/TondarAPI-Info.plist"; 636 | OTHER_LDFLAGS = "-licucore"; 637 | PRODUCT_NAME = "$(TARGET_NAME)"; 638 | SDKROOT = macosx; 639 | WRAPPER_EXTENSION = framework; 640 | }; 641 | name = Debug; 642 | }; 643 | 02F155E415C547220054EF51 /* Release */ = { 644 | isa = XCBuildConfiguration; 645 | buildSettings = { 646 | COMBINE_HIDPI_IMAGES = YES; 647 | DYLIB_COMPATIBILITY_VERSION = 1; 648 | DYLIB_CURRENT_VERSION = 1; 649 | FRAMEWORK_VERSION = A; 650 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 651 | GCC_PREFIX_HEADER = "TondarAPI/TondarAPI-Prefix.pch"; 652 | INFOPLIST_FILE = "TondarAPI/TondarAPI-Info.plist"; 653 | OTHER_LDFLAGS = "-licucore"; 654 | PRODUCT_NAME = "$(TARGET_NAME)"; 655 | SDKROOT = macosx; 656 | WRAPPER_EXTENSION = framework; 657 | }; 658 | name = Release; 659 | }; 660 | 02F155E615C547220054EF51 /* Debug */ = { 661 | isa = XCBuildConfiguration; 662 | buildSettings = { 663 | COMBINE_HIDPI_IMAGES = YES; 664 | FRAMEWORK_SEARCH_PATHS = "\"$(DEVELOPER_LIBRARY_DIR)/Frameworks\""; 665 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 666 | GCC_PREFIX_HEADER = "TondarAPI/TondarAPI-Prefix.pch"; 667 | INFOPLIST_FILE = "TondarAPITests/TondarAPITests-Info.plist"; 668 | PRODUCT_NAME = "$(TARGET_NAME)"; 669 | SDKROOT = macosx; 670 | WRAPPER_EXTENSION = octest; 671 | }; 672 | name = Debug; 673 | }; 674 | 02F155E715C547220054EF51 /* Release */ = { 675 | isa = XCBuildConfiguration; 676 | buildSettings = { 677 | COMBINE_HIDPI_IMAGES = YES; 678 | FRAMEWORK_SEARCH_PATHS = "\"$(DEVELOPER_LIBRARY_DIR)/Frameworks\""; 679 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 680 | GCC_PREFIX_HEADER = "TondarAPI/TondarAPI-Prefix.pch"; 681 | INFOPLIST_FILE = "TondarAPITests/TondarAPITests-Info.plist"; 682 | PRODUCT_NAME = "$(TARGET_NAME)"; 683 | SDKROOT = macosx; 684 | WRAPPER_EXTENSION = octest; 685 | }; 686 | name = Release; 687 | }; 688 | A83FEEA015E3E5EF00FD8907 /* Debug */ = { 689 | isa = XCBuildConfiguration; 690 | buildSettings = { 691 | ARCHS = "$(ARCHS_STANDARD_32_64_BIT)"; 692 | FRAMEWORK_SEARCH_PATHS = "\"$(DEVELOPER_LIBRARY_DIR)/Frameworks\""; 693 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 694 | GCC_PREFIX_HEADER = "URLTesting/URLTesting-Prefix.pch"; 695 | GCC_VERSION = ""; 696 | INFOPLIST_FILE = "URLTesting/URLTesting-Info.plist"; 697 | PRODUCT_NAME = "$(TARGET_NAME)"; 698 | SDKROOT = macosx; 699 | WRAPPER_EXTENSION = octest; 700 | }; 701 | name = Debug; 702 | }; 703 | A83FEEA115E3E5EF00FD8907 /* Release */ = { 704 | isa = XCBuildConfiguration; 705 | buildSettings = { 706 | ARCHS = "$(ARCHS_STANDARD_32_64_BIT)"; 707 | FRAMEWORK_SEARCH_PATHS = "\"$(DEVELOPER_LIBRARY_DIR)/Frameworks\""; 708 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 709 | GCC_PREFIX_HEADER = "URLTesting/URLTesting-Prefix.pch"; 710 | GCC_VERSION = ""; 711 | INFOPLIST_FILE = "URLTesting/URLTesting-Info.plist"; 712 | PRODUCT_NAME = "$(TARGET_NAME)"; 713 | SDKROOT = macosx; 714 | VALIDATE_PRODUCT = YES; 715 | WRAPPER_EXTENSION = octest; 716 | }; 717 | name = Release; 718 | }; 719 | /* End XCBuildConfiguration section */ 720 | 721 | /* Begin XCConfigurationList section */ 722 | 02F155B115C547220054EF51 /* Build configuration list for PBXProject "TondarAPI" */ = { 723 | isa = XCConfigurationList; 724 | buildConfigurations = ( 725 | 02F155E015C547220054EF51 /* Debug */, 726 | 02F155E115C547220054EF51 /* Release */, 727 | ); 728 | defaultConfigurationIsVisible = 0; 729 | defaultConfigurationName = Release; 730 | }; 731 | 02F155E215C547220054EF51 /* Build configuration list for PBXNativeTarget "TondarAPI" */ = { 732 | isa = XCConfigurationList; 733 | buildConfigurations = ( 734 | 02F155E315C547220054EF51 /* Debug */, 735 | 02F155E415C547220054EF51 /* Release */, 736 | ); 737 | defaultConfigurationIsVisible = 0; 738 | defaultConfigurationName = Release; 739 | }; 740 | 02F155E515C547220054EF51 /* Build configuration list for PBXNativeTarget "TondarAPITests" */ = { 741 | isa = XCConfigurationList; 742 | buildConfigurations = ( 743 | 02F155E615C547220054EF51 /* Debug */, 744 | 02F155E715C547220054EF51 /* Release */, 745 | ); 746 | defaultConfigurationIsVisible = 0; 747 | defaultConfigurationName = Release; 748 | }; 749 | A83FEE9F15E3E5EF00FD8907 /* Build configuration list for PBXNativeTarget "URLTesting" */ = { 750 | isa = XCConfigurationList; 751 | buildConfigurations = ( 752 | A83FEEA015E3E5EF00FD8907 /* Debug */, 753 | A83FEEA115E3E5EF00FD8907 /* Release */, 754 | ); 755 | defaultConfigurationIsVisible = 0; 756 | defaultConfigurationName = Release; 757 | }; 758 | /* End XCConfigurationList section */ 759 | }; 760 | rootObject = 02F155AE15C547220054EF51 /* Project object */; 761 | } 762 | -------------------------------------------------------------------------------- /TondarAPI.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /TondarAPI.xcodeproj/project.xcworkspace/xcshareddata/TondarAPI.xccheckout: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDESourceControlProjectFavoriteDictionaryKey 6 | 7 | IDESourceControlProjectIdentifier 8 | E2D89815-26B8-4FBD-BB13-78F6DDDC24BE 9 | IDESourceControlProjectName 10 | TondarAPI 11 | IDESourceControlProjectOriginsDictionary 12 | 13 | 46CBEF68-C28D-4FC4-A44F-A3A9224BC2D2 14 | https://github.com/xuxulll/xunlei-lixian-api-PureObjc.git 15 | 16 | IDESourceControlProjectPath 17 | TondarAPI.xcodeproj/project.xcworkspace 18 | IDESourceControlProjectRelativeInstallPathDictionary 19 | 20 | 46CBEF68-C28D-4FC4-A44F-A3A9224BC2D2 21 | ../.. 22 | 23 | IDESourceControlProjectURL 24 | https://github.com/xuxulll/xunlei-lixian-api-PureObjc.git 25 | IDESourceControlProjectVersion 26 | 110 27 | IDESourceControlProjectWCCIdentifier 28 | 46CBEF68-C28D-4FC4-A44F-A3A9224BC2D2 29 | IDESourceControlProjectWCConfigurations 30 | 31 | 32 | IDESourceControlRepositoryExtensionIdentifierKey 33 | public.vcs.git 34 | IDESourceControlWCCIdentifierKey 35 | 46CBEF68-C28D-4FC4-A44F-A3A9224BC2D2 36 | IDESourceControlWCCName 37 | xunlei-lixian-api-PureObjc 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /TondarAPI/ConvertURL.h: -------------------------------------------------------------------------------- 1 | // 2 | // ConvertURL.h 3 | // TondarAPI 4 | // 5 | // Created by liuchao on 8/21/12. 6 | // Copyright (c) 2012 MartianZ. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ConvertURL : NSObject 12 | -(NSString*) thunderURLEncode:(NSString*) urlString; 13 | -(NSString*) thunderURLDecode:(NSString*) urlString; 14 | -(NSString*) qqURLEncode:(NSString*) urlString; 15 | -(NSString*) qqURLDecode:(NSString*) encodedString; 16 | -(NSString*) flashgetURLEncode:(NSString*) urlString; 17 | -(NSString*) flashgetURLDecode:(NSString*) encodedString; 18 | //一个通用方法,可以转换thunder,qq,flashget几种 19 | -(NSString*) urlUnmask:(NSString*) urlString; 20 | @end 21 | -------------------------------------------------------------------------------- /TondarAPI/ConvertURL.m: -------------------------------------------------------------------------------- 1 | // 2 | // ConvertURL.m 3 | // TondarAPI 4 | // 5 | // Created by liuchao on 8/21/12. 6 | // Copyright (c) 2012 MartianZ. All rights reserved. 7 | // 8 | 9 | #import "ConvertURL.h" 10 | #import "NSString+Base64.h" 11 | #import "NSData+Base64.h" 12 | 13 | @implementation ConvertURL 14 | 15 | -(NSString*) thunderURLEncode:(NSString*) urlString{ 16 | //set up data 17 | NSString *t=[NSString stringWithFormat:@"AA%@ZZ",urlString]; 18 | NSData *inputData = [t dataUsingEncoding:NSUTF8StringEncoding]; 19 | 20 | //encode 21 | NSString *encodedString = [inputData base64EncodedString]; 22 | NSString *url=[NSString stringWithFormat:@"thunder://%@",encodedString]; 23 | return url; 24 | } 25 | -(NSString*) thunderURLDecode:(NSString*) encodedString{ 26 | NSString* returnString=nil; 27 | if ([encodedString hasPrefix:@"thunder://"]) { 28 | NSData *outputData = [NSData dataWithBase64EncodedString:[encodedString substringFromIndex:10]]; 29 | NSString *outputString = [[NSString alloc] initWithData:outputData encoding:NSUTF8StringEncoding]; 30 | if([outputString hasPrefix:@"AA"]&&[outputString hasSuffix:@"ZZ"]){ 31 | returnString=[outputString substringWithRange:NSMakeRange(2, outputString.length-4)]; 32 | } 33 | } 34 | return returnString; 35 | } 36 | 37 | -(NSString*) qqURLEncode:(NSString*) urlString{ 38 | //set up data; 39 | NSData *inputData = [urlString dataUsingEncoding:NSUTF8StringEncoding]; 40 | 41 | //encode 42 | NSString *encodedString = [inputData base64EncodedString]; 43 | NSString *url=[NSString stringWithFormat:@"qqdl://%@",encodedString]; 44 | return url; 45 | } 46 | -(NSString*) qqURLDecode:(NSString*) encodedString{ 47 | NSString* returnString=nil; 48 | if ([encodedString hasPrefix:@"qqdl://"]) { 49 | NSData *outputData = [NSData dataWithBase64EncodedString:[encodedString substringFromIndex:7]]; 50 | NSString *outputString = [[NSString alloc] initWithData:outputData encoding:NSUTF8StringEncoding]; 51 | returnString=outputString; 52 | } 53 | return returnString; 54 | } 55 | -(NSString*) flashgetURLEncode:(NSString*) urlString{ 56 | //set up data 57 | NSString *t=[NSString stringWithFormat:@"[FLASHGET]%@[FLASHGET]",urlString]; 58 | NSData *inputData = [t dataUsingEncoding:NSUTF8StringEncoding]; 59 | 60 | //encode 61 | NSString *encodedString = [inputData base64EncodedString]; 62 | NSString *url=[NSString stringWithFormat:@"Flashget://%@",encodedString]; 63 | return url; 64 | } 65 | -(NSString*) flashgetURLDecode:(NSString*) encodedString{ 66 | NSString* returnString=nil; 67 | if ([encodedString hasPrefix:@"Flashget://"]) { 68 | NSData *outputData = [NSData dataWithBase64EncodedString:[encodedString substringFromIndex:11]]; 69 | NSString *outputString = [[NSString alloc] initWithData:outputData encoding:NSUTF8StringEncoding]; 70 | if([outputString hasPrefix:@"[FLASHGET]"]&&[outputString hasSuffix:@"[FLASHGET]"]){ 71 | returnString=[outputString substringWithRange:NSMakeRange(10, outputString.length-20)]; 72 | } 73 | } 74 | return returnString; 75 | } 76 | 77 | -(NSString*) urlUnmask:(NSString*) urlString{ 78 | NSString* returnString=nil; 79 | if([urlString hasPrefix:@"thunder://"]){ 80 | returnString=[self thunderURLDecode:urlString]; 81 | }else if ([urlString hasPrefix:@"qqdl://"]){ 82 | returnString=[self qqURLDecode:urlString]; 83 | }else if ([urlString hasPrefix:@"Flashget://"]){ 84 | returnString=[self flashgetURLDecode:urlString]; 85 | }else{ 86 | returnString=urlString; 87 | } 88 | return returnString; 89 | } 90 | 91 | @end 92 | -------------------------------------------------------------------------------- /TondarAPI/HYXunleiLixianAPI.h: -------------------------------------------------------------------------------- 1 | // 2 | // HWXunleiLixianAPI.h 3 | // XunleiLixian-API 4 | // 5 | // Created by Liu Chao on 6/10/12. 6 | // Copyright (c) 2012 HwaYing. All rights reserved. 7 | // 8 | /*This file is part of XunleiLixian-API. 9 | 10 | XunleiLixian-API is free software: you can redistribute it and/or modify 11 | it under the terms of the GNU General Public License as published by 12 | the Free Software Foundation, either version 3 of the License, or 13 | (at your option) any later version. 14 | 15 | Foobar is distributed in the hope that it will be useful, 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | GNU General Public License for more details. 19 | 20 | You should have received a copy of the GNU General Public License 21 | along with Foobar. If not, see . 22 | */ 23 | 24 | #import 25 | @class XunleiItemInfo; 26 | @class KuaiItemInfo; 27 | typedef enum{ 28 | QMiddleQuality=1, 29 | QLowQuality=2, 30 | QHighQuality=3 31 | }YUNZHUANMAQuality; 32 | 33 | @interface HYXunleiLixianAPI : NSObject 34 | -(XunleiItemInfo *) getTaskWithTaskID:(NSString*) aTaskID; 35 | #pragma mark - Cookies Methods 36 | -(NSString *) cookieValueWithName:(NSString *)aName; 37 | -(NSHTTPCookie *) setCookieWithKey:(NSString *) key Value:(NSString *) value; 38 | -(BOOL) hasCookie:(NSString*) aKey; 39 | #pragma mark - Login/LogOut Methods 40 | //Login 41 | -(BOOL) loginWithUsername:(NSString *) aName Password:(NSString *) aPassword; 42 | -(BOOL) isLogin; 43 | -(void) logOut; 44 | #pragma mark - UserID,UserNmae 45 | //UserID,UserName 46 | -(NSString *)userID; 47 | -(NSString *)userName; 48 | #pragma mark - GDriveID 49 | //GdriveID是一个关键Cookie,在下载文件的时候需要用它进行验证 50 | -(NSString*)GDriveID; 51 | -(BOOL) isGDriveIDInCookie; 52 | -(void) setGdriveID:(NSString*) gdriveid; 53 | #pragma mark - Referer 54 | //获得Referer 55 | -(NSString*) refererWithStringFormat; 56 | -(NSURL*) refererWithURLFormat; 57 | 58 | 59 | #pragma mark - Task 60 | //获得不同下载状态的任务列表 61 | -(NSMutableArray*) readAllCompleteTasks; 62 | -(NSMutableArray*) readCompleteTasksWithPage:(NSUInteger) pg; 63 | 64 | -(NSMutableArray*) readAllDownloadingTasks; 65 | -(NSMutableArray*) readDownloadingTasksWithPage:(NSUInteger) pg; 66 | /* //Some Problems Tempremoved*/ 67 | -(NSMutableArray *) readAllOutofDateTasks; 68 | -(NSMutableArray *) readOutofDateTasksWithPage:(NSUInteger) pg; 69 | 70 | -(NSMutableArray*) readAllDeletedTasks; 71 | -(NSMutableArray*) readDeletedTasksWithPage:(NSUInteger) pg; 72 | 73 | #pragma mark - BT Task 74 | //BT任务列表 75 | -(NSMutableArray *) readSingleBTTaskListWithTaskID:(NSString *) taskid hashID:(NSString *)dcid andPageNumber:(NSUInteger) pg; 76 | -(NSMutableArray *) readAllBTTaskListWithTaskID:(NSString *) taskid hashID:(NSString *)dcid; 77 | #pragma mark - Add Task 78 | //添加任务 79 | -(NSString *) addMegnetTask:(NSString *) url; 80 | -(NSString *) addNormalTask:(NSString *)url; 81 | #pragma mark - Delete Task 82 | //删除任务 83 | -(BOOL) deleteTasksByIDArray:(NSArray *)ids; 84 | -(BOOL) deleteSingleTaskByID:(NSString*) id; 85 | -(BOOL) deleteSingleTaskByXunleiItemInfo:(XunleiItemInfo*) aInfo; 86 | -(BOOL) deleteTasksByXunleiItemInfoArray:(NSArray *)ids; 87 | #pragma mark - Pause Task 88 | -(BOOL) pauseMultiTasksByTaskID:(NSArray*) ids; 89 | -(BOOL) pauseTaskWithID:(NSString*) taskID; 90 | -(BOOL) pauseTask:(XunleiItemInfo*) info; 91 | -(BOOL) pauseMutiTasksByTaskItemInfo:(NSArray*) infos; 92 | #pragma mark - ReStart Task 93 | -(BOOL) restartTask:(XunleiItemInfo*) info; 94 | -(BOOL) restartMutiTasksByTaskItemInfo:(NSArray*) infos; 95 | #pragma mark - Rename Task 96 | //TO DO 97 | #pragma mark - YunZhuanMa Task 98 | //云转码任务列表 99 | -(NSMutableArray*) readAllYunTasks; 100 | -(NSMutableArray *) readYunTasksWithPage:(NSUInteger) pg retIfHasNextPage:(BOOL *) hasNextPageBool; 101 | //添加任务到云转码 102 | -(BOOL) addYunTaskWithFileSize:(NSString*) size downloadURL:(NSString*) url dcid:(NSString*) cid fileName:(NSString*) aName Quality:(YUNZHUANMAQuality) q; 103 | //云转码删除任务 104 | -(BOOL) deleteYunTaskByID:(NSString*) anId; 105 | -(BOOL) deleteYunTasksByIDArray:(NSArray *)ids; 106 | 107 | #pragma mark - Xunlei KuaiChuan ...迅雷快传 108 | //通过提供KuaiItemInfo来直接创建迅雷离线地址,KuaiItemInfo可以通过getKuaiItemInfos:获得 109 | -(NSString*) generateXunleiURLStringByKuaiItemInfo:(KuaiItemInfo*) info; 110 | //生成KuaiItemInfoArray 111 | -(NSArray*) getKuaiItemInfos:(NSURL*) kuaiURL; 112 | //添加快传页面的连接到迅雷离线 113 | -(BOOL) addAllKuaiTasksToLixianByURL:(NSURL*) kuaiURL; 114 | // 添加BT任务 115 | - (NSString *)addBTTask:(NSString *)filePath selection:(NSArray *)array hasFetchedFileList:(NSDictionary *)dataField; 116 | - (NSDictionary *)fetchBTFileList:(NSString *)filePath; 117 | - (NSString *)fileSize:(float)size; //一个根据length返回文件大小的方法 118 | @end 119 | -------------------------------------------------------------------------------- /TondarAPI/HYXunleiLixianAPI.m: -------------------------------------------------------------------------------- 1 | // 2 | // HWXunleiLixianAPI.m 3 | // XunleiLixian-API 4 | // 5 | // Created by Liu Chao on 6/10/12. 6 | // Copyright (c) 2012 HwaYing. All rights reserved. 7 | // 8 | /*This file is part of XunleiLixian-API. 9 | 10 | XunleiLixian-API is free software: you can redistribute it and/or modify 11 | it under the terms of the GNU General Public License as published by 12 | the Free Software Foundation, either version 3 of the License, or 13 | (at your option) any later version. 14 | 15 | Foobar is distributed in the hope that it will be useful, 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | GNU General Public License for more details. 19 | 20 | You should have received a copy of the GNU General Public License 21 | along with Foobar. If not, see . 22 | */ 23 | 24 | 25 | #import "HYXunleiLixianAPI.h" 26 | #import "md5.h" 27 | #import "ParseElements.h" 28 | #import "JSONKit.h" 29 | #import "NSString+RE.h" 30 | #import "URlEncode.h" 31 | #import "XunleiItemInfo.h" 32 | #import "Kuai.h" 33 | #import "ConvertURL.h" 34 | #import "LCHTTPConnection.h" 35 | 36 | typedef enum { 37 | TLTAll, 38 | TLTDownloadding, 39 | TLTComplete, 40 | TLTOutofDate, 41 | TLTDeleted 42 | } TaskListType; 43 | 44 | @implementation HYXunleiLixianAPI 45 | 46 | #define LoginURL @"http://login.xunlei.com/sec2login/" 47 | #define DEFAULT_USER_AGENT @"User-Agent:Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/535.2 (KHTML, like Gecko) Chrome/15.0.874.106 Safari/535.2" 48 | #define DEFAULT_REFERER @"http://lixian.vip.xunlei.com/" 49 | 50 | #pragma mark - Login/LogOut Methods 51 | /** 52 | * 登陆方法 53 | */ 54 | -(BOOL) loginWithUsername:(NSString *) aName Password:(NSString *) aPassword{ 55 | NSString *vCode=[self _verifyCode:aName]; 56 | if ([vCode compare:@"0"]==NSOrderedSame) { 57 | return NO; 58 | } 59 | NSString *enPassword=[self _encodePassword:aPassword withVerifyCode:vCode]; 60 | 61 | //第一步登陆,验证用户名密码 62 | NSURL *url = [NSURL URLWithString:LoginURL]; 63 | LCHTTPConnection *request=[LCHTTPConnection new]; 64 | [request setPostValue:aName forKey:@"u"]; 65 | [request setPostValue:enPassword forKey:@"p"]; 66 | [request setPostValue:vCode forKey:@"verifycode"]; 67 | [request setPostValue:@"0" forKey:@"login_enable"]; 68 | [request setPostValue:@"720" forKey:@"login_hour"]; 69 | [request post:[url absoluteString]]; 70 | //把response中的Cookie添加到CookieStorage 71 | [self _addResponseCookietoCookieStorage:[request responseCookies]]; 72 | 73 | //完善所需要的cookies,并收到302响应跳转 74 | NSString *timeStamp=[self _currentTimeString]; 75 | NSURL *redirectUrl = [NSURL URLWithString:[NSString stringWithFormat:@"http://dynamic.cloud.vip.xunlei.com/login?cachetime=%@&cachetime=%@&from=0",timeStamp,timeStamp]]; 76 | LCHTTPConnection* redirectURLrequest = [LCHTTPConnection new]; 77 | [redirectURLrequest get:[redirectUrl absoluteString]]; 78 | //把response中的Cookie添加到CookieStorage 79 | [self _addResponseCookietoCookieStorage:[redirectURLrequest responseCookies]]; 80 | //验证是否登陆成功 81 | NSString *userid=[self userID]; 82 | if(userid.length>1){ 83 | return YES; 84 | }else { 85 | return NO; 86 | } 87 | } 88 | 89 | //加密密码 90 | -(NSString *) _encodePassword:(NSString *) aPassword withVerifyCode:(NSString *) aVerifyCode{ 91 | NSString *enPwd_tmp=[md5 md5HexDigestwithString:([md5 md5HexDigestwithString:aPassword])]; 92 | NSString *upperVerifyCode=[aVerifyCode uppercaseString]; 93 | //join the two strings 94 | enPwd_tmp=[NSString stringWithFormat:@"%@%@",enPwd_tmp,upperVerifyCode]; 95 | NSString *pwd=[md5 md5HexDigestwithString:enPwd_tmp]; 96 | NSLog(@"%@",pwd); 97 | return pwd; 98 | } 99 | 100 | //获取验证码 101 | -(NSString *) _verifyCode:(NSString *) aUserName{ 102 | NSHTTPCookieStorage *cookieJar=[NSHTTPCookieStorage sharedHTTPCookieStorage]; 103 | [cookieJar setCookieAcceptPolicy:NSHTTPCookieAcceptPolicyAlways]; 104 | NSString *currentTime=[self _currentTimeString]; 105 | //NSLog(@"%@",currentTime); 106 | NSString *checkUrlString=[NSString stringWithFormat:@"http://login.xunlei.com/check?u=%@&cachetime=%@",aUserName,currentTime]; 107 | 108 | LCHTTPConnection *request=[LCHTTPConnection new]; 109 | [request get:checkUrlString]; 110 | //把response中的Cookie添加到CookieStorage 111 | [self _addResponseCookietoCookieStorage:[request responseCookies]]; 112 | 113 | NSString *vCode; 114 | vCode=[self cookieValueWithName:@"check_result"]; 115 | //判断是否取得合法VerifyCode 116 | NSRange range; 117 | range=[vCode rangeOfString:@":"]; 118 | if(range.location==NSNotFound){ 119 | NSLog(@"Maybe something wrong when get verifyCode"); 120 | return 0; 121 | }else { 122 | vCode=[[vCode componentsSeparatedByString:@":"] objectAtIndex:1]; 123 | NSLog(@"%@",vCode); 124 | 125 | } 126 | return vCode; 127 | } 128 | 129 | 130 | /* 131 | *迅雷的登陆会过期,有时需要检验一下是否登陆。 132 | *现在采用的方法比较“重”,效率可能会低一些,但更稳妥直接 133 | *现在备选的两种方法,第一同样访问taskPage然后检查页面大小判断是否真的登陆 134 | *第二种方法检查Cookies,但是还未找到判断哪个Cookie 135 | */ 136 | -(BOOL) isLogin{ 137 | BOOL result=NO; 138 | if([self _tasksWithStatus:TLTComplete]){ 139 | NSLog(@"Thunder Login Successfully"); 140 | result=YES; 141 | } 142 | return result; 143 | } 144 | 145 | /* 146 | *有两种方法可以实现logout 147 | *第一种清空Cookies,第二种访问http://dynamic.vip.xunlei.com/login/indexlogin_contr/logout/,本方法采用了第一种速度快,现在也没发现什么问题。 148 | */ 149 | -(void)logOut{ 150 | NSArray* keys=@[@"vip_isvip",@"lx_sessionid",@"vip_level",@"lx_login",@"dl_enable",@"in_xl",@"ucid",@"lixian_section",@"sessionid",@"usrname",@"nickname",@"usernewno",@"userid",@"gdriveid"]; 151 | for(NSString* i in keys){ 152 | [self setCookieWithKey:i Value:@""]; 153 | } 154 | } 155 | 156 | #pragma mark - GDriveID 157 | //GdriveID是一个关键Cookie,在下载文件的时候需要用它进行验证 158 | -(NSString*)GDriveID{ 159 | return [self cookieValueWithName:@"gdriveid"]; 160 | } 161 | -(BOOL) isGDriveIDInCookie{ 162 | BOOL result=NO; 163 | if([self GDriveID]){ 164 | result=YES; 165 | } 166 | return result; 167 | } 168 | 169 | -(void) setGdriveID:(NSString*) gdriveid{ 170 | [self setCookieWithKey:@"gdriveid" Value:gdriveid]; 171 | } 172 | 173 | 174 | #pragma mark - Referer 175 | //获得Referer 176 | -(NSString*) refererWithStringFormat{ 177 | NSString* urlString=[NSString stringWithFormat:@"http://dynamic.cloud.vip.xunlei.com/user_task?userid=%@",[self userID]]; 178 | return urlString; 179 | } 180 | -(NSURL*) refererWithURLFormat{ 181 | return [NSURL URLWithString:[self refererWithStringFormat]]; 182 | } 183 | 184 | #pragma mark - Cookies Methods 185 | //从cookies中取得指定名称的值 186 | -(NSString *) cookieValueWithName:(NSString *)aName{ 187 | NSHTTPCookieStorage *cookieJar = [NSHTTPCookieStorage sharedHTTPCookieStorage]; 188 | NSString *value=nil; 189 | for(NSHTTPCookie *cookie in [cookieJar cookies]){ 190 | if([cookie.domain hasSuffix:@".xunlei.com"]){ 191 | // NSLog(@"%@",cookie); 192 | if([aName isEqualToString:@"gdriveid"] && [cookie.domain hasSuffix:@".xunlei.com"] && [cookie.name compare:aName]==NSOrderedSame){ 193 | value=cookie.value; 194 | } 195 | if([cookie.name compare:aName]==NSOrderedSame){ 196 | value=cookie.value; 197 | // NSLog(@"%@:%@",aName,value); 198 | }} 199 | } 200 | return value; 201 | } 202 | 203 | //设置Cookies 204 | -(NSHTTPCookie *) setCookieWithKey:(NSString *) key Value:(NSString *) value{ 205 | //创建一个cookie 206 | NSMutableDictionary *properties = [NSMutableDictionary dictionary]; 207 | [properties setObject:value forKey:NSHTTPCookieValue]; 208 | [properties setObject:key forKey:NSHTTPCookieName]; 209 | [properties setObject:@".vip.xunlei.com" forKey:NSHTTPCookieDomain]; 210 | [properties setObject:@"/" forKey:NSHTTPCookiePath]; 211 | [properties setObject:[[NSDate date] dateByAddingTimeInterval:2629743] forKey:NSHTTPCookieExpires]; 212 | //这里是关键,不要写成@"FALSE",而是应该直接写成TRUE 或者 FALSE,否则会默认为TRUE 213 | [properties setValue:FALSE forKey:NSHTTPCookieSecure]; 214 | NSHTTPCookie *cookie = [[NSHTTPCookie alloc] initWithProperties:properties]; 215 | NSHTTPCookieStorage *cookieStorage=[NSHTTPCookieStorage sharedHTTPCookieStorage]; 216 | [cookieStorage setCookieAcceptPolicy:NSHTTPCookieAcceptPolicyAlways]; 217 | [cookieStorage setCookie:cookie]; 218 | 219 | return cookie; 220 | } 221 | //查询Cookie是否存在 222 | -(BOOL) hasCookie:(NSString*) aKey{ 223 | BOOL result=NO; 224 | if([self cookieValueWithName:aKey]){ 225 | result=YES; 226 | } 227 | return result; 228 | } 229 | 230 | 231 | #pragma mark - UserID,UserNmae 232 | //获取当前UserID 233 | -(NSString *)userID{ 234 | return ([self cookieValueWithName:@"userid"]); 235 | } 236 | 237 | -(NSString *)userName{ 238 | return ([self cookieValueWithName:@"usernewno"]); 239 | } 240 | 241 | 242 | 243 | 244 | #pragma mark - Public Normal Task Methods 245 | //获取主任务页内容 246 | //公共方法 247 | -(NSMutableArray*) readAllCompleteTasks{ 248 | return [self _readAllTasksWithStat:TLTComplete]; 249 | } 250 | -(NSMutableArray*) readCompleteTasksWithPage:(NSUInteger) pg{ 251 | return [self _tasksWithStatus:TLTComplete andPage:pg retIfHasNextPage:NULL]; 252 | } 253 | -(NSMutableArray*) readAllDownloadingTasks{ 254 | return [self _readAllTasksWithStat:TLTDownloadding]; 255 | } 256 | -(NSMutableArray*) readDownloadingTasksWithPage:(NSUInteger) pg{ 257 | return [self _tasksWithStatus:TLTDownloadding andPage:pg retIfHasNextPage:NULL]; 258 | } 259 | -(NSMutableArray *) readAllOutofDateTasks{ 260 | return [self _readAllTasksWithStat:TLTOutofDate]; 261 | } 262 | -(NSMutableArray *) readOutofDateTasksWithPage:(NSUInteger) pg{ 263 | return [self _tasksWithStatus:TLTOutofDate andPage:pg retIfHasNextPage:NULL]; 264 | } 265 | -(NSMutableArray*) readAllDeletedTasks{ 266 | return [self _readAllTasksWithStat:TLTDeleted]; 267 | } 268 | -(NSMutableArray*) readDeletedTasksWithPage:(NSUInteger) pg{ 269 | return [self _tasksWithStatus:TLTDeleted andPage:pg retIfHasNextPage:NULL]; 270 | } 271 | #pragma mark - Private Normal Task Methods 272 | //私有方法 273 | -(NSMutableArray *) _tasksWithStatus:(TaskListType) listType{ 274 | NSString* userid=[self userID]; 275 | NSURL *url; 276 | switch (listType) { 277 | case TLTAll: 278 | url=[NSURL URLWithString:[NSString stringWithFormat:@"http://dynamic.cloud.vip.xunlei.com/user_task?userid=%@&st=0",userid]]; 279 | break; 280 | case TLTComplete: 281 | url=[NSURL URLWithString:[NSString stringWithFormat:@"http://dynamic.cloud.vip.xunlei.com/user_task?userid=%@&st=2",userid]]; 282 | break; 283 | case TLTDownloadding: 284 | url=[NSURL URLWithString:[NSString stringWithFormat:@"http://dynamic.cloud.vip.xunlei.com/user_task?userid=%@&st=1",userid]]; 285 | break; 286 | case TLTOutofDate: 287 | url=[NSURL URLWithString:[NSString stringWithFormat:@"http://dynamic.cloud.vip.xunlei.com/user_history?type=1&userid=%@",userid]]; 288 | break; 289 | case TLTDeleted: 290 | url=[NSURL URLWithString:[NSString stringWithFormat:@"http://dynamic.cloud.vip.xunlei.com/user_history?type=0userid=%@",userid]]; 291 | break; 292 | default: 293 | break; 294 | } 295 | return [self _tasksWithURL:url retIfHasNextPage:NULL listType:listType]; 296 | } 297 | -(NSMutableArray *) _tasksWithStatus:(TaskListType) listType andPage:(NSUInteger) pg retIfHasNextPage:(BOOL *) hasNextPage{ 298 | NSString* userid=[self userID]; 299 | NSURL *url; 300 | switch (listType) { 301 | case TLTAll: 302 | url=[NSURL URLWithString:[NSString stringWithFormat:@"http://dynamic.cloud.vip.xunlei.com/user_task?userid=%@&st=0&p=%lu",userid,(unsigned long)pg]]; 303 | break; 304 | case TLTComplete: 305 | url=[NSURL URLWithString:[NSString stringWithFormat:@"http://dynamic.cloud.vip.xunlei.com/user_task?userid=%@&st=2&p=%lu",userid,(unsigned long)pg]]; 306 | break; 307 | case TLTDownloadding: 308 | url=[NSURL URLWithString:[NSString stringWithFormat:@"http://dynamic.cloud.vip.xunlei.com/user_task?userid=%@&st=1&p=%lu",userid,(unsigned long)pg]]; 309 | break; 310 | case TLTOutofDate: 311 | url=[NSURL URLWithString:[NSString stringWithFormat:@"http://dynamic.cloud.vip.xunlei.com/user_history?type=1&userid=%@&p=%lu",userid,(unsigned long)pg]]; 312 | break; 313 | case TLTDeleted: 314 | url=[NSURL URLWithString:[NSString stringWithFormat:@"http://dynamic.cloud.vip.xunlei.com/user_history?type=0&userid=%@&p=%lu",userid,(unsigned long)pg]]; 315 | break; 316 | default: 317 | break; 318 | } 319 | NSLog(@"%@",url); 320 | return [self _tasksWithURL:url retIfHasNextPage:hasNextPage listType:listType]; 321 | } 322 | -(NSMutableArray *) _readAllTasksWithStat:(TaskListType) listType{ 323 | NSUInteger pg=1; 324 | BOOL hasNP=NO; 325 | NSMutableArray *allTaskArray=[NSMutableArray arrayWithCapacity:0]; 326 | NSMutableArray *mArray=nil; 327 | do { 328 | mArray=[self _tasksWithStatus:listType andPage:pg retIfHasNextPage:&hasNP]; 329 | [allTaskArray addObjectsFromArray:mArray]; 330 | pg++; 331 | } while (hasNP); 332 | return allTaskArray; 333 | } 334 | //只适用于“已过期”,“已删除”任务 335 | 336 | //通用方法 337 | -(NSURL*) _getNextPageURL:(NSString *) currentPageData{ 338 | NSString *tmp=[ParseElements nextPageSubURL:currentPageData]; 339 | NSURL *url=nil; 340 | if(tmp){ 341 | NSString *u=[NSString stringWithFormat:@"http://dynamic.cloud.vip.xunlei.com%@",tmp]; 342 | url=[NSURL URLWithString:u]; 343 | } 344 | return url; 345 | } 346 | -(BOOL) _hasNextPage:(NSString*) currrentPageData{ 347 | BOOL result=NO; 348 | if([self _getNextPageURL:currrentPageData]){ 349 | result=YES; 350 | } 351 | return result; 352 | } 353 | -(NSMutableArray *) _tasksWithURL:(NSURL *) taskURL retIfHasNextPage:(BOOL *) hasNextPageBool listType:(TaskListType) listtype{ 354 | NSString *siteData; 355 | //初始化返回Array 356 | NSMutableArray *elements=[[NSMutableArray alloc] initWithCapacity:0]; 357 | //设置lx_nf_all Cookie 358 | //不得不喷一下这个东西了,不设置这个Cookie,返回网页有问题,不是没有内容,而是他妈的不全,太傻逼了,浪费了我一个小时的时间 359 | //而且这个东西只是再查询“已经删除”和“已经过期”才会用,如果在非这两种状态下使用这个Cookies也会出现显示网页不全的问题。 360 | //迅雷离线的网页怎么做的,飘忽不定 361 | if(listtype==TLTOutofDate||listtype==TLTDeleted){ 362 | [self setCookieWithKey:@"lx_nf_all" Value:@"page_check_all%3Dhistory%26fltask_all_guoqi%3D1%26class_check%3D0%26page_check%3Dtask%26fl_page_id%3D0%26class_check_new%3D0%26set_tab_status%3D11"]; 363 | }else{ 364 | [self setCookieWithKey:@"lx_nf_all" Value:@""]; 365 | } 366 | 367 | if(![self cookieValueWithName:@"lx_login"]){ 368 | //完善所需要的cookies,并收到302响应跳转 369 | NSString *timeStamp=[self _currentTimeString]; 370 | NSURL *redirectUrl = [NSURL URLWithString:[NSString stringWithFormat:@"http://dynamic.cloud.vip.xunlei.com/login?cachetime=%@&cachetime=%@&from=0",timeStamp,timeStamp]]; 371 | LCHTTPConnection* redirectURLrequest = [LCHTTPConnection new]; 372 | [redirectURLrequest get:[redirectUrl absoluteString]]; 373 | //获取task页面内容 374 | LCHTTPConnection *request=[LCHTTPConnection new]; 375 | siteData=[request get:[taskURL absoluteString]]; 376 | }else { 377 | //获取task页面内容 378 | LCHTTPConnection *request=[LCHTTPConnection new]; 379 | siteData=[request get:[taskURL absoluteString]]; 380 | } 381 | // NSLog(@"data:%@",siteData); 382 | //当得到返回数据且得到真实可用的列表信息(不是502等错误页面)时进行下一步 383 | NSString *gdriveid=[ParseElements GDriveID:siteData]; 384 | if (siteData&&(gdriveid.length>0)) { 385 | //设置Gdriveid 386 | [self setGdriveID:gdriveid]; 387 | /* 388 | *=============== 389 | *Parse Html 390 | *=============== 391 | */ 392 | //检查是否还有下一页 393 | if(hasNextPageBool){ 394 | *hasNextPageBool=[self _hasNextPage:siteData]; 395 | } 396 | NSString *re1=@""; 397 | NSString *tmpD1=[siteData stringByMatching:re1 capture:1]; 398 | NSString *re2=nil; 399 | if(listtype==TLTAll|listtype==TLTComplete|listtype==TLTDownloadding){ 400 | re2=@""; 401 | }else if (listtype==TLTOutofDate|listtype==TLTDeleted){ 402 | re2=@"]*>"; 403 | } 404 | NSArray *allTaskArray=[tmpD1 arrayOfCaptureComponentsMatchedByRegex:re2]; 405 | for(NSArray *tmp in allTaskArray){ 406 | //初始化XunleiItemInfo 407 | XunleiItemInfo *info=[XunleiItemInfo new]; 408 | NSString *taskContent=[tmp objectAtIndex:0]; 409 | // NSLog(@"content:%@",taskContent); 410 | NSMutableDictionary *taskInfoDic=[ParseElements taskInfo:taskContent]; 411 | NSString* taskLoadingProcess=[ParseElements taskLoadProcess:taskContent]; 412 | NSString* taskRetainDays=[ParseElements taskRetainDays:taskContent]; 413 | NSString* taskAddTime=[ParseElements taskAddTime:taskContent]; 414 | NSString* taskType=[ParseElements taskType:taskContent]; 415 | NSString* taskReadableSize=[ParseElements taskSize:taskContent]; 416 | 417 | info.taskid=[taskInfoDic objectForKey:@"id"]; 418 | info.name=[taskInfoDic objectForKey:@"taskname"]; 419 | info.size=[taskInfoDic objectForKey:@"ysfilesize"]; 420 | info.readableSize=taskReadableSize; 421 | info.downloadPercent=taskLoadingProcess; 422 | //没办法,只能打补丁了,已删除页面无法和其他页面使用一个通用的正则去判断,只能这样了 423 | if(listtype==TLTDeleted){ 424 | info.retainDays=@"已删除"; 425 | }else{ 426 | info.retainDays=taskRetainDays; 427 | } 428 | info.addDate=taskAddTime; 429 | info.downloadURL=[taskInfoDic objectForKey:@"dl_url"]; 430 | info.type=taskType; 431 | info.isBT=[taskInfoDic objectForKey:@"d_tasktype"]; 432 | info.dcid=[taskInfoDic objectForKey:@"dcid"]; 433 | info.status=[[taskInfoDic objectForKey:@"d_status"] integerValue]; 434 | info.originalURL=[taskInfoDic objectForKey:@"f_url"]; 435 | info.ifvod=[taskInfoDic objectForKey:@"ifvod"]; 436 | 437 | [elements addObject:info]; 438 | } 439 | //return info 440 | return elements; 441 | }else { 442 | return nil; 443 | } 444 | //NSLog(@"%@",elements); 445 | } 446 | 447 | #pragma mark - BT Task 448 | -(NSMutableArray *) readAllBTTaskListWithTaskID:(NSString *) taskid hashID:(NSString *)dcid{ 449 | NSUInteger pg=1; 450 | BOOL hasNP=NO; 451 | NSMutableArray *allTaskArray=[NSMutableArray arrayWithCapacity:0]; 452 | NSMutableArray *mArray=nil; 453 | do { 454 | mArray=[self readSingleBTTaskListWithTaskID:taskid hashID:dcid andPageNumber:pg]; 455 | if(mArray){ 456 | hasNP=YES; 457 | [allTaskArray addObjectsFromArray:mArray]; 458 | pg++; 459 | }else{ 460 | hasNP=NO; 461 | } 462 | } while (hasNP); 463 | return allTaskArray; 464 | } 465 | //获取BT页面内容(hashid 也就是dcid) 466 | -(NSMutableArray *) readSingleBTTaskListWithTaskID:(NSString *) taskid hashID:(NSString *)dcid andPageNumber:(NSUInteger) pg{ 467 | NSMutableArray *elements=[[NSMutableArray alloc] initWithCapacity:0]; 468 | NSString *userid=[self userID]; 469 | NSString *currentTimeStamp=[self _currentTimeString]; 470 | NSString *urlString=[NSString stringWithFormat:@"http://dynamic.cloud.vip.xunlei.com/interface/fill_bt_list?callback=fill_bt_list&tid=%@&infoid=%@&g_net=1&p=%lu&uid=%@&noCacheIE=%@",taskid,dcid,(unsigned long)pg,userid,currentTimeStamp]; 471 | NSURL *url=[NSURL URLWithString:urlString]; 472 | //获取BT task页面内容 473 | LCHTTPConnection *request=[LCHTTPConnection new]; 474 | NSString* siteData=[request get:[url absoluteString]]; 475 | if (siteData) { 476 | NSString *re=@"^fill_bt_list\\((.+)\\)\\s*$"; 477 | NSString *s=[siteData stringByMatching:re capture:1]; 478 | 479 | NSDictionary *dic=[s objectFromJSONString]; 480 | NSDictionary *result=[dic objectForKey:@"Result"]; 481 | //dcid Value 482 | NSString *dcid=[result objectForKey:@"Infoid"]; 483 | NSArray *record=[result objectForKey:@"Record"]; 484 | 485 | for(NSDictionary *task in record){ 486 | XunleiItemInfo *info=[XunleiItemInfo new]; 487 | 488 | info.taskid=taskid; 489 | info.name=[task objectForKey:@"title"]; 490 | info.size=[task objectForKey:@"filesize"]; 491 | info.retainDays=[task objectForKey:@"livetime"]; 492 | info.addDate=@""; 493 | info.downloadURL=[task objectForKey:@"downurl"]; 494 | info.originalURL=[task objectForKey:@"url"]; 495 | info.isBT=@"1"; 496 | info.type=[task objectForKey:@"openformat"]; 497 | info.dcid=dcid; 498 | info.ifvod=[task objectForKey:@"vod"]; 499 | info.status=[[task objectForKey:@"download_status"] integerValue]; 500 | info.readableSize=[task objectForKey:@"size"]; 501 | info.downloadPercent=[task objectForKey:@"percent"]; 502 | [elements addObject:info]; 503 | } 504 | if([elements count]>0){ 505 | return elements; 506 | }else { 507 | return nil; 508 | } 509 | }else { 510 | return nil; 511 | } 512 | //NSLog(@"%@",elements); 513 | //return elements; 514 | } 515 | 516 | #pragma mark - YunZhuanMa Methods 517 | -(NSMutableArray*) readAllYunTasks{ 518 | NSUInteger pg=1; 519 | BOOL hasNP=NO; 520 | NSMutableArray *allTaskArray=[NSMutableArray arrayWithCapacity:0]; 521 | NSMutableArray *mArray=nil; 522 | do { 523 | mArray=[self readYunTasksWithPage:pg retIfHasNextPage:&hasNP]; 524 | [allTaskArray addObjectsFromArray:mArray]; 525 | pg++; 526 | } while (hasNP); 527 | return allTaskArray; 528 | } 529 | 530 | //获取云转码页面信息 531 | -(NSMutableArray *) readYunTasksWithPage:(NSUInteger) pg retIfHasNextPage:(BOOL *) hasNextPageBool{ 532 | NSString* aUserID=[self userID]; 533 | //初始化返回Array 534 | NSMutableArray *elements=[[NSMutableArray alloc] initWithCapacity:0]; 535 | NSURL *requestURL=[NSURL URLWithString:[NSString stringWithFormat:@"http://dynamic.cloud.vip.xunlei.com/cloud?userid=%@&p=%ld",aUserID,(unsigned long)pg]]; 536 | LCHTTPConnection *request=[LCHTTPConnection new]; 537 | NSString* data=[request get:[requestURL absoluteString]]; 538 | if(data){ 539 | if(hasNextPageBool){ 540 | //检查是否还有下一页 541 | *hasNextPageBool=[self _hasNextPage:data]; 542 | } 543 | NSString *re1=@""; 544 | NSString *tmpD1=[data stringByMatching:re1 capture:1]; 545 | NSString *re2=@""; 546 | NSArray *allTaskArray=[tmpD1 arrayOfCaptureComponentsMatchedByRegex:re2]; 547 | for(NSArray *tmp in allTaskArray){ 548 | //初始化XunleiItemInfo 549 | XunleiItemInfo *info=[XunleiItemInfo new]; 550 | NSString *taskContent=[tmp objectAtIndex:0]; 551 | 552 | NSMutableDictionary *taskInfoDic=[ParseElements taskInfo:taskContent]; 553 | NSString* taskLoadingProcess=[ParseElements taskLoadProcess:taskContent]; 554 | NSString* taskRetainDays=[ParseElements taskRetainDays:taskContent]; 555 | NSString* taskAddTime=[ParseElements taskAddTime:taskContent]; 556 | NSString* taskType=[ParseElements taskType:taskContent]; 557 | NSString* taskReadableSize=[ParseElements taskSize:taskContent]; 558 | 559 | info.taskid=[taskInfoDic objectForKey:@"id"]; 560 | info.name=[taskInfoDic objectForKey:@"cloud_taskname"]; 561 | info.size=[taskInfoDic objectForKey:@"ysfilesize"]; 562 | info.readableSize=taskReadableSize; 563 | info.downloadPercent=taskLoadingProcess; 564 | info.retainDays=taskRetainDays; 565 | info.addDate=taskAddTime; 566 | info.downloadURL=[taskInfoDic objectForKey:@"cloud_dl_url"]; 567 | info.type=taskType; 568 | info.isBT=[taskInfoDic objectForKey:@"d_tasktype"]; 569 | info.dcid=[taskInfoDic objectForKey:@"dcid"]; 570 | info.status=[[taskInfoDic objectForKey:@"cloud_d_status"] integerValue]; 571 | //info.originalURL=[taskInfoDic objectForKey:@"f_url"]; 572 | //info.ifvod=[taskInfoDic objectForKey:@"ifvod"]; 573 | //NSLog(@"Yun Name:%@",info.name); 574 | [elements addObject:info]; 575 | } 576 | //return info 577 | return elements; 578 | }else { 579 | return nil; 580 | } 581 | } 582 | 583 | #pragma mark - Add BT 584 | //本来不想加最后那个param的。。但是貌似重复上传文件但没有后续操作会导致添加文件失败。所以就加了这个。获取数据后,把dictionary填到最后一个位置就可以了 585 | //请注意selection的这个array里面存着的是findex 586 | 587 | - (NSString *)addBTTask:(NSString *)filePath selection:(NSArray *)array hasFetchedFileList:(NSDictionary *)dataField { 588 | if (array.count > 0) { 589 | if (dataField == nil) { 590 | dataField = [self fetchBTFileList:filePath]; 591 | } 592 | 593 | int ret_value = [dataField[@"ret_value"] intValue]; 594 | 595 | // ret value等于0就是失败啊,目前只看到出现过1,不知道会不会有别的值。所以这里先用不等于0作为判断。 596 | 597 | if (ret_value != 0) { 598 | 599 | NSString *dcid = dataField[@"infoid"]; 600 | NSString *tsize = dataField[@"btsize"]; 601 | NSString *btname = dataField[@"ftitle"]; 602 | NSArray *fileList = dataField[@"filelist"]; 603 | // NSString *random = dataField[@"random"]; 604 | // 605 | 606 | //提交任务 607 | NSURL *commitURL = [NSURL URLWithString:@"http://dynamic.cloud.vip.xunlei.com/interface/bt_task_commit"]; 608 | LCHTTPConnection* commitRequest = [LCHTTPConnection new]; 609 | 610 | NSArray *subSizes = [fileList valueForKey:@"subsize"]; 611 | 612 | NSMutableArray *sizeArray = [[NSMutableArray alloc] init]; 613 | for (NSString *select in array) { 614 | NSInteger index = [[fileList valueForKey:@"findex"] indexOfObject:select]; 615 | [sizeArray addObject:subSizes[index]]; 616 | } 617 | 618 | [commitRequest setPostValue:[self userID] forKey:@"uid"]; 619 | [commitRequest setPostValue:[URlEncode encodeToPercentEscapeString:btname] forKey:@"btname"]; 620 | [commitRequest setPostValue:dcid forKey:@"cid"]; 621 | [commitRequest setPostValue:@"0" forKey:@"goldbean"]; 622 | [commitRequest setPostValue:@"0" forKey:@"silverbean"]; 623 | [commitRequest setPostValue:tsize forKey:@"tsize"]; 624 | [commitRequest setPostValue:[array componentsJoinedByString:@"_"] forKey:@"findex"]; 625 | [commitRequest setPostValue:[sizeArray componentsJoinedByString:@"_"] forKey:@"size"]; 626 | [commitRequest setPostValue:@"0" forKey:@"o_taskid"]; 627 | [commitRequest setPostValue:@"task" forKey:@"o_page"]; 628 | [commitRequest setPostValue:@"0" forKey:@"class_id"]; 629 | [commitRequest setPostValue:@"task" forKey:@"interfrom"]; 630 | [commitRequest post:[commitURL absoluteString]]; 631 | return dcid; 632 | 633 | } 634 | } 635 | 636 | return nil; 637 | } 638 | 639 | - (NSDictionary *)fetchBTFileList:(NSString *)filePath { 640 | 641 | LCHTTPConnection *request=[LCHTTPConnection new]; 642 | NSString *postResult = [request postBTFile:filePath]; 643 | 644 | postResult = [postResult stringByReplacingOccurrencesOfString:@"" withString:@""]; 646 | 647 | NSDictionary *dataField = [NSJSONSerialization JSONObjectWithData:[postResult dataUsingEncoding:NSUTF8StringEncoding] options: NSJSONReadingMutableContainers error: nil]; 648 | 649 | return dataField; 650 | } 651 | 652 | - (NSString *)fileSize:(float)size { 653 | int counter = 0; 654 | while (size > 1000) { 655 | size /= 1000; 656 | counter++; 657 | } 658 | 659 | NSString *size_type = @"Bytes"; 660 | switch (counter) { 661 | case 1: 662 | size_type = @"KB"; 663 | break; 664 | 665 | case 2: 666 | size_type = @"MB"; 667 | break; 668 | 669 | case 3: 670 | size_type = @"GB"; 671 | break; 672 | 673 | case 4: 674 | size_type = @"TB"; 675 | break; 676 | 677 | case 5: 678 | size_type = @"PB"; 679 | break; 680 | 681 | default: 682 | break; 683 | } 684 | 685 | return [NSString stringWithFormat:@"%.2f %@", size, size_type]; 686 | } 687 | 688 | 689 | #pragma mark - Add Task 690 | //add megnet task 691 | //返回dcid作为文件标示 692 | -(NSString *) addMegnetTask:(NSString *) url{ 693 | NSString *dcid; 694 | NSString *tsize; 695 | NSString *btname; 696 | NSString *findex; 697 | NSString *sindex; 698 | NSString *enUrl=[URlEncode encodeToPercentEscapeString:url]; 699 | NSString *timestamp=[self _currentTimeString]; 700 | NSString *callURLString=[NSString stringWithFormat:@"http://dynamic.cloud.vip.xunlei.com/interface/url_query?callback=queryUrl&u=%@&random=%@",enUrl,timestamp]; 701 | NSURL *callURL=[NSURL URLWithString:callURLString]; 702 | LCHTTPConnection *request=[LCHTTPConnection new]; 703 | NSString* data=[request get:[callURL absoluteString]]; 704 | NSString *re=@"queryUrl(\\(1,.*\\))\\s*$"; 705 | NSString *sucsess=[data stringByMatching:re capture:1]; 706 | if(sucsess){ 707 | //NSLog(sucsess); 708 | NSArray *array=[sucsess componentsSeparatedByString:@"new Array"]; 709 | //first data 710 | NSString *dataGroup1=[array objectAtIndex:0]; 711 | //last data 712 | NSString *dataGroup2=[array objectAtIndex:([array count]-1)]; 713 | //last fourth data 714 | NSString *dataGroup3=[array objectAtIndex:([array count]-4)]; 715 | NSString *re1=@"['\"]?([^'\"]*)['\"]?"; 716 | dcid=[[[dataGroup1 componentsSeparatedByString:@","] objectAtIndex:1] stringByMatching:re1 capture:1]; 717 | //NSLog(cid); 718 | tsize=[[[dataGroup1 componentsSeparatedByString:@","] objectAtIndex:2] stringByMatching:re1 capture:1]; 719 | //NSLog(tsize); 720 | btname=[[[dataGroup1 componentsSeparatedByString:@","] objectAtIndex:3] stringByMatching:re1 capture:1]; 721 | //NSLog(btname); 722 | 723 | //findex 724 | NSString *re2=@"\\(([^\\)]*)\\)"; 725 | NSString *preString0=[dataGroup2 stringByMatching:re2 capture:1]; 726 | NSString *re3=@"'([^']*)'"; 727 | NSArray *preArray0=[preString0 arrayOfCaptureComponentsMatchedByRegex:re3]; 728 | NSMutableArray *preMutableArray=[NSMutableArray arrayWithCapacity:0]; 729 | for(NSArray *a in preArray0){ 730 | [preMutableArray addObject:[a objectAtIndex:1]]; 731 | } 732 | findex=[preMutableArray componentsJoinedByString:@"_"]; 733 | //NSLog(@"%@",findex); 734 | 735 | //size index 736 | preString0=[dataGroup3 stringByMatching:re2 capture:1]; 737 | preArray0=[preString0 arrayOfCaptureComponentsMatchedByRegex:re3]; 738 | NSMutableArray *preMutableArray1=[NSMutableArray arrayWithCapacity:0]; 739 | for(NSArray *a in preArray0){ 740 | [preMutableArray1 addObject:[a objectAtIndex:1]]; 741 | } 742 | sindex=[preMutableArray1 componentsJoinedByString:@"_"]; 743 | //NSLog(@"%@",sindex); 744 | 745 | //提交任务 746 | NSURL *commitURL = [NSURL URLWithString:@"http://dynamic.cloud.vip.xunlei.com/interface/bt_task_commit"]; 747 | LCHTTPConnection* commitRequest = [LCHTTPConnection new]; 748 | 749 | [commitRequest setPostValue:[self userID] forKey:@"uid"]; 750 | [commitRequest setPostValue:btname forKey:@"btname"]; 751 | [commitRequest setPostValue:dcid forKey:@"cid"]; 752 | [commitRequest setPostValue:tsize forKey:@"tsize"]; 753 | [commitRequest setPostValue:findex forKey:@"findex"]; 754 | [commitRequest setPostValue:sindex forKey:@"size"]; 755 | [commitRequest setPostValue:@"0" forKey:@"from"]; 756 | [commitRequest post:[commitURL absoluteString]]; 757 | }else { 758 | NSString *re1=@"queryUrl\\(-1,'([^']{40})"; 759 | dcid=[data stringByMatching:re1 capture:1]; 760 | } 761 | //NSLog(@"%@",cid); 762 | return dcid; 763 | } 764 | 765 | 766 | //add normal task(http,ed2k...) 767 | //返回dcid作为文件标示 768 | -(NSString *) addNormalTask:(NSString *)url{ 769 | ConvertURL *curl=[ConvertURL new]; 770 | NSString *decodeurl=[curl urlUnmask:url]; 771 | NSString *enUrl=[URlEncode encodeToPercentEscapeString:decodeurl]; 772 | NSString *timestamp=[self _currentTimeString]; 773 | NSString *callURLString=[NSString stringWithFormat:@"http://dynamic.cloud.vip.xunlei.com/interface/task_check?callback=queryCid&url=%@&random=%@&tcache=%@",enUrl,timestamp,timestamp]; 774 | // NSURL *callURL=[NSURL URLWithString:callURLString]; 775 | LCHTTPConnection *request=[LCHTTPConnection new]; 776 | NSString *dataRaw=[request get:callURLString]; 777 | 778 | NSString *dcid=@""; 779 | NSString *gcid=@""; 780 | NSString *size=@""; 781 | NSString *filename=@""; 782 | NSString *goldbeen=@""; 783 | NSString *silverbeen=@""; 784 | NSString *is_full=@""; 785 | NSString *random=@""; 786 | NSString *ext=@""; 787 | NSString *someKey=@""; 788 | NSString *taskType=@""; 789 | NSString *userid=@""; 790 | NSString *noCacheIE = @""; 791 | NSString *unknownData = @""; 792 | 793 | userid=[self userID]; 794 | 795 | 796 | if(([url rangeOfString:@"http://" options:NSCaseInsensitiveSearch].length>0)||([url rangeOfString:@"ftp://" options:NSCaseInsensitiveSearch].length>0)){ 797 | taskType=@"0"; 798 | }else if([url rangeOfString:@"ed2k://" options:NSCaseInsensitiveSearch].length>0){ 799 | taskType=@"2"; 800 | } 801 | 802 | NSString *re=@"queryCid\\((.+)\\)\\s*$"; 803 | NSString *sucsess=[dataRaw stringByMatching:re capture:1]; 804 | NSArray *data=[sucsess componentsSeparatedByString:@","]; 805 | NSMutableArray *newData=[NSMutableArray arrayWithCapacity:0]; 806 | for(NSString *i in data){ 807 | NSString *re1=@"\\s*['\"]?([^']*)['\"]?"; 808 | NSString *d=[i stringByMatching:re1 capture:1]; 809 | if(!d){ 810 | d=@""; 811 | } 812 | [newData addObject:d]; 813 | NSLog(@"%@",d); 814 | } 815 | if(8==data.count){ 816 | dcid=[newData objectAtIndex:0]; 817 | gcid=[newData objectAtIndex:1]; 818 | size=[newData objectAtIndex:2]; 819 | filename=[newData objectAtIndex:3]; 820 | goldbeen=[newData objectAtIndex:4]; 821 | silverbeen=[newData objectAtIndex:5]; 822 | is_full=[newData objectAtIndex:6]; 823 | random=[newData objectAtIndex:7]; 824 | } 825 | else if(9==data.count){ 826 | dcid=[newData objectAtIndex:0]; 827 | gcid=[newData objectAtIndex:1]; 828 | size=[newData objectAtIndex:2]; 829 | filename=[newData objectAtIndex:3]; 830 | goldbeen=[newData objectAtIndex:4]; 831 | silverbeen=[newData objectAtIndex:5]; 832 | is_full=[newData objectAtIndex:6]; 833 | random=[newData objectAtIndex:7]; 834 | ext=[newData objectAtIndex:8]; 835 | }else if(10==data.count){ 836 | dcid=[newData objectAtIndex:0]; 837 | gcid=[newData objectAtIndex:1]; 838 | size=[newData objectAtIndex:2]; 839 | someKey=[newData objectAtIndex:3]; 840 | filename=[newData objectAtIndex:4]; 841 | goldbeen=[newData objectAtIndex:5]; 842 | silverbeen=[newData objectAtIndex:6]; 843 | is_full=[newData objectAtIndex:7]; 844 | random=[newData objectAtIndex:8]; 845 | ext=[newData objectAtIndex:9]; 846 | } else if (data.count == 11) { 847 | dcid=[newData objectAtIndex:0]; 848 | gcid=[newData objectAtIndex:1]; 849 | size=[newData objectAtIndex:2]; 850 | someKey=[newData objectAtIndex:3]; 851 | filename=[newData objectAtIndex:4]; 852 | goldbeen=[newData objectAtIndex:5]; 853 | silverbeen=[newData objectAtIndex:6]; 854 | is_full=[newData objectAtIndex:7]; 855 | noCacheIE=[newData objectAtIndex:8]; 856 | ext=[newData objectAtIndex:9]; 857 | unknownData = newData[10]; 858 | 859 | } 860 | //filename如果是中文放到URL中会有编码问题,需要转码 861 | NSString *newFilename=[URlEncode encodeToPercentEscapeString:filename]; 862 | 863 | double UTCTime=[[NSDate date] timeIntervalSince1970]; 864 | NSString *currentTime=[NSString stringWithFormat:@"%f",UTCTime*1000]; 865 | 866 | NSString *commitString1 = [NSString stringWithFormat:@"http://dynamic.cloud.vip.xunlei.com/interface/task_check?callback=queryCid&url=%@&interfrom=task&random=%@&tcache=%@", enUrl, currentTime,timestamp]; 867 | 868 | NSString *commitString2 = [NSString stringWithFormat:@"http://dynamic.cloud.vip.xunlei.com/interface/task_commit?callback=ret_task&uid=%@&cid=%@&gcid=%@&size=%@&goldbean=%@&silverbean=%@&t=%@&url=%@&type=%@&o_page=history&o_taskid=0&class_id=0&database=undefined&interfrom=task&noCacheIE=%@",userid,dcid,gcid,size,goldbeen,silverbeen,newFilename,enUrl,taskType,timestamp]; 869 | 870 | //NSLog(@"%@",commitString); 871 | NSURL *commitURL1=[NSURL URLWithString:commitString1]; 872 | NSLog(@"%@",commitURL1); 873 | LCHTTPConnection *commitRequest1=[LCHTTPConnection new]; 874 | [commitRequest1 get:commitString1]; 875 | 876 | //NSLog(@"%@",commitString); 877 | NSURL *commitURL2=[NSURL URLWithString:commitString2]; 878 | NSLog(@"%@",commitURL2); 879 | LCHTTPConnection *commitRequest2=[LCHTTPConnection new]; 880 | [commitRequest2 get:commitString2]; 881 | 882 | return dcid; 883 | } 884 | 885 | -(unsigned long long)getRandomNumberBetween:(unsigned long long)from to:(unsigned long long)to { 886 | 887 | return (unsigned long long)from + arc4random() % (to-from+1); 888 | } 889 | 890 | #pragma mark - Delete Task 891 | //Delete tasks 892 | -(BOOL) deleteSingleTaskByID:(NSString*) id{ 893 | BOOL result=NO; 894 | result=[self deleteTasksByArray:@[id]]; 895 | return result; 896 | } 897 | -(BOOL) deleteTasksByIDArray:(NSArray *)ids{ 898 | BOOL result=NO; 899 | result=[self deleteTasksByArray:ids]; 900 | return result; 901 | } 902 | -(BOOL) deleteSingleTaskByXunleiItemInfo:(XunleiItemInfo*) aInfo{ 903 | BOOL result=NO; 904 | result=[self deleteTasksByArray:@[aInfo]]; 905 | return result; 906 | } 907 | -(BOOL) deleteTasksByXunleiItemInfoArray:(NSArray *)ids{ 908 | BOOL result=NO; 909 | result=[self deleteTasksByArray:ids]; 910 | return result; 911 | } 912 | -(BOOL) deleteTasksByArray:(NSArray *)ids{ 913 | BOOL returnResult=NO; 914 | NSMutableString *idString=[NSMutableString string]; 915 | for(id i in ids){ 916 | if([i isKindOfClass:[XunleiItemInfo class]]){ 917 | [idString appendString:[(XunleiItemInfo*)i taskid]]; 918 | }else if([i isKindOfClass:[NSString class]]){ 919 | [idString appendString:i]; 920 | }else{ 921 | NSLog(@"Warning!!deleteTasksByArray:UnKnown Type!"); 922 | //[idString appendString:i]; 923 | } 924 | [idString appendString:@","]; 925 | } 926 | NSString *jsonString=[NSString stringWithFormat:@"jsonp%@",[self _currentTimeString]]; 927 | NSString *urlString=[NSString stringWithFormat:@"http://dynamic.cloud.vip.xunlei.com/interface/task_delete?callback=%@&type=2",jsonString]; 928 | NSLog(@"%@",urlString); 929 | NSURL *url=[NSURL URLWithString:urlString]; 930 | LCHTTPConnection *request=[LCHTTPConnection new]; 931 | NSMutableString *IDs_postdata=[[ids componentsJoinedByString:@","] mutableCopy]; 932 | [IDs_postdata appendString:@","]; 933 | NSString *databasesID_postdata=@"0,"; 934 | [request setPostValue:IDs_postdata forKey:@"taskids"]; 935 | [request setPostValue:databasesID_postdata forKey:@"databases"]; 936 | NSString *requestString=[request post:[url absoluteString]]; 937 | if ([requestString hasSuffix:@"({\"result\":1,\"type\":2})"]) { 938 | returnResult=YES; 939 | } 940 | return returnResult; 941 | } 942 | #pragma mark - Pause Task 943 | -(BOOL) pauseMultiTasksByTaskID:(NSArray*) ids{ 944 | BOOL returnResult=NO; 945 | NSString* idString=[ids componentsJoinedByString:@","]; 946 | NSString *requestString=[NSString stringWithFormat:@"http://dynamic.cloud.vip.xunlei.com/interface/task_pause?tid=%@&uid=%@",idString,[self userID]]; 947 | LCHTTPConnection *request=[LCHTTPConnection new]; 948 | NSString* responsed=[request get:requestString]; 949 | if(responsed){ 950 | returnResult=YES; 951 | } 952 | return returnResult; 953 | } 954 | -(BOOL) pauseTaskWithID:(NSString*) taskID{ 955 | return [self pauseMultiTasksByTaskID:@[ taskID ]]; 956 | } 957 | -(BOOL) pauseTask:(XunleiItemInfo*) info{ 958 | return [self pauseTaskWithID:info.taskid]; 959 | } 960 | -(BOOL) pauseMutiTasksByTaskItemInfo:(NSArray*) infos{ 961 | NSMutableArray* tids=[NSMutableArray arrayWithCapacity:0]; 962 | for(XunleiItemInfo *info in infos){ 963 | [tids addObject:[info taskid]]; 964 | } 965 | return [self pauseMultiTasksByTaskID:tids]; 966 | } 967 | #pragma mark - ReStart Task 968 | -(BOOL) restartTask:(XunleiItemInfo*) info{ 969 | return [self restartMutiTasksByTaskItemInfo:@[info]]; 970 | } 971 | -(BOOL) restartMutiTasksByTaskItemInfo:(NSArray*) infos{ 972 | BOOL returnResult=YES; 973 | for(XunleiItemInfo* info in infos){ 974 | NSString* callbackString=[NSString stringWithFormat:@"jsonp%@",[self _currentTimeString]]; 975 | NSURL *requestURL=[NSURL URLWithString:[NSString stringWithFormat:@"http://dynamic.cloud.vip.xunlei.com/interface/redownload?callback=%@",callbackString]]; 976 | 977 | LCHTTPConnection* commitRequest = [LCHTTPConnection new]; 978 | [commitRequest setPostValue:info.taskid forKey:@"id[]"]; 979 | [commitRequest setPostValue:info.dcid forKey:@"cid[]"]; 980 | [commitRequest setPostValue:info.originalURL forKey:@"url[]"]; 981 | [commitRequest setPostValue:info.name forKey:@"taskname[]"]; 982 | [commitRequest setPostValue:[NSString stringWithFormat:@"%u",info.status] forKey:@"download_status[]"]; 983 | [commitRequest setPostValue:@"1" forKey:@"type"]; 984 | [commitRequest setPostValue:@"0" forKey:@"class_id"]; 985 | NSString *responseString=[commitRequest post:[requestURL absoluteString]]; 986 | if (!responseString) { 987 | returnResult=NO; 988 | } 989 | } 990 | return returnResult; 991 | } 992 | #pragma mark - Yun ZhuanMa Methods 993 | //Yun Zhuan Ma 994 | -(BOOL) addYunTaskWithFileSize:(NSString*) size downloadURL:(NSString*) url dcid:(NSString*) cid fileName:(NSString*) aName Quality:(YUNZHUANMAQuality) q{ 995 | NSString *gcid=[ParseElements GCID:url]; 996 | NSURL *requestURL=[NSURL URLWithString:@"http://dynamic.cloud.vip.xunlei.com/interface/cloud_build_task/"]; 997 | NSString *detailTaskPostValue=[NSString stringWithFormat:@"[{\"section_type\":\"c7\",\"filesize\":\"%@\",\"gcid\":\"%@\",\"cid\":\"%@\",\"filename\":\"%@\"}]",size,gcid,cid,aName]; 998 | LCHTTPConnection* commitRequest = [LCHTTPConnection new]; 999 | NSString *cloudFormat=[NSString stringWithFormat:@"%d",q]; 1000 | [commitRequest setPostValue:cloudFormat forKey:@"cloud_format"]; 1001 | [commitRequest setPostValue:detailTaskPostValue forKey:@"tasks"]; 1002 | NSString *response=[commitRequest post:[requestURL absoluteString]]; 1003 | if(response){ 1004 | NSDictionary *rDict=[response objectFromJSONString]; 1005 | if([rDict objectForKey:@"succ"] && [[rDict objectForKey:@"succ"] intValue]==1){ 1006 | return YES; 1007 | } 1008 | } 1009 | return NO; 1010 | } 1011 | -(BOOL) deleteYunTaskByID:(NSString*) anId{ 1012 | return [self deleteYunTasksByIDArray:@[anId]]; 1013 | } 1014 | 1015 | -(BOOL) deleteYunTasksByIDArray:(NSArray *)ids{ 1016 | BOOL returnResult=NO; 1017 | NSString *jsontext=[ids JSONString]; 1018 | NSURL *url=[NSURL URLWithString:@"http://dynamic.cloud.vip.xunlei.com/interface/cloud_delete_task"]; 1019 | LCHTTPConnection*request = [LCHTTPConnection new]; 1020 | 1021 | [request setPostValue:jsontext forKey:@"tasks"]; 1022 | 1023 | NSString *response=[request post:[url absoluteString]]; 1024 | if(response){ 1025 | NSDictionary *resJson=[response objectFromJSONString]; 1026 | if([[resJson objectForKey:@"result"] intValue]==0){ 1027 | returnResult=YES; 1028 | } 1029 | } 1030 | return returnResult; 1031 | } 1032 | #pragma mark - Xunlei KuaiChuan ...迅雷快传 1033 | -(BOOL) addAllKuaiTasksToLixianByURL:(NSURL*) kuaiURL{ 1034 | BOOL result=NO; 1035 | Kuai *k=[Kuai new]; 1036 | NSArray *infos=[k kuaiItemInfoArrayByKuaiURL:kuaiURL]; 1037 | for(KuaiItemInfo *i in infos){ 1038 | NSString *url=i.urlString; 1039 | NSString* t=[self addNormalTask:url]; 1040 | if(t) result=YES; 1041 | } 1042 | return result; 1043 | } 1044 | -(NSArray*) getKuaiItemInfos:(NSURL*) kuaiURL{ 1045 | Kuai *k=[Kuai new]; 1046 | return [k kuaiItemInfoArrayByKuaiURL:kuaiURL]; 1047 | } 1048 | 1049 | -(NSString*) generateXunleiURLStringByKuaiItemInfo:(KuaiItemInfo*) info{ 1050 | Kuai *k=[Kuai new]; 1051 | return [k generateLixianUrl:info]; 1052 | } 1053 | 1054 | #pragma mark - Other Useful Methods 1055 | -(void) _addResponseCookietoCookieStorage:(NSArray*) cookieArray{ 1056 | //在iOS下还没有问题,但是在Mac下,如果收到的Cookie没有ExpireDate那么就不会存储到CookieStorage中,会造成获取错误 1057 | //目前为了不影响原有的带有ExpireDate的Cookie,只是在登陆上的几个跳转加了ExpireDate 1058 | //其实这么做迅雷没有什么问题,本来那几个登陆的关键值就是Non-Session的,反而是Mac OS蛋疼了 1059 | //参考连接:http://stackoverflow.com/questions/11570737/shared-instance-of-nshttpcookiestorage-does-not-persist-cookies 1060 | //WTF!!! 1061 | for(NSHTTPCookie* i in cookieArray ){ 1062 | [self setCookieWithKey:i.name Value:i.value]; 1063 | } 1064 | } 1065 | 1066 | -(XunleiItemInfo *) getTaskWithTaskID:(NSString*) aTaskID{ 1067 | XunleiItemInfo *r=nil; 1068 | NSMutableArray *array=[self _readAllTasksWithStat:TLTAll]; 1069 | for(XunleiItemInfo* i in array){ 1070 | if(i.taskid==aTaskID){ 1071 | r=i; 1072 | } 1073 | } 1074 | return r; 1075 | } 1076 | 1077 | //取得当前UTC时间,并转换成13位数字字符 1078 | -(NSString *) _currentTimeString{ 1079 | double UTCTime=[[NSDate date] timeIntervalSince1970]; 1080 | NSString *currentTime=[NSString stringWithFormat:@"%f",UTCTime*1000]; 1081 | NSLog(@"%@",currentTime); 1082 | currentTime=[[currentTime componentsSeparatedByString:@"."] objectAtIndex:0]; 1083 | 1084 | return currentTime; 1085 | } 1086 | @end 1087 | -------------------------------------------------------------------------------- /TondarAPI/JSONKit/JSONKit.h: -------------------------------------------------------------------------------- 1 | // 2 | // JSONKit.h 3 | // http://github.com/johnezang/JSONKit 4 | // Dual licensed under either the terms of the BSD License, or alternatively 5 | // under the terms of the Apache License, Version 2.0, as specified below. 6 | // 7 | 8 | /* 9 | Copyright (c) 2011, John Engelhart 10 | 11 | All rights reserved. 12 | 13 | Redistribution and use in source and binary forms, with or without 14 | modification, are permitted provided that the following conditions are met: 15 | 16 | * Redistributions of source code must retain the above copyright 17 | notice, this list of conditions and the following disclaimer. 18 | 19 | * Redistributions in binary form must reproduce the above copyright 20 | notice, this list of conditions and the following disclaimer in the 21 | documentation and/or other materials provided with the distribution. 22 | 23 | * Neither the name of the Zang Industries nor the names of its 24 | contributors may be used to endorse or promote products derived from 25 | this software without specific prior written permission. 26 | 27 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 28 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 29 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 30 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 31 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 32 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 33 | TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 34 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 35 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 36 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 37 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 38 | */ 39 | 40 | /* 41 | Copyright 2011 John Engelhart 42 | 43 | Licensed under the Apache License, Version 2.0 (the "License"); 44 | you may not use this file except in compliance with the License. 45 | You may obtain a copy of the License at 46 | 47 | http://www.apache.org/licenses/LICENSE-2.0 48 | 49 | Unless required by applicable law or agreed to in writing, software 50 | distributed under the License is distributed on an "AS IS" BASIS, 51 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 52 | See the License for the specific language governing permissions and 53 | limitations under the License. 54 | */ 55 | 56 | #include 57 | #include 58 | #include 59 | #include 60 | #include 61 | 62 | #ifdef __OBJC__ 63 | #import 64 | #import 65 | #import 66 | #import 67 | #import 68 | #import 69 | #endif // __OBJC__ 70 | 71 | #ifdef __cplusplus 72 | extern "C" { 73 | #endif 74 | 75 | 76 | // For Mac OS X < 10.5. 77 | #ifndef NSINTEGER_DEFINED 78 | #define NSINTEGER_DEFINED 79 | #if defined(__LP64__) || defined(NS_BUILD_32_LIKE_64) 80 | typedef long NSInteger; 81 | typedef unsigned long NSUInteger; 82 | #define NSIntegerMin LONG_MIN 83 | #define NSIntegerMax LONG_MAX 84 | #define NSUIntegerMax ULONG_MAX 85 | #else // defined(__LP64__) || defined(NS_BUILD_32_LIKE_64) 86 | typedef int NSInteger; 87 | typedef unsigned int NSUInteger; 88 | #define NSIntegerMin INT_MIN 89 | #define NSIntegerMax INT_MAX 90 | #define NSUIntegerMax UINT_MAX 91 | #endif // defined(__LP64__) || defined(NS_BUILD_32_LIKE_64) 92 | #endif // NSINTEGER_DEFINED 93 | 94 | 95 | #ifndef _JSONKIT_H_ 96 | #define _JSONKIT_H_ 97 | 98 | #if defined(__GNUC__) && (__GNUC__ >= 4) && defined(__APPLE_CC__) && (__APPLE_CC__ >= 5465) 99 | #define JK_DEPRECATED_ATTRIBUTE __attribute__((deprecated)) 100 | #else 101 | #define JK_DEPRECATED_ATTRIBUTE 102 | #endif 103 | 104 | #define JSONKIT_VERSION_MAJOR 1 105 | #define JSONKIT_VERSION_MINOR 4 106 | 107 | typedef NSUInteger JKFlags; 108 | 109 | /* 110 | JKParseOptionComments : Allow C style // and /_* ... *_/ (without a _, obviously) comments in JSON. 111 | JKParseOptionUnicodeNewlines : Allow Unicode recommended (?:\r\n|[\n\v\f\r\x85\p{Zl}\p{Zp}]) newlines. 112 | JKParseOptionLooseUnicode : Normally the decoder will stop with an error at any malformed Unicode. 113 | This option allows JSON with malformed Unicode to be parsed without reporting an error. 114 | Any malformed Unicode is replaced with \uFFFD, or "REPLACEMENT CHARACTER". 115 | */ 116 | 117 | enum { 118 | JKParseOptionNone = 0, 119 | JKParseOptionStrict = 0, 120 | JKParseOptionComments = (1 << 0), 121 | JKParseOptionUnicodeNewlines = (1 << 1), 122 | JKParseOptionLooseUnicode = (1 << 2), 123 | JKParseOptionPermitTextAfterValidJSON = (1 << 3), 124 | JKParseOptionValidFlags = (JKParseOptionComments | JKParseOptionUnicodeNewlines | JKParseOptionLooseUnicode | JKParseOptionPermitTextAfterValidJSON), 125 | }; 126 | typedef JKFlags JKParseOptionFlags; 127 | 128 | enum { 129 | JKSerializeOptionNone = 0, 130 | JKSerializeOptionPretty = (1 << 0), 131 | JKSerializeOptionEscapeUnicode = (1 << 1), 132 | JKSerializeOptionEscapeForwardSlashes = (1 << 4), 133 | JKSerializeOptionValidFlags = (JKSerializeOptionPretty | JKSerializeOptionEscapeUnicode | JKSerializeOptionEscapeForwardSlashes), 134 | }; 135 | typedef JKFlags JKSerializeOptionFlags; 136 | 137 | #ifdef __OBJC__ 138 | 139 | typedef struct JKParseState JKParseState; // Opaque internal, private type. 140 | 141 | // As a general rule of thumb, if you use a method that doesn't accept a JKParseOptionFlags argument, it defaults to JKParseOptionStrict 142 | 143 | @interface JSONDecoder : NSObject { 144 | JKParseState *parseState; 145 | } 146 | + (id)decoder; 147 | + (id)decoderWithParseOptions:(JKParseOptionFlags)parseOptionFlags; 148 | - (id)initWithParseOptions:(JKParseOptionFlags)parseOptionFlags; 149 | - (void)clearCache; 150 | 151 | // The parse... methods were deprecated in v1.4 in favor of the v1.4 objectWith... methods. 152 | - (id)parseUTF8String:(const unsigned char *)string length:(size_t)length JK_DEPRECATED_ATTRIBUTE; // Deprecated in JSONKit v1.4. Use objectWithUTF8String:length: instead. 153 | - (id)parseUTF8String:(const unsigned char *)string length:(size_t)length error:(NSError **)error JK_DEPRECATED_ATTRIBUTE; // Deprecated in JSONKit v1.4. Use objectWithUTF8String:length:error: instead. 154 | // The NSData MUST be UTF8 encoded JSON. 155 | - (id)parseJSONData:(NSData *)jsonData JK_DEPRECATED_ATTRIBUTE; // Deprecated in JSONKit v1.4. Use objectWithData: instead. 156 | - (id)parseJSONData:(NSData *)jsonData error:(NSError **)error JK_DEPRECATED_ATTRIBUTE; // Deprecated in JSONKit v1.4. Use objectWithData:error: instead. 157 | 158 | // Methods that return immutable collection objects. 159 | - (id)objectWithUTF8String:(const unsigned char *)string length:(NSUInteger)length; 160 | - (id)objectWithUTF8String:(const unsigned char *)string length:(NSUInteger)length error:(NSError **)error; 161 | // The NSData MUST be UTF8 encoded JSON. 162 | - (id)objectWithData:(NSData *)jsonData; 163 | - (id)objectWithData:(NSData *)jsonData error:(NSError **)error; 164 | 165 | // Methods that return mutable collection objects. 166 | - (id)mutableObjectWithUTF8String:(const unsigned char *)string length:(NSUInteger)length; 167 | - (id)mutableObjectWithUTF8String:(const unsigned char *)string length:(NSUInteger)length error:(NSError **)error; 168 | // The NSData MUST be UTF8 encoded JSON. 169 | - (id)mutableObjectWithData:(NSData *)jsonData; 170 | - (id)mutableObjectWithData:(NSData *)jsonData error:(NSError **)error; 171 | 172 | @end 173 | 174 | //////////// 175 | #pragma mark Deserializing methods 176 | //////////// 177 | 178 | @interface NSString (JSONKitDeserializing) 179 | - (id)objectFromJSONString; 180 | - (id)objectFromJSONStringWithParseOptions:(JKParseOptionFlags)parseOptionFlags; 181 | - (id)objectFromJSONStringWithParseOptions:(JKParseOptionFlags)parseOptionFlags error:(NSError **)error; 182 | - (id)mutableObjectFromJSONString; 183 | - (id)mutableObjectFromJSONStringWithParseOptions:(JKParseOptionFlags)parseOptionFlags; 184 | - (id)mutableObjectFromJSONStringWithParseOptions:(JKParseOptionFlags)parseOptionFlags error:(NSError **)error; 185 | @end 186 | 187 | @interface NSData (JSONKitDeserializing) 188 | // The NSData MUST be UTF8 encoded JSON. 189 | - (id)objectFromJSONData; 190 | - (id)objectFromJSONDataWithParseOptions:(JKParseOptionFlags)parseOptionFlags; 191 | - (id)objectFromJSONDataWithParseOptions:(JKParseOptionFlags)parseOptionFlags error:(NSError **)error; 192 | - (id)mutableObjectFromJSONData; 193 | - (id)mutableObjectFromJSONDataWithParseOptions:(JKParseOptionFlags)parseOptionFlags; 194 | - (id)mutableObjectFromJSONDataWithParseOptions:(JKParseOptionFlags)parseOptionFlags error:(NSError **)error; 195 | @end 196 | 197 | //////////// 198 | #pragma mark Serializing methods 199 | //////////// 200 | 201 | @interface NSString (JSONKitSerializing) 202 | // Convenience methods for those that need to serialize the receiving NSString (i.e., instead of having to serialize a NSArray with a single NSString, you can "serialize to JSON" just the NSString). 203 | // Normally, a string that is serialized to JSON has quotation marks surrounding it, which you may or may not want when serializing a single string, and can be controlled with includeQuotes: 204 | // includeQuotes:YES `a "test"...` -> `"a \"test\"..."` 205 | // includeQuotes:NO `a "test"...` -> `a \"test\"...` 206 | - (NSData *)JSONData; // Invokes JSONDataWithOptions:JKSerializeOptionNone includeQuotes:YES 207 | - (NSData *)JSONDataWithOptions:(JKSerializeOptionFlags)serializeOptions includeQuotes:(BOOL)includeQuotes error:(NSError **)error; 208 | - (NSString *)JSONString; // Invokes JSONStringWithOptions:JKSerializeOptionNone includeQuotes:YES 209 | - (NSString *)JSONStringWithOptions:(JKSerializeOptionFlags)serializeOptions includeQuotes:(BOOL)includeQuotes error:(NSError **)error; 210 | @end 211 | 212 | @interface NSArray (JSONKitSerializing) 213 | - (NSData *)JSONData; 214 | - (NSData *)JSONDataWithOptions:(JKSerializeOptionFlags)serializeOptions error:(NSError **)error; 215 | - (NSData *)JSONDataWithOptions:(JKSerializeOptionFlags)serializeOptions serializeUnsupportedClassesUsingDelegate:(id)delegate selector:(SEL)selector error:(NSError **)error; 216 | - (NSString *)JSONString; 217 | - (NSString *)JSONStringWithOptions:(JKSerializeOptionFlags)serializeOptions error:(NSError **)error; 218 | - (NSString *)JSONStringWithOptions:(JKSerializeOptionFlags)serializeOptions serializeUnsupportedClassesUsingDelegate:(id)delegate selector:(SEL)selector error:(NSError **)error; 219 | @end 220 | 221 | @interface NSDictionary (JSONKitSerializing) 222 | - (NSData *)JSONData; 223 | - (NSData *)JSONDataWithOptions:(JKSerializeOptionFlags)serializeOptions error:(NSError **)error; 224 | - (NSData *)JSONDataWithOptions:(JKSerializeOptionFlags)serializeOptions serializeUnsupportedClassesUsingDelegate:(id)delegate selector:(SEL)selector error:(NSError **)error; 225 | - (NSString *)JSONString; 226 | - (NSString *)JSONStringWithOptions:(JKSerializeOptionFlags)serializeOptions error:(NSError **)error; 227 | - (NSString *)JSONStringWithOptions:(JKSerializeOptionFlags)serializeOptions serializeUnsupportedClassesUsingDelegate:(id)delegate selector:(SEL)selector error:(NSError **)error; 228 | @end 229 | 230 | #ifdef __BLOCKS__ 231 | 232 | @interface NSArray (JSONKitSerializingBlockAdditions) 233 | - (NSData *)JSONDataWithOptions:(JKSerializeOptionFlags)serializeOptions serializeUnsupportedClassesUsingBlock:(id(^)(id object))block error:(NSError **)error; 234 | - (NSString *)JSONStringWithOptions:(JKSerializeOptionFlags)serializeOptions serializeUnsupportedClassesUsingBlock:(id(^)(id object))block error:(NSError **)error; 235 | @end 236 | 237 | @interface NSDictionary (JSONKitSerializingBlockAdditions) 238 | - (NSData *)JSONDataWithOptions:(JKSerializeOptionFlags)serializeOptions serializeUnsupportedClassesUsingBlock:(id(^)(id object))block error:(NSError **)error; 239 | - (NSString *)JSONStringWithOptions:(JKSerializeOptionFlags)serializeOptions serializeUnsupportedClassesUsingBlock:(id(^)(id object))block error:(NSError **)error; 240 | @end 241 | 242 | #endif 243 | 244 | 245 | #endif // __OBJC__ 246 | 247 | #endif // _JSONKIT_H_ 248 | 249 | #ifdef __cplusplus 250 | } // extern "C" 251 | #endif 252 | -------------------------------------------------------------------------------- /TondarAPI/Kuai.h: -------------------------------------------------------------------------------- 1 | // 2 | // Kuai.h 3 | // TondarAPI 4 | // 5 | // Created by liuchao on 8/20/12. 6 | // Copyright (c) 2012 HwaYing. All rights reserved. 7 | // 8 | /*This file is part of XunleiLixian-API. 9 | 10 | XunleiLixian-API is free software: you can redistribute it and/or modify 11 | it under the terms of the GNU General Public License as published by 12 | the Free Software Foundation, either version 3 of the License, or 13 | (at your option) any later version. 14 | 15 | Foobar is distributed in the hope that it will be useful, 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | GNU General Public License for more details. 19 | 20 | You should have received a copy of the GNU General Public License 21 | along with Foobar. If not, see . 22 | */ 23 | #import 24 | 25 | @interface KuaiItemInfo : NSObject 26 | @property NSString* urlString; 27 | @property NSString *name; 28 | @property NSString *size; 29 | @property NSString *gcid; 30 | @property NSString *cid; 31 | @property NSString *gcid_resid; 32 | @property NSString *fid; 33 | @property NSString *tid; 34 | @property NSString *namehex; 35 | @property NSString *internalid; 36 | @property NSString *taskid; 37 | @end 38 | 39 | @interface Kuai : NSObject 40 | -(NSArray*) kuaiItemInfoArrayByKuaiURL:(NSURL*) kuaiURL; 41 | -(NSString*) generateLixianUrl:(KuaiItemInfo*) itemInfo; 42 | @end 43 | -------------------------------------------------------------------------------- /TondarAPI/Kuai.m: -------------------------------------------------------------------------------- 1 | // 2 | // Kuai.m 3 | // TondarAPI 4 | // 5 | // Created by liuchao on 8/20/12. 6 | // Copyright (c) 2012 HwaYing. All rights reserved. 7 | // 8 | /*This file is part of XunleiLixian-API. 9 | 10 | XunleiLixian-API is free software: you can redistribute it and/or modify 11 | it under the terms of the GNU General Public License as published by 12 | the Free Software Foundation, either version 3 of the License, or 13 | (at your option) any later version. 14 | 15 | Foobar is distributed in the hope that it will be useful, 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | GNU General Public License for more details. 19 | 20 | You should have received a copy of the GNU General Public License 21 | along with Foobar. If not, see . 22 | */ 23 | #import "Kuai.h" 24 | #import "LCHTTPConnection.h" 25 | #import "NSString+RE.h" 26 | @implementation KuaiItemInfo 27 | -(id)init{ 28 | self=[super init]; 29 | if(self){ 30 | _name=nil; 31 | _urlString=nil; 32 | _size=nil; 33 | _gcid=nil; 34 | _cid=nil; 35 | _gcid_resid=nil; 36 | _fid=nil; 37 | _tid=nil; 38 | _namehex=@"0102"; 39 | _internalid=@"111"; 40 | _taskid=@"xxx"; 41 | } 42 | return self; 43 | } 44 | 45 | @end 46 | 47 | 48 | @implementation Kuai 49 | 50 | -(NSArray*) kuaiItemInfoArrayByKuaiURL:(NSURL*) kuaiURL{ 51 | NSMutableArray *retArray=[NSMutableArray arrayWithCapacity:0]; 52 | LCHTTPConnection *request=[LCHTTPConnection new]; 53 | NSString* data=[request get:[kuaiURL absoluteString]]; 54 | if(data){ 55 | NSString* re=@"file_name=\"([^\"]*)\"\\s*file_url=\"([^\"]*)\"\\s*file_size=\"([^\"]*)\"\\s*cid=\"([^\"]*)\"\\s*gcid=\"([^\"]*)\"\\s*gcid_resid=\"([^\"]*)\""; 56 | NSArray *originalUrlInfoArray=[data arrayOfCaptureComponentsMatchedByRegex:re]; 57 | for(NSArray *i in originalUrlInfoArray){ 58 | KuaiItemInfo *item=[KuaiItemInfo new]; 59 | item.name=[i objectAtIndex:1]; 60 | item.urlString=[i objectAtIndex:2]; 61 | item.size=[i objectAtIndex:3]; 62 | item.cid=[i objectAtIndex:4]; 63 | item.gcid=[i objectAtIndex:5]; 64 | item.gcid_resid=[i objectAtIndex:6]; 65 | 66 | NSString *fidRex=@"fid=([^&]+)"; 67 | item.fid=[item.urlString stringByMatching:fidRex capture:1]; 68 | 69 | NSString *tidRex=@"tid=([^&]+)"; 70 | item.tid=[item.urlString stringByMatching:tidRex capture:1]; 71 | 72 | [retArray addObject:item]; 73 | item=nil; 74 | // NSLog(@"%@",[i objectAtIndex:1]); 75 | // NSLog(@"%@",[i objectAtIndex:4]); 76 | // NSLog(@"%@",tid); 77 | } 78 | } 79 | return retArray; 80 | } 81 | -(NSString*) generateLixianUrl:(KuaiItemInfo*) itemInfo{ 82 | NSString *urlT=[NSString stringWithFormat:@"http://gdl.lixian.vip.xunlei.com/download?fid=%@&mid=666&threshold=150&tid=%@&srcid=4&verno=1&g=%@&scn=t16&i=%@&t=1&ui=%@&ti=%@&s=%@&m=0&n=%@",itemInfo.fid,itemInfo.tid,itemInfo.gcid,itemInfo.gcid,itemInfo.internalid,itemInfo.taskid,itemInfo.size,itemInfo.namehex]; 83 | return urlT; 84 | } 85 | @end 86 | -------------------------------------------------------------------------------- /TondarAPI/LCHTTPConnection.h: -------------------------------------------------------------------------------- 1 | // 2 | // LCHTTPConnection.h 3 | // TondarAPI 4 | // 5 | // Created by Martian on 12-9-29. 6 | // Copyright (c) 2012年 LiuChao. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface LCHTTPConnection : NSObject 12 | 13 | @property NSMutableArray* responseCookies; 14 | + (LCHTTPConnection *)sharedZZHTTPConnection; 15 | - (NSString *)get:(NSString *)urlString; 16 | - (NSString*)post:(NSString*)urlString withBody:(NSString *)bodyData; 17 | -(NSString*) post:(NSString*) urlString; 18 | -(void) setPostValue:(NSString*) key forKey:(NSString*) value; 19 | - (NSString*)postBTFile:(NSString*)filePath; 20 | @end 21 | -------------------------------------------------------------------------------- /TondarAPI/LCHTTPConnection.m: -------------------------------------------------------------------------------- 1 | // 2 | // LCHTTPConnection.m 3 | // TondarAPI 4 | // 5 | // Created by Martian on 12-9-29. 6 | // Copyright (c) 2012年 LiuChao. All rights reserved. 7 | // 8 | 9 | #import "LCHTTPConnection.h" 10 | 11 | @interface LCHTTPConnection() 12 | @property NSMutableArray *postData; 13 | @end 14 | 15 | @implementation LCHTTPConnection 16 | @synthesize postData; 17 | 18 | 19 | + (LCHTTPConnection *)sharedZZHTTPConnection { 20 | static LCHTTPConnection *_sharedZZHTTPConnection = nil; 21 | if (!_sharedZZHTTPConnection) { 22 | _sharedZZHTTPConnection = [[self alloc] init]; 23 | } 24 | return _sharedZZHTTPConnection; 25 | } 26 | 27 | //发送GET请求 28 | - (NSString *)get:(NSString *)urlString { 29 | NSMutableURLRequest *_urlRequest = [[NSMutableURLRequest alloc] init]; 30 | 31 | _urlRequest = [[NSMutableURLRequest alloc] init]; 32 | [_urlRequest addValue:@"User-Agent:Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/535.2 (KHTML, like Gecko) Chrome/15.0.874.106 Safari/535.2" forHTTPHeaderField:@"User-Agent"]; 33 | [_urlRequest setTimeoutInterval: 15]; 34 | [_urlRequest addValue:@"http://lixian.vip.xunlei.com/" forHTTPHeaderField:@"Referer"]; 35 | [_urlRequest addValue:@"text/xml" forHTTPHeaderField: @"Content-Type"]; 36 | [_urlRequest setURL:[NSURL URLWithString:urlString]]; 37 | [_urlRequest setHTTPMethod:@"GET"]; 38 | 39 | NSHTTPCookieStorage *cookieJar = [NSHTTPCookieStorage sharedHTTPCookieStorage]; 40 | NSMutableString *cookie_str = [[NSMutableString alloc] init]; 41 | for(NSHTTPCookie *cookie in [cookieJar cookies]){ 42 | if([cookie.domain hasSuffix:@".xunlei.com"]){ 43 | [cookie_str setString:[cookie_str stringByAppendingFormat:@"%@=%@; ", cookie.name, cookie.value]]; 44 | } 45 | } 46 | [_urlRequest setValue:cookie_str forHTTPHeaderField:@"Cookie"]; 47 | 48 | NSHTTPURLResponse* urlResponse = nil; 49 | NSError *error = nil; 50 | NSData *responseData = [NSURLConnection sendSynchronousRequest:_urlRequest returningResponse:&urlResponse error:&error]; 51 | 52 | NSString *responseResult = [[NSString alloc] initWithData:responseData encoding:NSUTF8StringEncoding]; 53 | if ([[urlResponse allHeaderFields] objectForKey:@"Set-Cookie"]) { 54 | NSArray *cookies=[NSHTTPCookie cookiesWithResponseHeaderFields:[urlResponse allHeaderFields] forURL:[NSURL URLWithString:@".vip.xunlei.com"]]; 55 | for(NSHTTPCookie *t in cookies){ 56 | [self setCookieWithKey:t.name Value:t.value]; 57 | } 58 | } 59 | 60 | if ([urlResponse statusCode] >= 200 && [urlResponse statusCode] < 400) 61 | return responseResult; 62 | else 63 | return nil; 64 | } 65 | 66 | -(void) setPostValue:(NSString*) value forKey:(NSString*) key{ 67 | // Remove any existing value 68 | NSUInteger i; 69 | for (i=0; i<[[self postData] count]; i++) { 70 | NSDictionary *val = [[self postData] objectAtIndex:i]; 71 | if ([[val objectForKey:@"key"] isEqualToString:key]) { 72 | [[self postData] removeObjectAtIndex:i]; 73 | i--; 74 | } 75 | } 76 | if (!key) { 77 | return; 78 | } 79 | if (![self postData]) { 80 | 81 | // 在ios真机测试的时候。不用这种模式初始化array会导致数据append失败。 82 | postData = [[NSMutableArray alloc] initWithCapacity:0]; 83 | } 84 | NSMutableDictionary *keyValuePair = [NSMutableDictionary dictionaryWithCapacity:2]; 85 | [keyValuePair setValue:key forKey:@"key"]; 86 | [keyValuePair setValue:[value description] forKey:@"value"]; 87 | [[self postData] addObject:keyValuePair]; 88 | } 89 | 90 | 91 | //发送POST请求 92 | - (NSString*)postBTFile:(NSString*)filePath { 93 | 94 | NSString *fileName = [[filePath componentsSeparatedByString:@"/"] lastObject]; 95 | 96 | NSData *torrentData = [NSData dataWithContentsOfFile:filePath]; 97 | 98 | NSMutableURLRequest *_urlRequest = [[NSMutableURLRequest alloc] init]; 99 | 100 | [_urlRequest setURL:[NSURL URLWithString:@"http://dynamic.cloud.vip.xunlei.com/interface/torrent_upload"]]; 101 | [_urlRequest addValue:@"User-Agent:Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/535.2 (KHTML, like Gecko) Chrome/15.0.874.106 Safari/535.2" forHTTPHeaderField:@"User-Agent"]; 102 | [_urlRequest addValue:@"http://lixian.vip.xunlei.com/" forHTTPHeaderField:@"Referer"]; 103 | [_urlRequest setHTTPMethod:@"POST"]; 104 | NSString *boundary = [[[[[NSProcessInfo processInfo] globallyUniqueString] componentsSeparatedByString:@"-"] componentsJoinedByString:@""] lowercaseString]; 105 | NSString *boundaryString = [NSString stringWithFormat:@"multipart/form-data; boundary=%@", boundary]; 106 | [_urlRequest addValue:boundaryString forHTTPHeaderField:@"Content-Type"]; 107 | 108 | // define boundary separator... 109 | NSString *boundarySeparator = [NSString stringWithFormat:@"--%@\r\n", boundary]; 110 | //adding the body... 111 | NSMutableData *postBody = [NSMutableData data]; 112 | 113 | // Adds post data 114 | NSString *endItemBoundary = [NSString stringWithFormat:@"\r\n--%@\r\n",boundary]; 115 | NSString *finalItemBoundary = [NSString stringWithFormat:@"\r\n--%@--\r\n",boundary]; 116 | 117 | // header 118 | [postBody appendData:[boundarySeparator dataUsingEncoding:NSUTF8StringEncoding]]; 119 | [postBody appendData:[(NSString*)[NSString stringWithFormat:@"Content-Disposition: form-data; name=\"filepath\";\r\nfilename=\"%@\"\r\nContent-Type: application/x-bittorrent\r\n\r\n", fileName] dataUsingEncoding:NSUTF8StringEncoding]]; 120 | 121 | // torrent data 122 | [postBody appendData:torrentData]; 123 | [postBody appendData:[endItemBoundary dataUsingEncoding:NSUTF8StringEncoding]]; 124 | 125 | // timestamp???? 126 | [postBody appendData:[@"Content-Disposition: form-data; name=\"random\"\r\n\r\n" dataUsingEncoding:NSUTF8StringEncoding]]; 127 | [postBody appendData:[[self _currentTimeString] dataUsingEncoding:NSUTF8StringEncoding]]; 128 | [postBody appendData:[endItemBoundary dataUsingEncoding:NSUTF8StringEncoding]]; 129 | 130 | // tasksign??? 131 | [postBody appendData:[@"Content-Disposition: form-data; name=\"interfrom\"\r\n\r\ntask" dataUsingEncoding:NSUTF8StringEncoding]]; 132 | [postBody appendData:[finalItemBoundary dataUsingEncoding:NSUTF8StringEncoding]]; 133 | 134 | 135 | NSHTTPCookieStorage *cookieJar = [NSHTTPCookieStorage sharedHTTPCookieStorage]; 136 | NSMutableString *cookie_str = [[NSMutableString alloc] init]; 137 | for(NSHTTPCookie *cookie in [cookieJar cookies]){ 138 | if([cookie.domain hasSuffix:@".xunlei.com"]){ 139 | [cookie_str setString:[cookie_str stringByAppendingFormat:@"%@=%@; ", cookie.name, cookie.value]]; 140 | } 141 | } 142 | [_urlRequest setValue:cookie_str forHTTPHeaderField:@"Cookie"]; 143 | 144 | [_urlRequest setHTTPBody:postBody]; 145 | 146 | NSHTTPURLResponse* urlResponse = nil; 147 | NSData *responseData = [NSURLConnection sendSynchronousRequest:_urlRequest returningResponse:&urlResponse error:NULL]; 148 | NSString *responseResult = [[NSString alloc] initWithData:responseData encoding:NSUTF8StringEncoding]; 149 | if ([[urlResponse allHeaderFields] objectForKey:@"Set-Cookie"]) { 150 | NSArray *cookies=[NSHTTPCookie cookiesWithResponseHeaderFields:[urlResponse allHeaderFields] forURL:[NSURL URLWithString:@".vip.xunlei.com"]]; 151 | for(NSHTTPCookie *t in cookies){ 152 | [self setCookieWithKey:t.name Value:t.value]; 153 | } 154 | } 155 | if ([urlResponse statusCode] >= 200 && [urlResponse statusCode] < 400) 156 | return responseResult; 157 | else 158 | return nil; 159 | } 160 | 161 | 162 | //取得当前UTC时间,并转换成13位数字字符 163 | -(NSString *) _currentTimeString{ 164 | double UTCTime=[[NSDate date] timeIntervalSince1970]; 165 | NSString *currentTime=[NSString stringWithFormat:@"%f",UTCTime*1000]; 166 | NSLog(@"%@",currentTime); 167 | currentTime=[[currentTime componentsSeparatedByString:@"."] objectAtIndex:0]; 168 | 169 | return currentTime; 170 | } 171 | 172 | //发送POST请求 173 | - (NSString*)post:(NSString*)urlString withBody:(NSString *)bodyData{ 174 | 175 | NSMutableURLRequest *_urlRequest = [[NSMutableURLRequest alloc] init]; 176 | 177 | [_urlRequest setURL:[NSURL URLWithString:urlString]]; 178 | [_urlRequest setHTTPMethod:@"POST"]; 179 | [_urlRequest addValue:@"text/xml" forHTTPHeaderField: @"Content-Type"]; 180 | NSString *boundary = [[NSProcessInfo processInfo] globallyUniqueString]; 181 | NSString *boundaryString = [NSString stringWithFormat:@"multipart/form-data; boundary=%@", boundary]; 182 | [_urlRequest addValue:boundaryString forHTTPHeaderField:@"Content-Type"]; 183 | 184 | // define boundary separator... 185 | NSString *boundarySeparator = [NSString stringWithFormat:@"--%@\r\n", boundary]; 186 | //adding the body... 187 | NSMutableData *postBody = [NSMutableData data]; 188 | 189 | [postBody appendData:[boundarySeparator dataUsingEncoding:NSUTF8StringEncoding]]; 190 | // Adds post data 191 | NSString *endItemBoundary = [NSString stringWithFormat:@"\r\n--%@\r\n",boundary]; 192 | NSUInteger i=0; 193 | for (NSDictionary *val in [self postData]) { 194 | [postBody appendData:[(NSString*)[NSString stringWithFormat:@"Content-Disposition: form-data; name=\"%@\"\r\n\r\n",[val objectForKey:@"key"]] dataUsingEncoding:NSUTF8StringEncoding]]; 195 | [postBody appendData:[[val objectForKey:@"value"] dataUsingEncoding:NSUTF8StringEncoding]]; 196 | i++; 197 | if (i != [[self postData] count]) { //Only add the boundary if this is not the last item in the post body 198 | [postBody appendData:[endItemBoundary dataUsingEncoding:NSUTF8StringEncoding]]; 199 | } 200 | } 201 | [_urlRequest setHTTPBody:postBody]; 202 | 203 | NSHTTPCookieStorage *cookieJar = [NSHTTPCookieStorage sharedHTTPCookieStorage]; 204 | NSMutableString *cookie_str = [[NSMutableString alloc] init]; 205 | for(NSHTTPCookie *cookie in [cookieJar cookies]){ 206 | if([cookie.domain hasSuffix:@".xunlei.com"]){ 207 | [cookie_str setString:[cookie_str stringByAppendingFormat:@"%@=%@; ", cookie.name, cookie.value]]; 208 | } 209 | } 210 | [_urlRequest setValue:cookie_str forHTTPHeaderField:@"Cookie"]; 211 | 212 | NSHTTPURLResponse* urlResponse = nil; 213 | NSData *responseData = [NSURLConnection sendSynchronousRequest:_urlRequest returningResponse:&urlResponse error:NULL]; 214 | NSString *responseResult = [[NSString alloc] initWithData:responseData encoding:NSUTF8StringEncoding]; 215 | if ([[urlResponse allHeaderFields] objectForKey:@"Set-Cookie"]) { 216 | NSArray *cookies=[NSHTTPCookie cookiesWithResponseHeaderFields:[urlResponse allHeaderFields] forURL:[NSURL URLWithString:@".vip.xunlei.com"]]; 217 | for(NSHTTPCookie *t in cookies){ 218 | [self setCookieWithKey:t.name Value:t.value]; 219 | } 220 | } 221 | if ([urlResponse statusCode] >= 200 && [urlResponse statusCode] < 400) 222 | return responseResult; 223 | else 224 | return nil; 225 | } 226 | 227 | -(NSString*) post:(NSString*) urlString{ 228 | NSMutableURLRequest *_urlRequest = [[NSMutableURLRequest alloc] init]; 229 | 230 | [_urlRequest setURL:[NSURL URLWithString:urlString]]; 231 | [_urlRequest setHTTPMethod:@"POST"]; 232 | [_urlRequest addValue:@"application/x-www-form-urlencoded;charset=utf-8" forHTTPHeaderField: @"Content-Type"]; 233 | NSMutableString *postValueStr=[NSMutableString new]; 234 | for(NSDictionary *kv in [self postData]){ 235 | [postValueStr setString:[postValueStr stringByAppendingFormat:@"%@=%@&",[kv objectForKey:@"key"],[kv objectForKey:@"value"] ]]; 236 | } 237 | NSLog(@"hahah:%@",postValueStr); 238 | [_urlRequest setHTTPBody:[postValueStr dataUsingEncoding:NSUTF8StringEncoding]]; 239 | NSHTTPCookieStorage *cookieJar = [NSHTTPCookieStorage sharedHTTPCookieStorage]; 240 | NSMutableString *cookie_str = [[NSMutableString alloc] init]; 241 | for(NSHTTPCookie *cookie in [cookieJar cookies]){ 242 | if([cookie.domain hasSuffix:@".xunlei.com"]){ 243 | [cookie_str setString:[cookie_str stringByAppendingFormat:@"%@=%@; ", cookie.name, cookie.value]]; 244 | } 245 | } 246 | [_urlRequest setValue:cookie_str forHTTPHeaderField:@"Cookie"]; 247 | 248 | NSHTTPURLResponse* urlResponse = nil; 249 | NSData *responseData = [NSURLConnection sendSynchronousRequest:_urlRequest returningResponse:&urlResponse error:NULL]; 250 | NSString *responseResult = [[NSString alloc] initWithData:responseData encoding:NSUTF8StringEncoding]; 251 | if ([[urlResponse allHeaderFields] objectForKey:@"Set-Cookie"]) { 252 | NSArray *cookies=[NSHTTPCookie cookiesWithResponseHeaderFields:[urlResponse allHeaderFields] forURL:[NSURL URLWithString:@".vip.xunlei.com"]]; 253 | for(NSHTTPCookie *t in cookies){ 254 | [self setCookieWithKey:t.name Value:t.value]; 255 | } 256 | } 257 | if ([urlResponse statusCode] >= 200 && [urlResponse statusCode] < 400) 258 | return responseResult; 259 | else 260 | return nil; 261 | 262 | } 263 | 264 | 265 | -(NSHTTPCookie *) setCookieWithKey:(NSString *) key Value:(NSString *) value{ 266 | //创建一个cookie 267 | NSMutableDictionary *properties = [NSMutableDictionary dictionary]; 268 | [properties setObject:value forKey:NSHTTPCookieValue]; 269 | [properties setObject:key forKey:NSHTTPCookieName]; 270 | [properties setObject:@".vip.xunlei.com" forKey:NSHTTPCookieDomain]; 271 | [properties setObject:@"/" forKey:NSHTTPCookiePath]; 272 | [properties setObject:[[NSDate date] dateByAddingTimeInterval:2629743] forKey:NSHTTPCookieExpires]; 273 | //这里是关键,不要写成@"FALSE",而是应该直接写成TRUE 或者 FALSE,否则会默认为TRUE 274 | [properties setValue:FALSE forKey:NSHTTPCookieSecure]; 275 | NSHTTPCookie *cookie = [[NSHTTPCookie alloc] initWithProperties:properties]; 276 | NSHTTPCookieStorage *cookieStorage=[NSHTTPCookieStorage sharedHTTPCookieStorage]; 277 | [cookieStorage setCookieAcceptPolicy:NSHTTPCookieAcceptPolicyAlways]; 278 | [cookieStorage setCookie:cookie]; 279 | 280 | //add to responseCookies Array 281 | [[self responseCookies] addObject:cookie]; 282 | return cookie; 283 | } 284 | 285 | @end 286 | -------------------------------------------------------------------------------- /TondarAPI/NSData+Base64.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSData+Base64.h 3 | // 4 | // Version 1.0.2 5 | // 6 | // Created by Nick Lockwood on 12/01/2012. 7 | // Copyright (C) 2012 Charcoal Design 8 | // 9 | // Distributed under the permissive zlib License 10 | // Get the latest version from here: 11 | // 12 | // https://github.com/nicklockwood/Base64 13 | // 14 | // This software is provided 'as-is', without any express or implied 15 | // warranty. In no event will the authors be held liable for any damages 16 | // arising from the use of this software. 17 | // 18 | // Permission is granted to anyone to use this software for any purpose, 19 | // including commercial applications, and to alter it and redistribute it 20 | // freely, subject to the following restrictions: 21 | // 22 | // 1. The origin of this software must not be misrepresented; you must not 23 | // claim that you wrote the original software. If you use this software 24 | // in a product, an acknowledgment in the product documentation would be 25 | // appreciated but is not required. 26 | // 27 | // 2. Altered source versions must be plainly marked as such, and must not be 28 | // misrepresented as being the original software. 29 | // 30 | // 3. This notice may not be removed or altered from any source distribution. 31 | // 32 | 33 | #import 34 | 35 | @interface NSData (Base64) 36 | 37 | + (NSData *)dataWithBase64EncodedString:(NSString *)string; 38 | - (NSString *)base64EncodedStringWithWrapWidth:(NSUInteger)wrapWidth; 39 | - (NSString *)base64EncodedString; 40 | 41 | @end -------------------------------------------------------------------------------- /TondarAPI/NSData+Base64.m: -------------------------------------------------------------------------------- 1 | // 2 | // NSData+Base64.m 3 | // 4 | // Version 1.0.2 5 | // 6 | // Created by Nick Lockwood on 12/01/2012. 7 | // Copyright (C) 2012 Charcoal Design 8 | // 9 | // Distributed under the permissive zlib License 10 | // Get the latest version from here: 11 | // 12 | // https://github.com/nicklockwood/Base64 13 | // 14 | // This software is provided 'as-is', without any express or implied 15 | // warranty. In no event will the authors be held liable for any damages 16 | // arising from the use of this software. 17 | // 18 | // Permission is granted to anyone to use this software for any purpose, 19 | // including commercial applications, and to alter it and redistribute it 20 | // freely, subject to the following restrictions: 21 | // 22 | // 1. The origin of this software must not be misrepresented; you must not 23 | // claim that you wrote the original software. If you use this software 24 | // in a product, an acknowledgment in the product documentation would be 25 | // appreciated but is not required. 26 | // 27 | // 2. Altered source versions must be plainly marked as such, and must not be 28 | // misrepresented as being the original software. 29 | // 30 | // 3. This notice may not be removed or altered from any source distribution. 31 | // 32 | 33 | #import "NSData+Base64.h" 34 | 35 | @implementation NSData (Base64) 36 | 37 | + (NSData *)dataWithBase64EncodedString:(NSString *)string 38 | { 39 | const char lookup[] = 40 | { 41 | 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 42 | 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 43 | 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 62, 99, 99, 99, 63, 44 | 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 99, 99, 99, 99, 99, 99, 45 | 99, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 46 | 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 99, 99, 99, 99, 99, 47 | 99, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 48 | 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 99, 99, 99, 99, 99 49 | }; 50 | 51 | NSData *inputData = [string dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES]; 52 | long long inputLength = [inputData length]; 53 | const unsigned char *inputBytes = [inputData bytes]; 54 | 55 | long long maxOutputLength = (inputLength / 4 + 1) * 3; 56 | NSMutableData *outputData = [NSMutableData dataWithLength:maxOutputLength]; 57 | unsigned char *outputBytes = (unsigned char *)[outputData mutableBytes]; 58 | 59 | int accumulator = 0; 60 | long long outputLength = 0; 61 | unsigned char accumulated[] = {0, 0, 0, 0}; 62 | for (long long i = 0; i < inputLength; i++) 63 | { 64 | unsigned char decoded = lookup[inputBytes[i] & 0x7F]; 65 | if (decoded != 99) 66 | { 67 | accumulated[accumulator] = decoded; 68 | if (accumulator == 3) 69 | { 70 | outputBytes[outputLength++] = (accumulated[0] << 2) | (accumulated[1] >> 4); 71 | outputBytes[outputLength++] = (accumulated[1] << 4) | (accumulated[2] >> 2); 72 | outputBytes[outputLength++] = (accumulated[2] << 6) | accumulated[3]; 73 | } 74 | accumulator = (accumulator + 1) % 4; 75 | } 76 | } 77 | 78 | //handle left-over data 79 | if (accumulator > 0) outputBytes[outputLength] = (accumulated[0] << 2) | (accumulated[1] >> 4); 80 | if (accumulator > 1) outputBytes[++outputLength] = (accumulated[1] << 4) | (accumulated[2] >> 2); 81 | if (accumulator > 2) outputLength++; 82 | 83 | //truncate data to match actual output length 84 | outputData.length = outputLength; 85 | return outputLength? outputData: nil; 86 | } 87 | 88 | - (NSString *)base64EncodedStringWithWrapWidth:(NSUInteger)wrapWidth 89 | { 90 | //ensure wrapWidth is a multiple of 4 91 | wrapWidth = (wrapWidth / 4) * 4; 92 | 93 | const char lookup[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; 94 | 95 | long long inputLength = [self length]; 96 | const unsigned char *inputBytes = [self bytes]; 97 | 98 | long long maxOutputLength = (inputLength / 3 + 1) * 4; 99 | maxOutputLength += wrapWidth? (maxOutputLength / wrapWidth) * 2: 0; 100 | unsigned char *outputBytes = (unsigned char *)malloc(maxOutputLength); 101 | 102 | long long i; 103 | long long outputLength = 0; 104 | for (i = 0; i < inputLength - 2; i += 3) 105 | { 106 | outputBytes[outputLength++] = lookup[(inputBytes[i] & 0xFC) >> 2]; 107 | outputBytes[outputLength++] = lookup[((inputBytes[i] & 0x03) << 4) | ((inputBytes[i + 1] & 0xF0) >> 4)]; 108 | outputBytes[outputLength++] = lookup[((inputBytes[i + 1] & 0x0F) << 2) | ((inputBytes[i + 2] & 0xC0) >> 6)]; 109 | outputBytes[outputLength++] = lookup[inputBytes[i + 2] & 0x3F]; 110 | 111 | //add line break 112 | if (wrapWidth && (outputLength + 2) % (wrapWidth + 2) == 0) 113 | { 114 | outputBytes[outputLength++] = '\r'; 115 | outputBytes[outputLength++] = '\n'; 116 | } 117 | } 118 | 119 | //handle left-over data 120 | if (i == inputLength - 2) 121 | { 122 | // = terminator 123 | outputBytes[outputLength++] = lookup[(inputBytes[i] & 0xFC) >> 2]; 124 | outputBytes[outputLength++] = lookup[((inputBytes[i] & 0x03) << 4) | ((inputBytes[i + 1] & 0xF0) >> 4)]; 125 | outputBytes[outputLength++] = lookup[(inputBytes[i + 1] & 0x0F) << 2]; 126 | outputBytes[outputLength++] = '='; 127 | } 128 | else if (i == inputLength - 1) 129 | { 130 | // == terminator 131 | outputBytes[outputLength++] = lookup[(inputBytes[i] & 0xFC) >> 2]; 132 | outputBytes[outputLength++] = lookup[(inputBytes[i] & 0x03) << 4]; 133 | outputBytes[outputLength++] = '='; 134 | outputBytes[outputLength++] = '='; 135 | } 136 | 137 | //truncate data to match actual output length 138 | outputBytes = realloc(outputBytes, outputLength); 139 | NSString *result = [[NSString alloc] initWithBytesNoCopy:outputBytes length:outputLength encoding:NSASCIIStringEncoding freeWhenDone:YES]; 140 | 141 | #if !__has_feature(objc_arc) 142 | [result autorelease]; 143 | #endif 144 | 145 | return (outputLength >= 4)? result: nil; 146 | } 147 | 148 | - (NSString *)base64EncodedString 149 | { 150 | return [self base64EncodedStringWithWrapWidth:0]; 151 | } 152 | 153 | @end 154 | -------------------------------------------------------------------------------- /TondarAPI/NSString+Base64.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSString+Base64.h 3 | // 4 | // Version 1.0.2 5 | // 6 | // Created by Nick Lockwood on 12/01/2012. 7 | // Copyright (C) 2012 Charcoal Design 8 | // 9 | // Distributed under the permissive zlib License 10 | // Get the latest version from here: 11 | // 12 | // https://github.com/nicklockwood/Base64 13 | // 14 | // This software is provided 'as-is', without any express or implied 15 | // warranty. In no event will the authors be held liable for any damages 16 | // arising from the use of this software. 17 | // 18 | // Permission is granted to anyone to use this software for any purpose, 19 | // including commercial applications, and to alter it and redistribute it 20 | // freely, subject to the following restrictions: 21 | // 22 | // 1. The origin of this software must not be misrepresented; you must not 23 | // claim that you wrote the original software. If you use this software 24 | // in a product, an acknowledgment in the product documentation would be 25 | // appreciated but is not required. 26 | // 27 | // 2. Altered source versions must be plainly marked as such, and must not be 28 | // misrepresented as being the original software. 29 | // 30 | // 3. This notice may not be removed or altered from any source distribution. 31 | // 32 | 33 | #import 34 | 35 | @interface NSString (Base64) 36 | 37 | + (NSString *)stringWithBase64EncodedString:(NSString *)string; 38 | - (NSString *)base64EncodedStringWithWrapWidth:(NSUInteger)wrapWidth; 39 | - (NSString *)base64EncodedString; 40 | - (NSString *)base64DecodedString; 41 | - (NSData *)base64DecodedData; 42 | 43 | @end -------------------------------------------------------------------------------- /TondarAPI/NSString+Base64.m: -------------------------------------------------------------------------------- 1 | // 2 | // NSString+Base64.m 3 | // 4 | // Version 1.0.2 5 | // 6 | // Created by Nick Lockwood on 12/01/2012. 7 | // Copyright (C) 2012 Charcoal Design 8 | // 9 | // Distributed under the permissive zlib License 10 | // Get the latest version from here: 11 | // 12 | // https://github.com/nicklockwood/Base64 13 | // 14 | // This software is provided 'as-is', without any express or implied 15 | // warranty. In no event will the authors be held liable for any damages 16 | // arising from the use of this software. 17 | // 18 | // Permission is granted to anyone to use this software for any purpose, 19 | // including commercial applications, and to alter it and redistribute it 20 | // freely, subject to the following restrictions: 21 | // 22 | // 1. The origin of this software must not be misrepresented; you must not 23 | // claim that you wrote the original software. If you use this software 24 | // in a product, an acknowledgment in the product documentation would be 25 | // appreciated but is not required. 26 | // 27 | // 2. Altered source versions must be plainly marked as such, and must not be 28 | // misrepresented as being the original software. 29 | // 30 | // 3. This notice may not be removed or altered from any source distribution. 31 | // 32 | 33 | #import "NSString+Base64.h" 34 | #import "NSData+Base64.h" 35 | 36 | @implementation NSString (Base64) 37 | 38 | + (NSString *)stringWithBase64EncodedString:(NSString *)string 39 | { 40 | NSData *data = [NSData dataWithBase64EncodedString:string]; 41 | if (data) 42 | { 43 | NSString *result = [[self alloc] initWithData:data encoding:NSUTF8StringEncoding]; 44 | 45 | #if !__has_feature(objc_arc) 46 | [result autorelease]; 47 | #endif 48 | 49 | return result; 50 | } 51 | return nil; 52 | } 53 | 54 | - (NSString *)base64EncodedStringWithWrapWidth:(NSUInteger)wrapWidth 55 | { 56 | NSData *data = [self dataUsingEncoding:NSUTF8StringEncoding allowLossyConversion:YES]; 57 | return [data base64EncodedStringWithWrapWidth:wrapWidth]; 58 | } 59 | 60 | - (NSString *)base64EncodedString 61 | { 62 | NSData *data = [self dataUsingEncoding:NSUTF8StringEncoding allowLossyConversion:YES]; 63 | return [data base64EncodedString]; 64 | } 65 | 66 | - (NSString *)base64DecodedString 67 | { 68 | return [NSString stringWithBase64EncodedString:self]; 69 | } 70 | 71 | - (NSData *)base64DecodedData 72 | { 73 | return [NSData dataWithBase64EncodedString:self]; 74 | } 75 | 76 | @end -------------------------------------------------------------------------------- /TondarAPI/NSString+RE.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSString+RE.h 3 | // TondarAPI 4 | // 5 | // Created by liuchao on 10/8/12. 6 | // 7 | // 8 | 9 | #import 10 | 11 | @interface NSString (RE) 12 | -(NSArray*) arrayOfCaptureComponentsMatchedByRegex:(NSString*) regex; 13 | - (NSArray *) captureComponentsMatchedByRegex:(NSString *)regex capture:(NSInteger)capture; 14 | - (NSArray *) captureComponentsMatchedByRegex:(NSString *)regex; 15 | - (NSString *) stringByMatching:(NSString *)regex capture:(NSInteger)capture; 16 | 17 | @end 18 | -------------------------------------------------------------------------------- /TondarAPI/NSString+RE.m: -------------------------------------------------------------------------------- 1 | // 2 | // NSString+RE.m 3 | // TondarAPI 4 | // 5 | // Created by liuchao on 10/8/12. 6 | // 7 | // 8 | 9 | #import "NSString+RE.h" 10 | 11 | @implementation NSString (RE) 12 | 13 | -(NSArray*) arrayOfCaptureComponentsMatchedByRegex:(NSString*) regex{ 14 | NSMutableArray *result=[NSMutableArray arrayWithCapacity:0]; 15 | // NSString *htmlString = @"A long string containing Name:A name here amongst other things"; 16 | NSRegularExpression *nameExpression = [NSRegularExpression regularExpressionWithPattern:regex options:NSRegularExpressionSearch error:nil]; 17 | 18 | NSArray *matches = [nameExpression matchesInString:self 19 | options:0 20 | range:NSMakeRange(0, [self length])]; 21 | for (NSTextCheckingResult *match in matches) { 22 | NSMutableArray *subResult=[NSMutableArray arrayWithCapacity:0]; 23 | for(int i=0;i<[match numberOfRanges];i++){ 24 | NSRange matchRange = [match rangeAtIndex:i]; 25 | NSString *matchString = [self substringWithRange:matchRange]; 26 | [subResult addObject:matchString]; 27 | } 28 | // NSLog(@"%@", subResult); 29 | [result addObject:subResult]; 30 | } 31 | return result; 32 | } 33 | - (NSArray *) captureComponentsMatchedByRegex:(NSString *)regex{ 34 | return [self captureComponentsMatchedByRegex:regex capture:0]; 35 | } 36 | - (NSArray *) captureComponentsMatchedByRegex:(NSString *)regex capture:(NSInteger) capture{ 37 | NSMutableArray *result=[NSMutableArray arrayWithCapacity:0]; 38 | // NSString *htmlString = @"A long string containing Name:A name here amongst other things"; 39 | NSRegularExpression *nameExpression = [NSRegularExpression regularExpressionWithPattern:regex options:NSRegularExpressionSearch error:nil]; 40 | 41 | NSArray *matches = [nameExpression matchesInString:self 42 | options:0 43 | range:NSMakeRange(0, [self length])]; 44 | for (NSTextCheckingResult *match in matches) { 45 | NSRange matchRange = [match rangeAtIndex:capture]; 46 | NSString *matchString = [self substringWithRange:matchRange]; 47 | // NSLog(@"%@", matchString); 48 | [result addObject:matchString]; 49 | } 50 | return result; 51 | 52 | } 53 | - (NSString *) stringByMatching:(NSString *)regex capture:(NSInteger)capture{ 54 | NSString *result=nil; 55 | // NSString *htmlString = @"A long string containing Name:A name here amongst other things"; 56 | NSRegularExpression *nameExpression = [NSRegularExpression regularExpressionWithPattern:regex options:NSRegularExpressionSearch error:nil]; 57 | 58 | NSArray *matches = [nameExpression matchesInString:self 59 | options:0 60 | range:NSMakeRange(0, [self length])]; 61 | for (NSTextCheckingResult *match in matches) { 62 | NSRange matchRange = [match rangeAtIndex:capture]; 63 | NSString *matchString = @""; 64 | @try { 65 | matchString=[self substringWithRange:matchRange]; 66 | } 67 | @catch (NSException *exception) { 68 | // NSLog(@"found exception!!"); 69 | result=nil; 70 | } 71 | @finally { 72 | } 73 | // NSLog(@"%@", matchString); 74 | result=matchString; 75 | break; 76 | } 77 | return result; 78 | } 79 | @end 80 | -------------------------------------------------------------------------------- /TondarAPI/ParseElements.h: -------------------------------------------------------------------------------- 1 | // 2 | // PhraseElements.h 3 | // XunleiLixian-API 4 | // 5 | // Created by Liu Chao on 6/10/12. 6 | // Copyright (c) 2012 HwaYing. All rights reserved. 7 | // 8 | /*This file is part of XunleiLixian-API. 9 | 10 | XunleiLixian-API is free software: you can redistribute it and/or modify 11 | it under the terms of the GNU General Public License as published by 12 | the Free Software Foundation, either version 3 of the License, or 13 | (at your option) any later version. 14 | 15 | Foobar is distributed in the hope that it will be useful, 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | GNU General Public License for more details. 19 | 20 | You should have received a copy of the GNU General Public License 21 | along with Foobar. If not, see . 22 | */ 23 | 24 | /* 25 | 这个文件中的方法几乎不需要手动调用 26 | 正常的情况下你不需要使用任何其中的方法 27 | */ 28 | 29 | #import 30 | 31 | @interface ParseElements : NSObject 32 | 33 | +(NSArray *) taskPageData:(NSString *)orignData; 34 | 35 | +(NSString *) taskName:(NSString *)taskContent; 36 | +(NSString *) taskSize:(NSString *)taskContent; 37 | +(NSString *) taskLoadProcess:(NSString *)taskContent; 38 | +(NSString *) taskRetainDays:(NSString *)taskContent; 39 | +(NSString *) taskAddTime:(NSString *)taskContent; 40 | +(NSString *) taskDownlaodNormalURL:(NSString *)taskContent; 41 | +(NSString *) GDriveID:(NSString *) orignData; 42 | +(NSString *) taskType:(NSString *)taskContent; 43 | +(NSString *) DCID:(NSString *)taskContent; 44 | +(NSString *) GCID:(NSString *)taskDownLoadURL; 45 | +(NSMutableDictionary *)taskInfo:(NSString *)taskContent; 46 | +(NSString*) nextPageSubURL:(NSString *) currentPageData; 47 | @end 48 | -------------------------------------------------------------------------------- /TondarAPI/ParseElements.m: -------------------------------------------------------------------------------- 1 | // 2 | // PhraseElements.m 3 | // XunleiLixian-API 4 | // 5 | // Created by Liu Chao on 6/10/12. 6 | // Copyright (c) 2012 HwaYing. All rights reserved. 7 | // 8 | /*This file is part of XunleiLixian-API. 9 | 10 | XunleiLixian-API is free software: you can redistribute it and/or modify 11 | it under the terms of the GNU General Public License as published by 12 | the Free Software Foundation, either version 3 of the License, or 13 | (at your option) any later version. 14 | 15 | Foobar is distributed in the hope that it will be useful, 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | GNU General Public License for more details. 19 | 20 | You should have received a copy of the GNU General Public License 21 | along with Foobar. If not, see . 22 | */ 23 | 24 | 25 | #import "ParseElements.h" 26 | #import "NSString+RE.h" 27 | 28 | @implementation ParseElements 29 | 30 | +(NSArray *) taskPageData:(NSString *)orignData{ 31 | //获得已经完成和已经过期Task列表汇总信息 32 | NSString *listBoxRex=@"]*>([\\s\\S]+?]+?>)"; 33 | NSString *outofDateListBoxRex=@"]*>([\\s\\S]+?)]+?>"; 34 | 35 | NSArray *completeTaskArray=[orignData arrayOfCaptureComponentsMatchedByRegex:listBoxRex]; 36 | NSArray *outOfDateTaskArray=[orignData arrayOfCaptureComponentsMatchedByRegex:outofDateListBoxRex]; 37 | NSMutableArray *allTaskArray=[NSMutableArray arrayWithArray:completeTaskArray]; 38 | [allTaskArray addObjectsFromArray:outOfDateTaskArray]; 39 | 40 | return allTaskArray; 41 | } 42 | 43 | +(NSString *) taskName:(NSString *)taskContent{ 44 | NSString *re=@"]*taskid=[\"']?\\d+[\"']?[^>]*title=[\"']?([^\"]*)[\"']?.*?"; 45 | NSString *result=[taskContent stringByMatching:re capture:1]; 46 | if(result){ 47 | return result; 48 | }else { 49 | return @"未知信息"; 50 | } 51 | } 52 | +(NSString *) taskSize:(NSString *)taskContent{ 53 | NSString *re=@"]*?>([^<]+)"; 54 | NSString *result=[taskContent stringByMatching:re capture:1]; 55 | if(result){ 56 | return result; 57 | }else { 58 | return @"未知信息"; 59 | } 60 | } 61 | //读取下载进度 62 | +(NSString *) taskLoadProcess:(NSString *)taskContent{ 63 | NSString *re=@"([^<]+)"; 64 | NSString *result=[taskContent stringByMatching:re capture:1]; 65 | if(result.length>1){ 66 | return (result); 67 | }else { 68 | return (@"已经过期或已经删除"); 69 | } 70 | } 71 | //提取保留时间 72 | +(NSString *) taskRetainDays:(NSString *)taskContent{ 73 | NSString *re=@"\\s*]*>([^<]+)"; 74 | NSString *result=[taskContent stringByMatching:re capture:1]; 75 | if(result){ 76 | return result; 77 | }else { 78 | return @"未知信息"; 79 | } 80 | } 81 | //任务添加时间 82 | +(NSString *) taskAddTime:(NSString *)taskContent{ 83 | NSString *re=@"([^<]+)"; 84 | NSString *result=[taskContent stringByMatching:re capture:1]; 85 | if(result){ 86 | return result; 87 | }else { 88 | return @"未知信息"; 89 | }} 90 | //链接地址 91 | +(NSString *) taskDownlaodNormalURL:(NSString *)taskContent{ 92 | //NSString *re=@"]+)[\"']?>"; 93 | NSString *re=@"]*)\""; 94 | NSString *result=[taskContent stringByMatching:re capture:1]; 95 | if(result){ 96 | return result; 97 | }else { 98 | return @"未知信息"; 99 | } 100 | } 101 | 102 | //获取GdriveID 103 | +(NSString *) GDriveID:(NSString *) taskHTMLOrignData{ 104 | NSString *gdriveidRex=@"id=\"cok\"\\svalue=\"([^\"]+)\""; 105 | NSString *gdriveID=[taskHTMLOrignData stringByMatching:gdriveidRex capture:1]; 106 | NSLog(@"GDRIVEID:%@",gdriveID); 107 | return gdriveID; 108 | } 109 | 110 | //获取DCID(也是BT HASHID) 111 | +(NSString *) DCID:(NSString *)taskContent{ 112 | NSString *re=@""; 113 | NSString *result=[taskContent stringByMatching:re capture:1]; 114 | if(result){ 115 | return result; 116 | }else { 117 | return @"未知信息"; 118 | } 119 | } 120 | 121 | 122 | //文件类型(BT/MOVIE/PDF/...) 123 | +(NSString *) taskType:(NSString *)taskContent{ 124 | NSString *re=@""; 125 | NSString *result=[taskContent stringByMatching:re capture:1]; 126 | if(result){ 127 | //如果result结果是other就代表bt文件 128 | return result; 129 | }else { 130 | return @"未知类型"; 131 | } 132 | } 133 | 134 | +(NSMutableDictionary *)taskInfo:(NSString *)taskContent{ 135 | NSMutableDictionary *dic=[NSMutableDictionary dictionaryWithCapacity:0]; 136 | NSString *re0=@"]*)['\"]?"; 137 | NSArray *data=[taskContent arrayOfCaptureComponentsMatchedByRegex:re0]; 138 | NSArray *data1=[data objectAtIndex:0]; 139 | [dic setObject:[data1 objectAtIndex:2] forKey:@"id"]; 140 | for(NSArray *d in data){ 141 | NSString *tmp; 142 | if(![d objectAtIndex:3]){ 143 | tmp=@""; 144 | }else { 145 | tmp=[d objectAtIndex:3]; 146 | } 147 | [dic setObject:tmp forKey:[d objectAtIndex:1]]; 148 | } 149 | return dic; 150 | } 151 | 152 | //取得GCID 153 | +(NSString *) GCID:(NSString *)taskDownLoadURL{ 154 | NSString *rex=@"&g=([^&]*)&"; 155 | NSString *r=[taskDownLoadURL stringByMatching:rex capture:1]; 156 | return r; 157 | } 158 | 159 | //获得下一页部分URL 160 | /* 161 | href="/user_task?userid=642109&st=4&p=2&stype=0" 162 | */ 163 | +(NSString*) nextPageSubURL:(NSString *) currentPageData{ 164 | NSString *rex=@"[^<>]*"; 165 | NSString *r=[currentPageData stringByMatching:rex capture:1]; 166 | return r; 167 | } 168 | @end 169 | -------------------------------------------------------------------------------- /TondarAPI/TondarAPI-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | English 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIconFile 10 | 11 | CFBundleIdentifier 12 | com.res0w.${PRODUCT_NAME:rfc1034identifier} 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | ${PRODUCT_NAME} 17 | CFBundlePackageType 18 | FMWK 19 | CFBundleShortVersionString 20 | 1.0 21 | CFBundleSignature 22 | ???? 23 | CFBundleVersion 24 | 1 25 | NSHumanReadableCopyright 26 | Copyright © 2012年 LiuChao. All rights reserved. 27 | NSPrincipalClass 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /TondarAPI/TondarAPI-Prefix.pch: -------------------------------------------------------------------------------- 1 | // 2 | // Prefix header for all source files of the 'TondarAPI' target in the 'TondarAPI' project 3 | // 4 | 5 | #ifdef __OBJC__ 6 | #import 7 | #endif 8 | 9 | 10 | 11 | 12 | #ifndef __OPTIMIZE__ 13 | # define NSLog(s, ...) NSLog( @"<%s : (%d)> %@",__FUNCTION__, __LINE__, [NSString stringWithFormat:(s), ##__VA_ARGS__] ) 14 | #else 15 | # define NSLog(...) {} //Disable NSLog 16 | #endif 17 | -------------------------------------------------------------------------------- /TondarAPI/URlEncode.h: -------------------------------------------------------------------------------- 1 | // 2 | // URlEncode.h 3 | // XunleiLixian-API 4 | // 5 | // Created by Liu Chao on 6/10/12. 6 | // Copyright (c) 2012 HwaYing. All rights reserved. 7 | // 8 | /*This file is part of XunleiLixian-API. 9 | 10 | XunleiLixian-API is free software: you can redistribute it and/or modify 11 | it under the terms of the GNU General Public License as published by 12 | the Free Software Foundation, either version 3 of the License, or 13 | (at your option) any later version. 14 | 15 | Foobar is distributed in the hope that it will be useful, 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | GNU General Public License for more details. 19 | 20 | You should have received a copy of the GNU General Public License 21 | along with Foobar. If not, see . 22 | */ 23 | 24 | 25 | #import 26 | 27 | @interface URlEncode : NSObject 28 | 29 | + (NSString *)encodeToPercentEscapeString: (NSString *) input; 30 | + (NSString *)decodeFromPercentEscapeString: (NSString *) input; 31 | 32 | @end 33 | -------------------------------------------------------------------------------- /TondarAPI/URlEncode.m: -------------------------------------------------------------------------------- 1 | // 2 | // URlEncode.m 3 | // XunleiLixian-API 4 | // 5 | // Created by Liu Chao on 6/10/12. 6 | // Copyright (c) 2012 HwaYing. All rights reserved. 7 | // 8 | /*This file is part of XunleiLixian-API. 9 | 10 | XunleiLixian-API is free software: you can redistribute it and/or modify 11 | it under the terms of the GNU General Public License as published by 12 | the Free Software Foundation, either version 3 of the License, or 13 | (at your option) any later version. 14 | 15 | Foobar is distributed in the hope that it will be useful, 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | GNU General Public License for more details. 19 | 20 | You should have received a copy of the GNU General Public License 21 | along with Foobar. If not, see . 22 | */ 23 | 24 | 25 | #import "URlEncode.h" 26 | 27 | @implementation URlEncode 28 | 29 | + (NSString *)encodeToPercentEscapeString: (NSString *) input 30 | { 31 | // Encode all the reserved characters, per RFC 3986 32 | // () 33 | NSString *outputStr = 34 | CFBridgingRelease(CFURLCreateStringByAddingPercentEscapes(kCFAllocatorDefault, 35 | (__bridge CFStringRef)input, 36 | NULL, 37 | (CFStringRef)@"!*'();:@&=+$,/?%#[]", 38 | kCFStringEncodingUTF8)); 39 | return outputStr; 40 | } 41 | 42 | + (NSString *)decodeFromPercentEscapeString: (NSString *) input 43 | { 44 | NSMutableString *outputStr = [NSMutableString stringWithString:input]; 45 | [outputStr replaceOccurrencesOfString:@"+" 46 | withString:@" " 47 | options:NSLiteralSearch 48 | range:NSMakeRange(0, [outputStr length])]; 49 | 50 | return [outputStr stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding]; 51 | } 52 | 53 | @end 54 | -------------------------------------------------------------------------------- /TondarAPI/XunleiItemInfo.h: -------------------------------------------------------------------------------- 1 | // 2 | // XunleiItemInfo.h 3 | // XunleiLixian-API 4 | // 5 | // Created by Liu Chao on 6/10/12. 6 | // Copyright (c) 2012 HwaYing. All rights reserved. 7 | // 8 | /*This file is part of XunleiLixian-API. 9 | 10 | XunleiLixian-API is free software: you can redistribute it and/or modify 11 | it under the terms of the GNU General Public License as published by 12 | the Free Software Foundation, either version 3 of the License, or 13 | (at your option) any later version. 14 | 15 | Foobar is distributed in the hope that it will be useful, 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | GNU General Public License for more details. 19 | 20 | You should have received a copy of the GNU General Public License 21 | along with Foobar. If not, see . 22 | */ 23 | 24 | 25 | #import 26 | 27 | typedef enum{ 28 | sWaiting=0, 29 | sDownloadding=1, 30 | sComplete=2, 31 | sFail=3, 32 | sPending=4 33 | }TaskStatus; 34 | 35 | 36 | @interface XunleiItemInfo : NSObject 37 | 38 | @property(nonatomic) NSString *taskid; 39 | //任务名称 40 | @property(nonatomic) NSString *name; 41 | //任务大小(以字节为单位) 42 | @property(nonatomic) NSString *size; 43 | //任务大小(易读) 44 | @property(nonatomic) NSString *readableSize; 45 | //下载进度(float) 46 | @property(nonatomic) NSString *downloadPercent; 47 | //剩余保留时间 48 | @property(nonatomic) NSString *retainDays; 49 | //添加时间 50 | @property(nonatomic) NSString *addDate; 51 | //下载地址 52 | @property(nonatomic) NSString *downloadURL; 53 | //原始下载地址 54 | @property(nonatomic) NSString *originalURL; 55 | //BT或者普通任务(0为BT,1为普通任务) 56 | @property(nonatomic) NSString *isBT; 57 | // 58 | @property(nonatomic) NSString *type; 59 | //hash 60 | @property(nonatomic) NSString *dcid; 61 | //下载状态 62 | @property(nonatomic) TaskStatus status; 63 | //是否可以在线播放 64 | @property(nonatomic) NSString *ifvod; 65 | 66 | @end 67 | -------------------------------------------------------------------------------- /TondarAPI/XunleiItemInfo.m: -------------------------------------------------------------------------------- 1 | // 2 | // XunleiItemInfo.m 3 | // XunleiLixian-API 4 | // 5 | // Created by Liu Chao on 6/10/12. 6 | // Copyright (c) 2012 HwaYing. All rights reserved. 7 | // 8 | /*This file is part of XunleiLixian-API. 9 | 10 | XunleiLixian-API is free software: you can redistribute it and/or modify 11 | it under the terms of the GNU General Public License as published by 12 | the Free Software Foundation, either version 3 of the License, or 13 | (at your option) any later version. 14 | 15 | Foobar is distributed in the hope that it will be useful, 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | GNU General Public License for more details. 19 | 20 | You should have received a copy of the GNU General Public License 21 | along with Foobar. If not, see . 22 | */ 23 | 24 | 25 | #import "XunleiItemInfo.h" 26 | 27 | @implementation XunleiItemInfo 28 | 29 | NSString * const TaskStatusArray[]={ 30 | @"waiting",@"downloading",@"complete",@"fail",@"pending" 31 | }; 32 | 33 | - (void)encodeWithCoder:(NSCoder *)aCoder{ 34 | NSString *tmpStatus=[self _statusToString:self.status]; 35 | [aCoder encodeObject:tmpStatus forKey:@"status"]; 36 | [aCoder encodeObject:self.taskid forKey:@"taskid"]; 37 | [aCoder encodeObject:self.name forKey:@"name"]; 38 | [aCoder encodeObject:self.size forKey:@"size"]; 39 | [aCoder encodeObject:self.readableSize forKey:@"readableSize"]; 40 | [aCoder encodeObject:self.downloadPercent forKey:@"loaddingProcess"]; 41 | [aCoder encodeObject:self.retainDays forKey:@"retainDays"]; 42 | [aCoder encodeObject:self.addDate forKey:@"addTime"]; 43 | [aCoder encodeObject:self.downloadURL forKey:@"downloadURL"]; 44 | [aCoder encodeObject:self.type forKey:@"type"]; 45 | [aCoder encodeObject:self.dcid forKey:@"dcid"]; 46 | [aCoder encodeObject:self.originalURL forKey:@"originalurl"]; 47 | [aCoder encodeObject:self.ifvod forKey:@"ifVod"]; 48 | [aCoder encodeObject:self.isBT forKey:@"isBT"]; 49 | 50 | 51 | } 52 | - (id)initWithCoder:(NSCoder *)aDecoder{ 53 | if((self=[self init])){ 54 | TaskStatus tmpStatus=[self _stringToTaskStatus:[aDecoder decodeObjectForKey:@"status"]]; 55 | [self setStatus:tmpStatus]; 56 | [self setTaskid:[aDecoder decodeObjectForKey:@"taskid"]]; 57 | [self setName:[aDecoder decodeObjectForKey:@"name"]]; 58 | [self setSize:[aDecoder decodeObjectForKey:@"size"]]; 59 | [self setDownloadPercent:[aDecoder decodeObjectForKey:@"loaddingProcess"]]; 60 | [self setRetainDays:[aDecoder decodeObjectForKey:@"retainDays"]]; 61 | [self setAddDate:[aDecoder decodeObjectForKey:@"addTime"]]; 62 | [self setDownloadURL:[aDecoder decodeObjectForKey:@"downloadURL"]]; 63 | [self setType:[aDecoder decodeObjectForKey:@"type"]]; 64 | [self setDcid:[aDecoder decodeObjectForKey:@"dcid"]]; 65 | [self setOriginalURL:[aDecoder decodeObjectForKey:@"originalurl"]]; 66 | [self setReadableSize:[aDecoder decodeObjectForKey:@"readableSize"]]; 67 | [self setIfvod:[aDecoder decodeObjectForKey:@"ifVod"]]; 68 | [self setIsBT:[aDecoder decodeObjectForKey:@"isBT"]]; 69 | 70 | } 71 | return self; 72 | } 73 | 74 | -(NSString *) _statusToString:(TaskStatus) status{ 75 | return TaskStatusArray[status]; 76 | } 77 | -(TaskStatus) _stringToTaskStatus:(NSString*) taskStatusString{ 78 | int r; 79 | for(int i=0;i. 22 | */ 23 | 24 | #import 25 | #import 26 | 27 | @interface md5 : NSObject 28 | 29 | +(NSString *) md5HexDigestwithString:(NSString *) aString; 30 | 31 | @end 32 | -------------------------------------------------------------------------------- /TondarAPI/md5.m: -------------------------------------------------------------------------------- 1 | // 2 | // md5.m 3 | // XunleiLixian-API 4 | // 5 | // Created by Liu Chao on 6/10/12. 6 | // Copyright (c) 2012 HwaYing. All rights reserved. 7 | // 8 | /*This file is part of XunleiLixian-API. 9 | 10 | XunleiLixian-API is free software: you can redistribute it and/or modify 11 | it under the terms of the GNU General Public License as published by 12 | the Free Software Foundation, either version 3 of the License, or 13 | (at your option) any later version. 14 | 15 | Foobar is distributed in the hope that it will be useful, 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | GNU General Public License for more details. 19 | 20 | You should have received a copy of the GNU General Public License 21 | along with Foobar. If not, see . 22 | */ 23 | 24 | 25 | #import "md5.h" 26 | 27 | @implementation md5 28 | 29 | static inline char hexChar(unsigned char c) { 30 | return c < 10 ? '0' + c : 'a' + c - 10; 31 | } 32 | 33 | static inline void hexString(unsigned char *from, char *to, NSUInteger length) { 34 | for (NSUInteger i = 0; i < length; ++i) { 35 | unsigned char c = from[i]; 36 | unsigned char cHigh = c >> 4; 37 | unsigned char cLow = c & 0xf; 38 | to[2 * i] = hexChar(cHigh); 39 | to[2 * i + 1] = hexChar(cLow); 40 | } 41 | to[2 * length] = '\0'; 42 | } 43 | +(NSString *) md5HexDigestwithString:(NSString *) aString{ 44 | const char *string=[aString cStringUsingEncoding:NSASCIIStringEncoding]; 45 | static const NSUInteger LENGTH = 16; 46 | unsigned char result[LENGTH]; 47 | CC_MD5(string, (CC_LONG)strlen(string), result); 48 | 49 | char hexResult[2 * LENGTH + 1]; 50 | hexString(result, hexResult, LENGTH); 51 | 52 | return [NSString stringWithUTF8String:hexResult]; 53 | } 54 | 55 | 56 | @end 57 | -------------------------------------------------------------------------------- /TondarAPITests/TondarAPITests-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIdentifier 10 | la.4321.${PRODUCT_NAME:rfc1034identifier} 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundlePackageType 14 | BNDL 15 | CFBundleShortVersionString 16 | 1.0 17 | CFBundleSignature 18 | ???? 19 | CFBundleVersion 20 | 1 21 | 22 | 23 | -------------------------------------------------------------------------------- /TondarAPITests/TondarAPITests.h: -------------------------------------------------------------------------------- 1 | // 2 | // TondarAPITests.h 3 | // TondarAPITests 4 | // 5 | // Created by Martian on 12-7-29. 6 | // Copyright (c) 2012年 MartianZ. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "Kuai.h" 11 | #import "ConvertURL.h" 12 | 13 | @interface TondarAPITests : SenTestCase 14 | 15 | @end 16 | -------------------------------------------------------------------------------- /TondarAPITests/TondarAPITests.m: -------------------------------------------------------------------------------- 1 | // 2 | // TondarAPITests.m 3 | // TondarAPITests 4 | // 5 | // Created by Martian on 12-7-29. 6 | // Copyright (c) 2012年 MartianZ. All rights reserved. 7 | // 8 | 9 | #import "TondarAPITests.h" 10 | #import 11 | #import 12 | 13 | @implementation TondarAPITests 14 | 15 | - (void)setUp 16 | { 17 | [super setUp]; 18 | // Set-up code here. 19 | 20 | } 21 | 22 | - (void)tearDown 23 | { 24 | // Tear-down code here. 25 | [super tearDown]; 26 | } 27 | 28 | - (void)testExample 29 | { 30 | 31 | NSLog(@"TEST START"); 32 | HYXunleiLixianAPI *TondarAPI = [[HYXunleiLixianAPI alloc] init]; 33 | #define USERNAME @"lqik2004" 34 | #define pwd @"pwd" 35 | if ([TondarAPI loginWithUsername:USERNAME Password:pwd]) { 36 | NSLog(@"LOGIN SUCCESS: %@", [TondarAPI userID]); 37 | /* 38 | //获取全部已经完成任务 39 | for (XunleiItemInfo *task in [TondarAPI readAllOutofDateTasks]) { 40 | NSLog(@"%@", task.readableSize); 41 | } 42 | // */ 43 | NSLog(@"Gdriveid:%@", [TondarAPI GDriveID]); 44 | /* 45 | NSString* cookie=[NSString stringWithFormat:@"\"Cookie: gdriveid=%@;\"",[TondarAPI GDriveID]]; 46 | NSString* url=@"http://gdl.lixian.vip.xunlei.com/download?fid=j+f2P6nsVNZFKQdfr8pNzrHKTt0NtvpjAAAAAI/7zLCWJ/cdtHAo4U/v2Z08aGFU&mid=666&threshold=150&tid=C68A4BB60AEF6B90BFE413A399AF5991&srcid=4&verno=1&g=8FFBCCB09627F71DB47028E14FEFD99D3C686154&scn=c11&i=2682E4FEEFFAF0BB898FE53880FD5433&t=4&ui=642109&ti=62449130369&s=1677374989&m=0&n=01B2DE3389C4BB2E48331CAC1B54562E412202CA6E303234585406D271783236344CF92F97CBD3B0CAB2E72288F72E6D6B1731E45F00000000&ff=0&co=0766E865B2CB672C15A99F114A99658B&cm=1"; 47 | NSString* name=@"我正在测试.mkv"; 48 | NSString* json=[NSString stringWithFormat:@"{\"jsonrpc\":\"2.0\", \"id\":\"qwer\",\"method\":\"aria2.addUri\",\"params\":[[\"%@\"],{\"header\":%@,\"out\",\"%@\"}]}",url,cookie,name]; 49 | ASIHTTPRequest *request=[ASIHTTPRequest requestWithURL:[NSURL URLWithString:@"http://192.168.1.222:800/jsonrpc"]]; 50 | [request appendPostData:[json dataUsingEncoding:NSUTF8StringEncoding]]; 51 | [request startSynchronous]; 52 | NSLog(@"%d",[request responseStatusCode]); 53 | */ 54 | /*获取删除和过期任务(有问题) 55 | for (XunleiItemInfo *task in [TondarAPI readAllDeletedTasks]) { 56 | NSLog(@"%@", task.name); 57 | } 58 | */ 59 | //读取云转码第一页,并删除第一个,再打印第一页 60 | /* 61 | NSMutableArray* ma=[TondarAPI readYunTasksWithPage:1 retIfHasNextPage:NULL]; 62 | for (XunleiItemInfo *task in ma) { 63 | NSLog(@"%@-------%@", task.taskid,task.name); 64 | } 65 | [TondarAPI deleteYunTaskByID:[(XunleiItemInfo*)[ma objectAtIndex:0] taskid]]; 66 | for (XunleiItemInfo *task in [TondarAPI readYunTasksWithPage:1 retIfHasNextPage:NULL]) { 67 | NSLog(@"%@-------%@", task.taskid,task.name); 68 | } 69 | */ 70 | /* 71 | //获取全部云转码任务 72 | for (XunleiItemInfo *task in [TondarAPI readAllYunTasks]) { 73 | NSLog(@"%@", task.name); 74 | } 75 | */ 76 | /* 77 | for (XunleiItemInfo *task in [TondarAPI readAllDeletedTasks]) { 78 | NSLog(@"%@", task.name); 79 | } 80 | */ 81 | /* 82 | //测试快传 83 | NSURL *kuaiURL=[NSURL URLWithString:@"http://kuai.xunlei.com/d/NCMPTPTXWUZC"]; 84 | // [TondarAPI addAllKuaiTasksToLixianByURL:kuaiURL]; 85 | NSArray* infos=[TondarAPI getKuaiItemInfos:kuaiURL]; 86 | for(KuaiItemInfo* i in infos){ 87 | NSLog(@"Name:%@<<<<<<<<<< 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIdentifier 10 | com.res0w.${PRODUCT_NAME:rfc1034identifier} 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundlePackageType 14 | BNDL 15 | CFBundleShortVersionString 16 | 1.0 17 | CFBundleSignature 18 | ???? 19 | CFBundleVersion 20 | 1 21 | 22 | 23 | -------------------------------------------------------------------------------- /URLTesting/URLTesting-Prefix.pch: -------------------------------------------------------------------------------- 1 | // 2 | // Prefix header for all source files of the 'URLTesting' target in the 'URLTesting' project 3 | // 4 | -------------------------------------------------------------------------------- /URLTesting/URLTesting.h: -------------------------------------------------------------------------------- 1 | // 2 | // URLTesting.h 3 | // URLTesting 4 | // 5 | // Created by liuchao on 8/21/12. 6 | // Copyright (c) 2012 MartianZ. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface URLTesting : SenTestCase 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /URLTesting/URLTesting.m: -------------------------------------------------------------------------------- 1 | // 2 | // URLTesting.m 3 | // URLTesting 4 | // 5 | // Created by liuchao on 8/21/12. 6 | // Copyright (c) 2012 MartianZ. All rights reserved. 7 | // 8 | 9 | #import "URLTesting.h" 10 | #import "ConvertURL.h" 11 | 12 | @implementation URLTesting 13 | 14 | - (void)setUp 15 | { 16 | [super setUp]; 17 | 18 | // Set-up code here. 19 | } 20 | 21 | - (void)tearDown 22 | { 23 | // Tear-down code here. 24 | 25 | [super tearDown]; 26 | } 27 | 28 | - (void)testExample 29 | { 30 | 31 | } 32 | 33 | @end 34 | -------------------------------------------------------------------------------- /URLTesting/en.lproj/InfoPlist.strings: -------------------------------------------------------------------------------- 1 | /* Localized versions of Info.plist keys */ 2 | 3 | --------------------------------------------------------------------------------