├── .gitignore
├── LICENSE
├── README.md
├── build_kodi_waipu_addon_on_rpi_osmc.sh
├── checksum_file.py
├── cloud_sync.ps1
├── cloud_sync_config.example.ps1
├── expand_every_cloudf.py
├── removeGhosts.ps1
├── set_resolution
├── sync.lnk
├── sync_all_I_want.ps1
├── sync_all_but_shared.ps1
├── sync_odrive.ps1
├── transmission_re_add_missing_torrents.sh
└── utils.ps1
/.gitignore:
--------------------------------------------------------------------------------
1 | *.txt
2 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
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 | .
675 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # scripts
2 |
3 | ## Cross-platform
4 |
5 | ### checksum_file.py
6 | Print the checksum of a file, calculated using common, standard algorithms.
7 |
8 | ### expand_every_cloudf.py
9 | Traverse a directory recursively until no cloudf placeholders left.
10 | (This might only work on Windows. TODO try on Linux.)
11 |
12 | ## Linux
13 |
14 | ### build_kodi_waipu_addon_on_rpi_osmc.sh
15 | An automated way of building the [Waipu.tv](https://github.com/flubshi/pvr.waipu) PVR plugin for Kodi on a Raspberry Pi OSMC.
16 | By default it builds the addon for Kodi Leia, but another version can be specified as an argument too.
17 |
18 | ### transmission_re_add_missing_torrents.sh
19 | Helper script to alleviate the pain that this transmission issue causes: https://github.com/transmission/transmission/issues/83
20 |
21 | ## Windows
22 |
23 | ### removeGhosts.ps1
24 | I found the original version of this script [here](https://theorypc.ca/2017/06/28/remove-ghost-devices-natively-with-powershell/?unapproved=10049&moderation-hash=10c8951dd7472325cbcaeed99af2ec9e).
25 | Thank you for TrententTye and Alexander Boersch for their excellent work!
26 |
27 | In this repo I publish a slightly improved version of this script which adds:
28 | 1. -narrowByClass,
29 | 1. -narrowByFriendlyName,
30 | 1. -force, making the default run asking for confirmation,
31 | 1. and the ability to apply the optional filters for the non-destructive, listing runs as well.
32 |
33 | ### sync_odrive.ps1
34 | Sync all your cloud files using [odrive cli](https://docs.odrive.com/docs/odrive-cli), instead of syncing them one-by-one. File syncing is parallelised (use the `-JobCount` parameter) and there's a progress bar too.
35 |
36 | It uses `expand_every_cloudf.py` to expand every folder before it starts the syncing. This way the syncing can run once without missing any file.
37 |
38 | ### cloud_sync.ps1
39 | Thank you for Daiyan Yingyu for publishing the [original version](https://blog.daiyanyingyu.uk/files/MoveFromPhone.ps1) of the script.
40 |
41 | This script scans a directory on a phone and checks whether every file can be found in another directory or any of its subdirectories (recursively). If a file is missing, it gets copied over to a specified directory, which may or may not be the same as where the files are looked for. The script finishes with a summary of how many files were copied from how many it found.
42 |
43 | To make it easy to call the script you can create a little config file. This way the only parameter you need to specify is your phone's "nickname". See cloud_sync_config.example.ps1.
44 |
45 | This is handy if you have a local sync of your cloud drive and want to make sure every file is backed up before freeing up space on your device. The OneDrive android app has a feature that can remove the uploaded files, but for instance [mega](https://mega.io/) does not have it yet. I couldn't really find any other *reliable* way to know that all the files have been indeed uploaded.
46 |
--------------------------------------------------------------------------------
/build_kodi_waipu_addon_on_rpi_osmc.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | BRANCH=${1:-Leia}
4 | SEP="==============================================================="
5 | CMAKE_COMMAND="cmake -DADDONS_TO_BUILD=pvr.waipu -DADDON_SRC_PREFIX=../.. -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX=../../xbmc/addons -DPACKAGE_ZIP=1 ../../xbmc/cmake/addons"
6 |
7 | sudo apt-get install build-essential git autoconf cmake zip -y
8 | git clone --branch $BRANCH https://github.com/xbmc/xbmc.git
9 | git clone --branch $BRANCH https://github.com/flubshi/pvr.waipu.git
10 | cd pvr.waipu && mkdir build && cd build
11 |
12 | echo "### expected cmake failure, but we get the directory structure we need..."
13 | $CMAKE_COMMAND
14 | echo $SEP
15 |
16 | echo "#### adding waipu to the supported addons' list..."
17 | cd ../../xbmc/cmake/addons/addons
18 | cp -R pvr.zattoo pvr.waipu
19 | mv pvr.waipu/pvr.zattoo.txt pvr.waipu/pvr.waipu.txt
20 | echo "pvr.waipu https://github.com/flubshi/pvr.waipu $BRANCH" > pvr.waipu/pvr.waipu.txt
21 | echo $SEP
22 |
23 | cd ../../../../pvr.waipu/build
24 | echo "### make up the missing rapidjson.sha256 file..."
25 | wget https://raw.githubusercontent.com/rbuehlma/pvr.zattoo/$BRANCH/depends/common/rapidjson/rapidjson.sha256 -P ../depends/common/rapidjson/
26 | echo $SEP
27 |
28 | $CMAKE_COMMAND
29 | make
30 |
--------------------------------------------------------------------------------
/checksum_file.py:
--------------------------------------------------------------------------------
1 | """Print the checksum of a file, calculated using common, standard algorithms.
2 |
3 | Algos:
4 | - MD5
5 | - SHA256
6 | - SHA512
7 | """
8 | import hashlib
9 |
10 |
11 | def calculate_and_print_file_checksum():
12 | """Calculate and print the checksums for the user specified file."""
13 | filename = input("Enter the input file name: ")
14 | filename = filename.replace('"', '')
15 | with open(filename, "rb") as file:
16 | entire_file_as_bytes = file.read()
17 |
18 | md5 = hashlib.md5(entire_file_as_bytes).hexdigest()
19 | print("MD5:", md5)
20 |
21 | sha256 = hashlib.sha256(entire_file_as_bytes).hexdigest()
22 | print("SHA256:", sha256)
23 |
24 | sha512 = hashlib.sha512(entire_file_as_bytes).hexdigest()
25 | print("SHA512:", sha512)
26 |
27 |
28 | if __name__ == "__main__":
29 | calculate_and_print_file_checksum()
30 |
--------------------------------------------------------------------------------
/cloud_sync.ps1:
--------------------------------------------------------------------------------
1 | <#
2 | .SYNOPSIS
3 | Ensure all the files are uploaded from the phone to the cloud.
4 | Copy any missing files to a destination folder which is expected to be a cloud
5 | sync folder.
6 | #>
7 | param(
8 | [Parameter(Mandatory)]
9 | [string]$phoneName,
10 | [string]$phoneFolderPath="",
11 | [string]$cloudFolderPath="",
12 | [string]$destinationFolderPath="",
13 | [string]$filter=".(jpg|jpeg|mp4)$",
14 | [string]$choco="choco",
15 | [string]$winmerge="WinMergeU",
16 | [string]$tempDir=$env:Temp,
17 | # See cloud_sync_config.example.ps1
18 | [string]$configFile="cloud_sync_config.ps1",
19 | # TODO add multiprocessing [uint32]$jobCount=$(Get-ComputerInfo -Property CsProcessors).CsProcessors.NumberOfCores,
20 | [switch]$confirmCopy=$false,
21 | [switch]$dryRun=$false
22 | )
23 |
24 | #==============================================================================#
25 | # FUNCTIONS
26 | #==============================================================================#
27 |
28 | function Get-ShellProxy
29 | {
30 | if (-not $global:ShellProxy)
31 | {
32 | $global:ShellProxy = new-object -com Shell.Application
33 | }
34 | $global:ShellProxy
35 | }
36 |
37 | function Get-Phone
38 | {
39 | param($phoneName)
40 | $shell = Get-ShellProxy
41 | # 17 (0x11) = ssfDRIVES from the ShellSpecialFolderConstants (https://msdn.microsoft.com/en-us/library/windows/desktop/bb774096(v=vs.85).aspx)
42 | # => "My Computer" — the virtual folder that contains everything on the local computer: storage devices, printers, and Control Panel.
43 | # This folder can also contain mapped network drives.
44 | $shellItem = $shell.NameSpace(17).self
45 | $phone = $shellItem.GetFolder.items() | where { $_.name -eq $phoneName }
46 | return $phone
47 | }
48 |
49 | function Get-SubFolder
50 | {
51 | param($parent,[string]$path)
52 | $pathParts = @( $path.Split([system.io.path]::DirectorySeparatorChar) )
53 | $current = $parent
54 | foreach ($pathPart in $pathParts)
55 | {
56 | if ($pathPart)
57 | {
58 | $current = $current.GetFolder.items() | where { $_.Name -eq $pathPart }
59 | }
60 | }
61 | return $current
62 | }
63 |
64 | <#
65 | .SYNOPSIS
66 | Return a possible equivalent of the name of `$phoneFile` in the cloud when
67 | "Keep file names as in the device" is disabled.
68 | #>
69 | function GetMegaFilename
70 | {
71 | param($phoneFile)
72 |
73 | $extension = [System.IO.Path]::GetExtension($phoneFile.name)
74 | $megaName = $phoneFile.ExtendedProperty("System.DateModified").ToString("yyyy-MM-dd HH.mm.ss")
75 | $megaFilename = "$megaName$extension"
76 | return $megaFilename
77 | }
78 |
79 | function EnsureChocoIsInstalled
80 | {
81 | param([string]$choco)
82 |
83 | $command = Get-Command -Name $choco -ErrorAction SilentlyContinue
84 | if ($command -eq $null) {
85 | Write-Output "'$choco' is missing. Let's install it."
86 |
87 | Set-ExecutionPolicy Bypass -Scope Process -Force
88 | [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072
89 | $chocoInstaller = "https://community.chocolatey.org/install.ps1"
90 | $arguments = "Invoke-Expression ((New-Object System.Net.WebClient).DownloadString('$chocoInstaller'))"
91 | Start-Process powershell -ArgumentList $arguments -Verb RunAs -Wait
92 | } else {
93 | Write-Output "'$choco' is installed."
94 | }
95 | }
96 |
97 | function EnsureWinMergeIsInstalled
98 | {
99 | param([string]$choco, [string]$winmerge)
100 |
101 | $command = Get-Command -Name $winmerge -ErrorAction SilentlyContinue
102 | if ($command -eq $null) {
103 | Write-Output "'$winmerge' is missing. Let's install it."
104 |
105 | EnsureChocoIsInstalled $choco
106 |
107 | # handle the case when choco was freshly installed
108 | $command = Get-Command -Name $choco -ErrorAction SilentlyContinue
109 | if ($command -eq $null) {
110 | $choco = [IO.Path]::Combine($env:ChocolateyInstall, "choco")
111 | $command = Get-Command -Name $choco -ErrorAction SilentlyContinue
112 | if ($command -eq $null) {
113 | throw "Cannot find '$choco'"
114 | }
115 | }
116 |
117 | Start-Process $choco -ArgumentList "install winmerge" –Verb RunAs -Wait
118 | } else {
119 | Write-Output "'$winmerge' is installed."
120 | }
121 | }
122 |
123 | function EnsurePrerequisites
124 | {
125 | param([string]$choco, [string]$winmerge)
126 |
127 | EnsureWinMergeIsInstalled $choco $winmerge
128 | }
129 |
130 | function ClearTempDirectory
131 | {
132 | param($tempDir, $filter)
133 |
134 | Write-Output "Cleaning '$tempDir'..."
135 | Get-ChildItem -Path $tempDir -File | where { $_.Name -match $filter } | foreach { $_.Delete()}
136 | Write-Output "Done"
137 | }
138 |
139 | function GetTempFileName
140 | {
141 | param($phoneFile, $tempDir)
142 |
143 | return [IO.Path]::Combine($tempDir, $phoneFile.Name)
144 | }
145 |
146 | function CreateTempFile
147 | {
148 | param($phoneFile, $tempDir)
149 |
150 | $shell = Get-ShellProxy
151 | $destinationFolder = $shell.Namespace($tempDir).self
152 |
153 | $tempFile = GetTempFileName $phoneFile $tempDir
154 | $destinationFolder.GetFolder.CopyHere($phoneFile)
155 | Write-Debug "Created temporary file '$tempFile'"
156 |
157 | return $tempFile
158 | }
159 |
160 | function FilesAreIdentical
161 | {
162 | param([string]$winmerge, $phoneFile, $cloudFile)
163 |
164 | $arguments = "-enableexitcode -noninteractive -minimize `"$phoneFile`" `"$cloudFile`""
165 | $process = Start-Process $winmerge -windowstyle Hidden -ArgumentList $arguments -PassThru -Wait
166 | $comparisonResult = $process.ExitCode
167 |
168 | enum Result {
169 | Identical = 0
170 | Different
171 | Error
172 | }
173 | $enumResult = [Enum]::ToObject([Result], $comparisonResult)
174 |
175 | $result = switch ($enumResult) {
176 | Identical { $true }
177 | Different { $false }
178 | Error {
179 | throw "Failed to compare '$phoneFile' and '$cloudFile'"
180 | }
181 | }
182 |
183 | return $result
184 | }
185 |
186 | function IsInCloud
187 | {
188 | param($phoneFile, $cloudFiles, $tempDir)
189 |
190 | $originalFilename = $phoneFile.name
191 | $cloudFile = $cloudFiles[$originalFilename]
192 |
193 | if ($cloudFile -eq $null) {
194 | $megaFilename = GetMegaFilename($phoneFile)
195 | Write-Debug "Mega filename guess for '$originalFilename': '$megaFilename'"
196 | $cloudFile = $cloudFiles[$megaFilename]
197 | Write-Debug "Mega filename match: $($cloudFile -ne $null)"
198 | }
199 |
200 | if ($cloudFile -eq $null) {
201 | $result = $false
202 | } else {
203 | $extension = [System.IO.Path]::GetExtension($originalFilename)
204 | Write-Debug "'$originalFilename' extension: '$extension'"
205 |
206 | if ($extension -eq ".mp4") {
207 | # These files have the exact same size on the phone and on the PC too.
208 | $phoneFileSize = $phoneFile.ExtendedProperty("System.Size")
209 | $cloudFileSize = $cloudFile.Length
210 | Write-Debug "$($phoneFile.name) $phoneFileSize == $($cloudFile.name) $cloudFileSize"
211 | if ($phoneFileSize -eq $cloudFileSize) {
212 | $result = $true
213 | } else {
214 | $result = $false
215 | }
216 | } else {
217 | # These files can have different size or modified date on the phone and on the PC.
218 | # So we do a proper comparison using winmerge.
219 |
220 | $tempFile = CreateTempFile $phoneFile $tempDir
221 | $result = FilesAreIdentical $winmerge $tempFile $cloudFile
222 | }
223 | }
224 |
225 | return $result
226 | }
227 |
228 | function CacheCloudFiles
229 | {
230 | param([string]$cloudFolderPath, [string]$filter)
231 |
232 | $cloudFiles = @{}
233 | foreach ($file in Get-ChildItem -Path $cloudFolderPath -Recurse | where { $_.Name -match $filter }) {
234 | $cloudFiles.add($file.Name, $file)
235 | }
236 |
237 | return $cloudFiles
238 | }
239 |
240 | function GetConfig
241 | {
242 | param([string]$configFile)
243 |
244 | if (![System.IO.File]::Exists($configFile)) {
245 | $configFile = [IO.Path]::Combine($PSScriptRoot, $configFile)
246 | }
247 |
248 | . $configFile
249 |
250 | return $config
251 | }
252 |
253 | #==============================================================================#
254 | # MAIN
255 | #==============================================================================#
256 |
257 | EnsurePrerequisites $choco $winmerge
258 |
259 | $config = GetConfig($configFile)
260 |
261 | if ($cloudFolderPath -eq "") {
262 | $cloudFolderPath = $config.settings.cloudFolderPath
263 | }
264 |
265 | if ($destinationFolderPath -eq "") {
266 | $destinationFolderPath = $config.settings.destinationFolderPath
267 | }
268 |
269 | $phoneInfo = $config.phones[$phoneName]
270 | if ($phoneInfo -ne $null) {
271 | $phoneName = $phoneInfo.name
272 | }
273 |
274 | if ($phoneFolderPath -eq "") {
275 | if ($phoneInfo -eq $null) {
276 | throw "Failed to find $phoneName in $configFile"
277 | }
278 | $phoneFolderPath = $phoneInfo.folder
279 | }
280 |
281 | $phone = Get-Phone -phoneName $phoneName
282 | if ($phone -eq $null) {
283 | throw "Can't find '$phoneName'. Have you attached the phone? Is it in 'File transfer' mode?"
284 | }
285 | if (!$(Test-Path -Path $cloudFolderPath -PathType Container)) {
286 | throw "Can't find the folder '$cloudFolderPath'."
287 | }
288 | if (!$(Test-Path -Path $destinationFolderPath -PathType Container)) {
289 | throw "Can't find the folder '$destinationFolderPath'."
290 | }
291 |
292 | # TODO add multiprocessing Write-Output "Running on $jobCount threads..."
293 |
294 | $phoneFolder = Get-SubFolder $phone $phoneFolderPath
295 | Write-Output "Looking for files under '$phoneFolderPath' that match '$filter'..."
296 | $phoneFiles = @( $phoneFolder.GetFolder.items() | where { $_.Name -match $filter } )
297 | $phoneFileCount = $phoneFiles.Count
298 | Write-Output "Found $phoneFileCount file(s) on the phone"
299 |
300 | $phonePath = "$phoneName\$phoneFolderPath"
301 | Write-Output "Processing path: $phonePath"
302 | Write-Output "Looking for files in: $cloudFolderPath"
303 | if ($phoneFileCount -gt 0) {
304 | $action = if ($dryRun) {"NOT copy (dry-run)"} else {"copy"}
305 | Write-Output "Will $action missing files to: $destinationFolderPath"
306 |
307 | $shell = Get-ShellProxy
308 | $destinationFolder = $shell.Namespace($destinationFolderPath).self
309 |
310 | Write-Output "Looking for files under '$cloudFolderPath' that match '$filter'..."
311 | $cloudFiles = CacheCloudFiles $cloudFolderPath $filter
312 | Write-Output "Found $($cloudFiles.Count) file(s) in the cloud"
313 |
314 | ClearTempDirectory $tempDir $filter # this helps re-runs
315 |
316 | $processedCount = 0;
317 | $copied = 0;
318 | foreach ($phoneFile in $phoneFiles) {
319 | $fileName = $phoneFile.Name
320 |
321 | ++$processedCount
322 | $percent = [int](($processedCount * 100) / $phoneFileCount)
323 | Write-Progress -Activity "Processing Files in $phonePath" `
324 | -Status "Processing File ${count} / ${totalItems} (${percent}%)" `
325 | -CurrentOperation $fileName `
326 | -PercentComplete $percent
327 |
328 | if (!(IsInCloud $phoneFile $cloudFiles $tempDir)) {
329 | if ($dryRun) {
330 | Write-Output "Would try to copy $fileName to $destinationFolderPath"
331 | ++$copied
332 | } else {
333 | $confirmed = $true
334 | if ($confirmCopy) {
335 | $confirmation = Read-Host "$fileName seems to be missing from $cloudFolderPath"`
336 | " or any of its sub-folders."`
337 | " Shall we copy it to $destinationFolderPath? (y/n)"
338 | if ($confirmation -ne 'y') {
339 | $confirmed = $false
340 | }
341 | }
342 | if ($confirmed) {
343 | # TODO re-use the temporary files, if they exist, with GetTempFileName
344 | Write-Output "Copying $fileName to $destinationFolderPath..."
345 | $destinationFolder.GetFolder.CopyHere($phoneFile)
346 | ++$copied
347 | }
348 | }
349 | }
350 | }
351 |
352 | if ($copied -eq 0) {
353 | Write-Output "All $phoneFileCount file(s) seem to be already synced. 🎉🎉🎉"
354 | } else {
355 | $action = if ($dryRun) {"would have been"} else {"were"}
356 | Write-Output "$copied/$phoneFileCount item(s) $action copied to $destinationFolderPath"
357 | }
358 | } else {
359 | Write-Output "Found no files under '$phonePath' matching the '$filter' filter."
360 | }
361 |
--------------------------------------------------------------------------------
/cloud_sync_config.example.ps1:
--------------------------------------------------------------------------------
1 | $config = @{
2 | settings = @{
3 | cloudFolderPath = ""
4 | destinationFolderPath = ""
5 | }
6 | phones = @{
7 | oneplus = @{
8 | name = ""
9 | folder = ""
11 | }
12 | samsung = @{
13 | # ...
14 | }
15 | iphone = @{
16 | # ...
17 | }
18 | }
19 | }
--------------------------------------------------------------------------------
/expand_every_cloudf.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 | """Traverse a directory recursively until no .cloudf folder placeholder left.
3 |
4 | [odrive](https://www.odrive.com) creates placeholder files for directories and files
5 | stored in the cloud so they don't use any disk space unless you try to open them,
6 | when they are synced to the disk.
7 | They have the .cloud extension for files and .cloudf for folders.
8 |
9 | This whole expansion costs 0 byte disk space but gives you access to all your
10 | cloud files either directly or as a .cloud placeholder.
11 |
12 | If the emojis aren't printed properly on Windows you can try the
13 | [Windows Terminal](https://github.com/microsoft/terminal).
14 | """
15 | import argparse
16 | import multiprocessing as mp
17 | import os
18 | import re
19 | import sys
20 | import time
21 |
22 |
23 | def parse_args():
24 | """Return the parsed cli arguments."""
25 | parser = argparse.ArgumentParser(description="Expand .cloudf files into actual directories")
26 | parser.add_argument("-d", "--directory", help="The root directory where our journey begins at.")
27 | parser.add_argument("-e", "--exclude-pattern",
28 | help="A regular expression which is searched in the absolute path of a cloudf file.\n"
29 | "In case of a match, the cloudf file won't get expanded.")
30 | parser.add_argument("-t", "--threads", type=int, default=None,
31 | help="How many threads the script should use to expand folders.\n"
32 | "Default: number of CPU cores")
33 | args = parser.parse_args()
34 |
35 | if args.directory is None:
36 | args.directory = input("Enter the root directory: ")
37 | args.directory = args.directory.replace('"', '')
38 |
39 | return args
40 |
41 |
42 | def expand(cloud_folder_full_path):
43 | """Double-click on the folder on the `cloud_folder_full_path` path."""
44 | # TODO does this work on Linux?
45 | os.startfile(cloud_folder_full_path)
46 |
47 |
48 | def try_expanding(cloud_folder_full_path, sleep_between_tries=0.1, timeout=10 * 60):
49 | start_time = time.time()
50 | while os.path.exists(cloud_folder_full_path):
51 | try:
52 | expand(cloud_folder_full_path)
53 | time.sleep(sleep_between_tries)
54 | except FileNotFoundError:
55 | pass
56 |
57 | elapsed_time = time.time() - start_time
58 | if elapsed_time > timeout:
59 | return False
60 | return True
61 |
62 |
63 | def traverse_and_expand(directory, exclude_pattern, num_threads):
64 | """Open every cloudf folder until none left under the user specified `directory`."""
65 | if num_threads is None:
66 | num_threads = os.cpu_count()
67 | print(f"using {num_threads} threads for folder expansion")
68 |
69 | with mp.Pool(num_threads) as pool:
70 | there_might_be_more = True
71 | cycle_counter = 0
72 | while there_might_be_more:
73 | async_results = []
74 |
75 | cycle_counter += 1
76 | last_progress_msg_len = 0
77 | print(f"traversing #{cycle_counter}...")
78 | for (root, _, filenames) in os.walk(directory):
79 | progress_msg_len = len(root)
80 | print(' ' * last_progress_msg_len, end='\r')
81 | print(root, end='\r')
82 | last_progress_msg_len = progress_msg_len
83 |
84 | cloud_folder_names = [filename for filename in filenames
85 | if re.search(r"\.cloudf$", filename) is not None]
86 | for cloud_folder_name in cloud_folder_names:
87 | cloud_folder_full_path = os.path.join(root, cloud_folder_name)
88 |
89 | if (exclude_pattern is not None) and re.search(exclude_pattern, cloud_folder_full_path):
90 | print(f"🛑✋ exclude {cloud_folder_full_path} ✋🛑")
91 | pass
92 | else:
93 | print(f"🟢👍 expand {cloud_folder_full_path} ... 👍🟢")
94 | async_result = pool.apply_async(try_expanding, args=(cloud_folder_full_path,))
95 | async_results.append((cloud_folder_full_path, async_result))
96 |
97 | print(' ' * last_progress_msg_len, end='\r')
98 | print(f"wait for the expansion threads #{cycle_counter}...")
99 | for (path, async_result) in async_results:
100 | print(f"fetching the result for {path}... ", end='')
101 | sys.stdout.flush()
102 | result = "✔" if async_result.get() else "❌"
103 | print(result)
104 |
105 | there_might_be_more = len(async_results) != 0
106 |
107 |
108 | def traverse_and_open_all():
109 | """Parse args and then start the traversal on a single or multiple threads."""
110 | args = parse_args()
111 |
112 | traverse_and_expand(args.directory, args.exclude_pattern, args.threads)
113 |
114 | print("🎉🎉🎉 All done! 🎉🎉🎉")
115 |
116 |
117 | if __name__ == "__main__":
118 | traverse_and_open_all()
119 |
--------------------------------------------------------------------------------
/removeGhosts.ps1:
--------------------------------------------------------------------------------
1 | <#
2 | .SYNOPSIS
3 | Removes ghost devices from your system
4 |
5 | .DESCRIPTION
6 | This script will remove ghost devices from your system. These are devices that are present but have an "InstallState" as false. These devices are typically shown as 'faded'
7 | in Device Manager, when you select "Show hidden and devices" from the view menu. This script has been tested on Windows 2008 R2 SP2 with PowerShell 3.0, 5.1, Server 2012R2
8 | with Powershell 4.0 and Windows 10 Pro with Powershell 5.1. There is no warranty with this script. Please use cautiously as removing devices is a destructive process without
9 | an undo.
10 |
11 | .PARAMETER filterByFriendlyName
12 | This parameter will exclude devices that match the partial name provided. This paramater needs to be specified in an array format for all the friendly names you want to be excluded.
13 | "Intel" will match "Intel(R) Xeon(R) CPU E5-2680 0 @ 2.70GHz". "Loop" will match "Microsoft Loopback Adapter".
14 |
15 | .PARAMETER narrowByFriendlyName
16 | This parameter will include devices that match the partial name provided. This paramater needs to be specified in an array format for all the friendly names you want to be included.
17 | "Intel" will match "Intel(R) Xeon(R) CPU E5-2680 0 @ 2.70GHz". "Loop" will match "Microsoft Loopback Adapter".
18 |
19 | .PARAMETER filterByClass
20 | This parameter will exclude devices that match the class name provided. This paramater needs to be specified in an array format for all the class names you want to be excluded.
21 | This is an exact string match so "Disk" will not match "DiskDrive".
22 |
23 | .PARAMETER narrowByClass
24 | This parameter will include devices that match the class name provided. This paramater needs to be specified in an array format for all the class names you want to be included.
25 | This is an exact string match so "Disk" will not match "DiskDrive".
26 |
27 | .PARAMETER listDevicesOnly
28 | listDevicesOnly will output a table of all devices found in this system.
29 |
30 | .PARAMETER listGhostDevicesOnly
31 | listGhostDevicesOnly will output a table of all 'ghost' devices found in this system.
32 |
33 | .PARAMETER force
34 | If specified, each matching device will be removed WITHOUT any confirmation!
35 |
36 | .EXAMPLE
37 | Lists all devices
38 | . "removeGhosts.ps1" -listDevicesOnly
39 |
40 | .EXAMPLE
41 | Save the list of devices as an object
42 | $Devices = . "removeGhosts.ps1" -listDevicesOnly
43 |
44 | .EXAMPLE
45 | Lists all 'ghost' devices
46 | . "removeGhosts.ps1" -listGhostDevicesOnly
47 |
48 | .EXAMPLE
49 | Lists all 'ghost' devices with a class of "Net"
50 | . "removeGhosts.ps1" -listGhostDevicesOnly -narrowByClass Net
51 |
52 | .EXAMPLE
53 | Lists all 'ghost' devices with a class of "Net" AND a friendly name matching "Realtek"
54 | . "removeGhosts.ps1" -listGhostDevicesOnly -narrowbyfriendlyname Realtek -narrowbyclass Net
55 |
56 | .EXAMPLE
57 | Save the list of 'ghost' devices as an object
58 | $ghostDevices = . "removeGhosts.ps1" -listGhostDevicesOnly
59 |
60 | .EXAMPLE
61 | Remove all ghost devices EXCEPT any devices that have "Intel" or "Citrix" in their friendly name
62 | . "removeGhosts.ps1" -filterByFriendlyName @("Intel","Citrix")
63 |
64 | .EXAMPLE
65 | Remove all ghost devices that have "Intel" in their friendly name
66 | . "removeGhosts.ps1" -narrowByFriendlyName Intel
67 |
68 | .EXAMPLE
69 | Remove all ghost devices EXCEPT any devices that are apart of the classes "LegacyDriver" or "Processor"
70 | . "removeGhosts.ps1" -filterByClass @("LegacyDriver","Processor")
71 |
72 | .EXAMPLE
73 | Remove all ghost devices EXCEPT for devices with a friendly name of "Intel" or "Citrix" or with a class of "LegacyDriver" or "Processor"
74 | . "removeGhosts.ps1" -filterByClass @("LegacyDriver","Processor") -filterByFriendlyName @("Intel","Citrix")
75 |
76 | .EXAMPLE
77 | Remove all ghost network devices i.e. the ones with a class of "Net"
78 | . "removeGhosts.ps1" -narrowByClass Net
79 |
80 | .EXAMPLE
81 | Remove all ghost devices without confirmation
82 | . "removeGhosts.ps1" -Force
83 |
84 | .NOTES
85 | Permission level has not been tested. It is assumed you will need to have sufficient rights to uninstall devices from device manager for this script to run properly.
86 | #>
87 |
88 | Param(
89 | [array]$FilterByClass,
90 | [array]$NarrowByClass,
91 | [array]$FilterByFriendlyName,
92 | [array]$NarrowByFriendlyName,
93 | [switch]$listDevicesOnly,
94 | [switch]$listGhostDevicesOnly,
95 | [switch]$Force
96 | )
97 |
98 | #parameter futzing
99 | $removeDevices = $true
100 | if ($FilterByClass -ne $null) {
101 | write-host "FilterByClass: $FilterByClass"
102 | }
103 |
104 | if ($NarrowByClass -ne $null) {
105 | write-host "NarrowByClass: $NarrowByClass"
106 | }
107 |
108 | if ($FilterByFriendlyName -ne $null) {
109 | write-host "FilterByFriendlyName: $FilterByFriendlyName"
110 | }
111 |
112 | if ($NarrowByFriendlyName -ne $null) {
113 | write-host "NarrowByFriendlyName: $NarrowByFriendlyName"
114 | }
115 |
116 | if ($listDevicesOnly -eq $true) {
117 | write-host "List devices without removal: $listDevicesOnly"
118 | $removeDevices = $false
119 | }
120 |
121 | if ($listGhostDevicesOnly -eq $true) {
122 | write-host "List ghost devices without removal: $listGhostDevicesOnly"
123 | $removeDevices = $false
124 | }
125 |
126 | if ($Force -eq $true) {
127 | write-host "Each removal will happen without any confirmation: $Force"
128 | }
129 |
130 | function Filter-Device {
131 | Param (
132 | [System.Object]$dev
133 | )
134 | $Class = $dev.Class
135 | $FriendlyName = $dev.FriendlyName
136 | $matchFilter = $false
137 |
138 | if (($matchFilter -eq $false) -and ($FilterByClass -ne $null)) {
139 | foreach ($ClassFilter in $FilterByClass) {
140 | if ($ClassFilter -eq $Class) {
141 | Write-verbose "Class filter match $ClassFilter, skipping"
142 | $matchFilter = $true
143 | break
144 | }
145 | }
146 | }
147 | if (($matchFilter -eq $false) -and ($NarrowByClass -ne $null)) {
148 | $shouldInclude = $false
149 | foreach ($ClassFilter in $NarrowByClass) {
150 | if ($ClassFilter -eq $Class) {
151 | $shouldInclude = $true
152 | break
153 | }
154 | }
155 | $matchFilter = !$shouldInclude
156 | }
157 | if (($matchFilter -eq $false) -and ($FilterByFriendlyName -ne $null)) {
158 | foreach ($FriendlyNameFilter in $FilterByFriendlyName) {
159 | if ($FriendlyName -like '*'+$FriendlyNameFilter+'*') {
160 | Write-verbose "FriendlyName filter match $FriendlyName, skipping"
161 | $matchFilter = $true
162 | break
163 | }
164 | }
165 | }
166 | if (($matchFilter -eq $false) -and ($NarrowByFriendlyName -ne $null)) {
167 | $shouldInclude = $false
168 | foreach ($FriendlyNameFilter in $NarrowByFriendlyName) {
169 | if ($FriendlyName -like '*'+$FriendlyNameFilter+'*') {
170 | $shouldInclude = $true
171 | break
172 | }
173 | }
174 | $matchFilter = !$shouldInclude
175 | }
176 | return $matchFilter
177 | }
178 |
179 | function Filter-Devices {
180 | Param (
181 | [array]$devices
182 | )
183 | $filteredDevices = @()
184 | foreach ($dev in $devices) {
185 | $matchFilter = Filter-Device -Dev $dev
186 | if ($matchFilter -eq $false) {
187 | $filteredDevices += @($dev)
188 | }
189 | }
190 | return $filteredDevices
191 | }
192 | function Get-Ghost-Devices {
193 | Param (
194 | [array]$devices
195 | )
196 | return ($devices | where {$_.InstallState -eq $false} | sort -Property FriendlyName)
197 | }
198 |
199 | # NOTE: White spaces are important in $setupapi for some reason!
200 | $setupapi = @"
201 | using System;
202 | using System.Diagnostics;
203 | using System.Text;
204 | using System.Runtime.InteropServices;
205 | namespace Win32
206 | {
207 | public static class SetupApi
208 | {
209 | // 1st form using a ClassGUID only, with Enumerator = IntPtr.Zero
210 | [DllImport("setupapi.dll", CharSet = CharSet.Auto)]
211 | public static extern IntPtr SetupDiGetClassDevs(
212 | ref Guid ClassGuid,
213 | IntPtr Enumerator,
214 | IntPtr hwndParent,
215 | int Flags
216 | );
217 |
218 | // 2nd form uses an Enumerator only, with ClassGUID = IntPtr.Zero
219 | [DllImport("setupapi.dll", CharSet = CharSet.Auto)]
220 | public static extern IntPtr SetupDiGetClassDevs(
221 | IntPtr ClassGuid,
222 | string Enumerator,
223 | IntPtr hwndParent,
224 | int Flags
225 | );
226 |
227 | [DllImport("setupapi.dll", CharSet = CharSet.Auto, SetLastError = true)]
228 | public static extern bool SetupDiEnumDeviceInfo(
229 | IntPtr DeviceInfoSet,
230 | uint MemberIndex,
231 | ref SP_DEVINFO_DATA DeviceInfoData
232 | );
233 |
234 | [DllImport("setupapi.dll", SetLastError = true)]
235 | public static extern bool SetupDiDestroyDeviceInfoList(
236 | IntPtr DeviceInfoSet
237 | );
238 | [DllImport("setupapi.dll", CharSet = CharSet.Auto, SetLastError = true)]
239 | public static extern bool SetupDiGetDeviceRegistryProperty(
240 | IntPtr deviceInfoSet,
241 | ref SP_DEVINFO_DATA deviceInfoData,
242 | uint property,
243 | out UInt32 propertyRegDataType,
244 | byte[] propertyBuffer,
245 | uint propertyBufferSize,
246 | out UInt32 requiredSize
247 | );
248 | [DllImport("setupapi.dll", SetLastError = true, CharSet = CharSet.Auto)]
249 | public static extern bool SetupDiGetDeviceInstanceId(
250 | IntPtr DeviceInfoSet,
251 | ref SP_DEVINFO_DATA DeviceInfoData,
252 | StringBuilder DeviceInstanceId,
253 | int DeviceInstanceIdSize,
254 | out int RequiredSize
255 | );
256 |
257 |
258 | [DllImport("setupapi.dll", CharSet = CharSet.Auto, SetLastError = true)]
259 | public static extern bool SetupDiRemoveDevice(IntPtr DeviceInfoSet,ref SP_DEVINFO_DATA DeviceInfoData);
260 | }
261 | [StructLayout(LayoutKind.Sequential)]
262 | public struct SP_DEVINFO_DATA
263 | {
264 | public uint cbSize;
265 | public Guid classGuid;
266 | public uint devInst;
267 | public IntPtr reserved;
268 | }
269 | [Flags]
270 | public enum DiGetClassFlags : uint
271 | {
272 | DIGCF_DEFAULT = 0x00000001, // only valid with DIGCF_DEVICEINTERFACE
273 | DIGCF_PRESENT = 0x00000002,
274 | DIGCF_ALLCLASSES = 0x00000004,
275 | DIGCF_PROFILE = 0x00000008,
276 | DIGCF_DEVICEINTERFACE = 0x00000010,
277 | }
278 | public enum SetupDiGetDeviceRegistryPropertyEnum : uint
279 | {
280 | SPDRP_DEVICEDESC = 0x00000000, // DeviceDesc (R/W)
281 | SPDRP_HARDWAREID = 0x00000001, // HardwareID (R/W)
282 | SPDRP_COMPATIBLEIDS = 0x00000002, // CompatibleIDs (R/W)
283 | SPDRP_UNUSED0 = 0x00000003, // unused
284 | SPDRP_SERVICE = 0x00000004, // Service (R/W)
285 | SPDRP_UNUSED1 = 0x00000005, // unused
286 | SPDRP_UNUSED2 = 0x00000006, // unused
287 | SPDRP_CLASS = 0x00000007, // Class (R--tied to ClassGUID)
288 | SPDRP_CLASSGUID = 0x00000008, // ClassGUID (R/W)
289 | SPDRP_DRIVER = 0x00000009, // Driver (R/W)
290 | SPDRP_CONFIGFLAGS = 0x0000000A, // ConfigFlags (R/W)
291 | SPDRP_MFG = 0x0000000B, // Mfg (R/W)
292 | SPDRP_FRIENDLYNAME = 0x0000000C, // FriendlyName (R/W)
293 | SPDRP_LOCATION_INFORMATION = 0x0000000D, // LocationInformation (R/W)
294 | SPDRP_PHYSICAL_DEVICE_OBJECT_NAME = 0x0000000E, // PhysicalDeviceObjectName (R)
295 | SPDRP_CAPABILITIES = 0x0000000F, // Capabilities (R)
296 | SPDRP_UI_NUMBER = 0x00000010, // UiNumber (R)
297 | SPDRP_UPPERFILTERS = 0x00000011, // UpperFilters (R/W)
298 | SPDRP_LOWERFILTERS = 0x00000012, // LowerFilters (R/W)
299 | SPDRP_BUSTYPEGUID = 0x00000013, // BusTypeGUID (R)
300 | SPDRP_LEGACYBUSTYPE = 0x00000014, // LegacyBusType (R)
301 | SPDRP_BUSNUMBER = 0x00000015, // BusNumber (R)
302 | SPDRP_ENUMERATOR_NAME = 0x00000016, // Enumerator Name (R)
303 | SPDRP_SECURITY = 0x00000017, // Security (R/W, binary form)
304 | SPDRP_SECURITY_SDS = 0x00000018, // Security (W, SDS form)
305 | SPDRP_DEVTYPE = 0x00000019, // Device Type (R/W)
306 | SPDRP_EXCLUSIVE = 0x0000001A, // Device is exclusive-access (R/W)
307 | SPDRP_CHARACTERISTICS = 0x0000001B, // Device Characteristics (R/W)
308 | SPDRP_ADDRESS = 0x0000001C, // Device Address (R)
309 | SPDRP_UI_NUMBER_DESC_FORMAT = 0X0000001D, // UiNumberDescFormat (R/W)
310 | SPDRP_DEVICE_POWER_DATA = 0x0000001E, // Device Power Data (R)
311 | SPDRP_REMOVAL_POLICY = 0x0000001F, // Removal Policy (R)
312 | SPDRP_REMOVAL_POLICY_HW_DEFAULT = 0x00000020, // Hardware Removal Policy (R)
313 | SPDRP_REMOVAL_POLICY_OVERRIDE = 0x00000021, // Removal Policy Override (RW)
314 | SPDRP_INSTALL_STATE = 0x00000022, // Device Install State (R)
315 | SPDRP_LOCATION_PATHS = 0x00000023, // Device Location Paths (R)
316 | SPDRP_BASE_CONTAINERID = 0x00000024 // Base ContainerID (R)
317 | }
318 | }
319 | "@
320 | Add-Type -TypeDefinition $setupapi
321 |
322 | #Array for all removed devices report
323 | $removeArray = @()
324 | #Array for all devices report
325 | $array = @()
326 |
327 | $setupClass = [Guid]::Empty
328 | #Get all devices
329 | $devs = [Win32.SetupApi]::SetupDiGetClassDevs([ref]$setupClass, [IntPtr]::Zero, [IntPtr]::Zero, [Win32.DiGetClassFlags]::DIGCF_ALLCLASSES)
330 |
331 | #Initialise Struct to hold device info Data
332 | $devInfo = new-object Win32.SP_DEVINFO_DATA
333 | $devInfo.cbSize = [System.Runtime.InteropServices.Marshal]::SizeOf($devInfo)
334 |
335 | #Device Counter
336 | $devCount = 0
337 | #Enumerate Devices
338 | while([Win32.SetupApi]::SetupDiEnumDeviceInfo($devs, $devCount, [ref]$devInfo)) {
339 |
340 | #Will contain an enum depending on the type of the registry Property, not used but required for call
341 | $propType = 0
342 | #Buffer is initially null and buffer size 0 so that we can get the required Buffer size first
343 | [byte[]]$propBuffer = $null
344 | $propBufferSize = 0
345 | #Get Buffer size
346 | [Win32.SetupApi]::SetupDiGetDeviceRegistryProperty($devs, [ref]$devInfo, [Win32.SetupDiGetDeviceRegistryPropertyEnum]::SPDRP_FRIENDLYNAME, [ref]$propType, $propBuffer, 0, [ref]$propBufferSize) | Out-null
347 | #Initialize Buffer with right size
348 | [byte[]]$propBuffer = New-Object byte[] $propBufferSize
349 |
350 | #Get HardwareID
351 | $propTypeHWID = 0
352 | [byte[]]$propBufferHWID = $null
353 | $propBufferSizeHWID = 0
354 | [Win32.SetupApi]::SetupDiGetDeviceRegistryProperty($devs, [ref]$devInfo, [Win32.SetupDiGetDeviceRegistryPropertyEnum]::SPDRP_HARDWAREID, [ref]$propTypeHWID, $propBufferHWID, 0, [ref]$propBufferSizeHWID) | Out-null
355 | [byte[]]$propBufferHWID = New-Object byte[] $propBufferSizeHWID
356 |
357 | #Get DeviceDesc (this name will be used if no friendly name is found)
358 | $propTypeDD = 0
359 | [byte[]]$propBufferDD = $null
360 | $propBufferSizeDD = 0
361 | [Win32.SetupApi]::SetupDiGetDeviceRegistryProperty($devs, [ref]$devInfo, [Win32.SetupDiGetDeviceRegistryPropertyEnum]::SPDRP_DEVICEDESC, [ref]$propTypeDD, $propBufferDD, 0, [ref]$propBufferSizeDD) | Out-null
362 | [byte[]]$propBufferDD = New-Object byte[] $propBufferSizeDD
363 |
364 | #Get Install State
365 | $propTypeIS = 0
366 | [byte[]]$propBufferIS = $null
367 | $propBufferSizeIS = 0
368 | [Win32.SetupApi]::SetupDiGetDeviceRegistryProperty($devs, [ref]$devInfo, [Win32.SetupDiGetDeviceRegistryPropertyEnum]::SPDRP_INSTALL_STATE, [ref]$propTypeIS, $propBufferIS, 0, [ref]$propBufferSizeIS) | Out-null
369 | [byte[]]$propBufferIS = New-Object byte[] $propBufferSizeIS
370 |
371 | #Get Class
372 | $propTypeCLSS = 0
373 | [byte[]]$propBufferCLSS = $null
374 | $propBufferSizeCLSS = 0
375 | [Win32.SetupApi]::SetupDiGetDeviceRegistryProperty($devs, [ref]$devInfo, [Win32.SetupDiGetDeviceRegistryPropertyEnum]::SPDRP_CLASS, [ref]$propTypeCLSS, $propBufferCLSS, 0, [ref]$propBufferSizeCLSS) | Out-null
376 | [byte[]]$propBufferCLSS = New-Object byte[] $propBufferSizeCLSS
377 | [Win32.SetupApi]::SetupDiGetDeviceRegistryProperty($devs, [ref]$devInfo,[Win32.SetupDiGetDeviceRegistryPropertyEnum]::SPDRP_CLASS, [ref]$propTypeCLSS, $propBufferCLSS, $propBufferSizeCLSS, [ref]$propBufferSizeCLSS) | out-null
378 | $Class = [System.Text.Encoding]::Unicode.GetString($propBufferCLSS)
379 |
380 | #Read FriendlyName property into Buffer
381 | if(![Win32.SetupApi]::SetupDiGetDeviceRegistryProperty($devs, [ref]$devInfo,[Win32.SetupDiGetDeviceRegistryPropertyEnum]::SPDRP_FRIENDLYNAME, [ref]$propType, $propBuffer, $propBufferSize, [ref]$propBufferSize)){
382 | [Win32.SetupApi]::SetupDiGetDeviceRegistryProperty($devs, [ref]$devInfo,[Win32.SetupDiGetDeviceRegistryPropertyEnum]::SPDRP_DEVICEDESC, [ref]$propTypeDD, $propBufferDD, $propBufferSizeDD, [ref]$propBufferSizeDD) | out-null
383 | $FriendlyName = [System.Text.Encoding]::Unicode.GetString($propBufferDD)
384 | #The friendly Name ends with a weird character
385 | if ($FriendlyName.Length -ge 1) {
386 | $FriendlyName = $FriendlyName.Substring(0,$FriendlyName.Length-1)
387 | }
388 | } else {
389 | #Get Unicode String from Buffer
390 | $FriendlyName = [System.Text.Encoding]::Unicode.GetString($propBuffer)
391 | #The friendly Name ends with a weird character
392 | if ($FriendlyName.Length -ge 1) {
393 | $FriendlyName = $FriendlyName.Substring(0,$FriendlyName.Length-1)
394 | }
395 | }
396 |
397 | #InstallState returns true or false as an output, not text
398 | $InstallState = [Win32.SetupApi]::SetupDiGetDeviceRegistryProperty($devs, [ref]$devInfo,[Win32.SetupDiGetDeviceRegistryPropertyEnum]::SPDRP_INSTALL_STATE, [ref]$propTypeIS, $propBufferIS, $propBufferSizeIS, [ref]$propBufferSizeIS)
399 |
400 | # Read HWID property into Buffer
401 | if(![Win32.SetupApi]::SetupDiGetDeviceRegistryProperty($devs, [ref]$devInfo,[Win32.SetupDiGetDeviceRegistryPropertyEnum]::SPDRP_HARDWAREID, [ref]$propTypeHWID, $propBufferHWID, $propBufferSizeHWID, [ref]$propBufferSizeHWID)){
402 | #Ignore if Error
403 | $HWID = ""
404 | } else {
405 | #Get Unicode String from Buffer
406 | $HWID = [System.Text.Encoding]::Unicode.GetString($propBufferHWID)
407 | #trim out excess names and take first object
408 | $HWID = $HWID.split([char]0x0000)[0].ToUpper()
409 | }
410 |
411 | #all detected devices list
412 | $device = New-Object System.Object
413 | $device | Add-Member -type NoteProperty -name FriendlyName -value $FriendlyName
414 | $device | Add-Member -type NoteProperty -name HWID -value $HWID
415 | $device | Add-Member -type NoteProperty -name InstallState -value $InstallState
416 | $device | Add-Member -type NoteProperty -name Class -value $Class
417 | if ($array.count -le 0) {
418 | #for some reason the script will blow by the first few entries without displaying the output
419 | #this brief pause seems to let the objects get created/displayed so that they are in order.
420 | sleep 1
421 | }
422 | $array += @($device)
423 |
424 | <#
425 | We need to execute the filtering at this point because we are in the current device context
426 | where we can execute an action (eg, removal).
427 | InstallState : False == ghosted device
428 | #>
429 | if ($removeDevices -eq $true) {
430 | #we want to remove devices so let's check the filters...
431 | $matchFilter = Filter-Device -Dev $device
432 |
433 | if ($InstallState -eq $False) {
434 | if ($matchFilter -eq $false) {
435 | $message = "Attempting to remove device $FriendlyName"
436 | $confirmed = $false
437 | if (!$Force -eq $true) {
438 | $question = 'Are you sure you want to proceed?'
439 | $choices = '&Yes', '&No'
440 | $decision = $Host.UI.PromptForChoice($message, $question, $choices, 1)
441 | if ($decision -eq 0) {
442 | $confirmed = $true
443 | }
444 | } else {
445 | $confirmed = $true
446 | }
447 | if ($confirmed -eq $true) {
448 | Write-Host $message -ForegroundColor Yellow
449 | $removeObj = New-Object System.Object
450 | $removeObj | Add-Member -type NoteProperty -name FriendlyName -value $FriendlyName
451 | $removeObj | Add-Member -type NoteProperty -name HWID -value $HWID
452 | $removeObj | Add-Member -type NoteProperty -name InstallState -value $InstallState
453 | $removeObj | Add-Member -type NoteProperty -name Class -value $Class
454 | $removeArray += @($removeObj)
455 | if([Win32.SetupApi]::SetupDiRemoveDevice($devs, [ref]$devInfo)){
456 | Write-Host "Removed device $FriendlyName" -ForegroundColor Green
457 | } else {
458 | Write-Host "Failed to remove device $FriendlyName" -ForegroundColor Red
459 | }
460 | } else {
461 | Write-Host "OK, skipped" -ForegroundColor Yellow
462 | }
463 | } else {
464 | write-host "Filter matched. Skipping $FriendlyName" -ForegroundColor Yellow
465 | }
466 | }
467 | }
468 | $devcount++
469 | }
470 |
471 | #output objects so you can take the output from the script
472 | if ($listDevicesOnly) {
473 | $allDevices = $array | sort -Property FriendlyName
474 | $filteredDevices = Filter-Devices -Devices $allDevices
475 | $filteredDevices | ft
476 | write-host "Total devices found : $($allDevices.count)"
477 | write-host "Total filtered devices found : $($filteredDevices.count)"
478 | $ghostDevices = Get-Ghost-Devices -Devices $array
479 | $filteredGhostDevices = Filter-Devices -Devices $ghostDevices
480 | write-host "Total ghost devices found : $($ghostDevices.count)"
481 | write-host "Total filtered ghost devices found : $($filteredGhostDevices.count)"
482 | return $filteredDevices | out-null
483 | }
484 |
485 | if ($listGhostDevicesOnly) {
486 | $ghostDevices = Get-Ghost-Devices -Devices $array
487 | $filteredGhostDevices = Filter-Devices -Devices $ghostDevices
488 | $filteredGhostDevices | ft
489 | write-host "Total ghost devices found : $($ghostDevices.count)"
490 | write-host "Total filtered ghost devices found : $($filteredGhostDevices.count)"
491 | return $filteredGhostDevices | out-null
492 | }
493 |
494 | if ($removeDevices -eq $true) {
495 | write-host "Removed devices:"
496 | $removeArray | sort -Property FriendlyName | ft
497 | write-host "Total removed devices : $($removeArray.count)"
498 | return $removeArray | out-null
499 | }
500 |
--------------------------------------------------------------------------------
/set_resolution:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | mode=$1
4 | disp=$(xrandr | grep -e " connected [^(]" | sed -e "s/\([A-Z0-9]\+\) connected.*/\1/")
5 | xrandr --output $disp --mode $mode
6 |
7 |
--------------------------------------------------------------------------------
/sync.lnk:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/istvans/scripts/5685cc8bc97de7cbe5714ef1bd29c6e76a97ca8e/sync.lnk
--------------------------------------------------------------------------------
/sync_all_I_want.ps1:
--------------------------------------------------------------------------------
1 | . $PSScriptRoot\utils.ps1
2 | & $PSScriptRoot\sync_odrive.ps1 -ExcludePattern "Shared With Me|Steve-OneDrive\\Videos\\|Steve-OneDrive\\Pictures\\|Amazon Cloud Drive" -FolderExpandExcludePattern "Shared With Me" -JobCount 12
3 | pause "Press any key to continue"
4 |
--------------------------------------------------------------------------------
/sync_all_but_shared.ps1:
--------------------------------------------------------------------------------
1 | . .\utils.ps1
2 | .\sync_odrive.ps1 -ExcludePattern "Shared With Me" -JobCount 16
3 | pause "Press any key to continue"
4 |
--------------------------------------------------------------------------------
/sync_odrive.ps1:
--------------------------------------------------------------------------------
1 | # Sync all *.cloud files/directories in the specified `OdrivePath`.
2 | # TODO:
3 | # =====
4 | # - Add multiple runs thus newly added multiple levels of folders can be synced
5 | # in one go.
6 | param(
7 | [Parameter(ValueFromPipeline)][System.Array] $CloudFiles,
8 | [String] $OdrivePath = "D:\odrive",
9 | [String] $OdriveScript = "$HOME\.odrive-agent\bin\odrive.py",
10 | [String] $Python = "python",
11 | [String] $ErrorFile = "errors.txt",
12 | [String] $ExcludePattern = $null,
13 | [String] $FolderExpandExcludePattern = $null,
14 | [String] $IncludePattern = $null,
15 | [uint32] $JobCount = 8,
16 | [switch] $LiveErrorReporting,
17 | [switch] $JustFind
18 | )
19 |
20 | $global:multi_threaded = if ($JobCount -ne 0) {$True} else {$False}
21 | $mt_status = if ($global:multi_threaded) {"enabled"} else {"disabled"}
22 | Write-Host "Multi-threaded operation is $mt_status"
23 |
24 | if (!(Test-Path "$OdrivePath" -PathType Container)) {
25 | throw "Unable to find '$OdrivePath'"
26 | }
27 |
28 | if (!(Test-Path "$OdriveScript" -PathType Leaf)) {
29 | throw "Unable to find '$OdriveScript'"
30 | }
31 |
32 | if ((Get-Command "$Python" -ErrorAction SilentlyContinue) -eq $null) {
33 | throw "Unable to find '$Python' in your PATH"
34 | }
35 |
36 | Write-Host "Expanding every .cloudf folder placeholder..."
37 | $arglist = "-3 $PSScriptRoot\expand_every_cloudf.py -d `"$OdrivePath`" -e `"$FolderExpandExcludePattern`""
38 | Start-Process "C:\Windows\py" -ArgumentList $arglist -Wait -NoNewWindow
39 |
40 | function find_cloud_files([String]$path)
41 | {
42 | Write-Host "Gathering .cloud files in '$path'... Please wait... " -NoNewLine
43 | return ls -Include *.cloud* -Path $path -Recurse
44 | }
45 |
46 | if ($CloudFiles.length -eq 0) {
47 | $CloudFiles = find_cloud_files $OdrivePath
48 | }
49 |
50 | $global:number_of_files = $CloudFiles.length
51 | Write-Host "Found $global:number_of_files cloud files to sync"
52 |
53 | if ($JustFind) {
54 | Write-Host "JustFind was specified, so just returning the found files"
55 | return $CloudFiles
56 | }
57 |
58 | function update_status([uint32]$counter,
59 | [DateTime]$start_time,
60 | [String]$percent_string,
61 | [uint32]$done_counter,
62 | [uint32]$failed_counter,
63 | [uint32]$excluded_counter,
64 | [uint32]$total_count)
65 | {
66 | $time_format_string = "{0:dd\:hh\:mm\:ss\,fff}"
67 |
68 | $elapsed_sec = ((Get-Date) - $start_time).TotalSeconds
69 | $elapsed_ts = [timespan]::fromseconds($elapsed_sec)
70 | $elapsed_time = ($time_format_string -f $elapsed_ts)
71 |
72 | if ($counter -ne 0) {
73 | $avg_elapsed_sec_per_file = $elapsed_sec / $counter
74 | } else {
75 | $avg_elapsed_sec_per_file = [double]::PositiveInfinity
76 | }
77 | $files_left = $total_count - $counter
78 | $left_sec = $files_left * $avg_elapsed_sec_per_file
79 | if ([double]::IsInfinity($left_sec)) {
80 | $estimated_time_left = $left_sec
81 | } else {
82 | $estimate_ts = [timespan]::fromseconds($left_sec)
83 | $estimated_time_left = ($time_format_string -f $estimate_ts)
84 | }
85 |
86 | $status_format_string = "{0}% (done: {1}, failed: {2}, excluded: {3}, total: {4}," `
87 | + " elapsed: {5}, left: {6})"
88 | $status = $status_format_string -f $percent_string,
89 | $done_counter,
90 | $failed_counter,
91 | $excluded_counter,
92 | $total_count,
93 | $elapsed_time,
94 | $estimated_time_left
95 |
96 | return $status, $files_left
97 | }
98 |
99 | $global:processed_count = 0
100 | $global:percent = 0
101 | $global:fixed_width_rounded_percent = "0.00"
102 | $global:failed_count = 0
103 | $global:done_count = 0
104 | $global:excluded_count = 0
105 |
106 | function update_global_state()
107 | {
108 | $global:percent = ($global:processed_count / $global:number_of_files) * 100
109 | $global:fixed_width_rounded_percent = "{0:n2}" -f $global:percent
110 | $global:failed_count = $Error.Count
111 | $global:done_count = $global:processed_count - $global:failed_count
112 | }
113 |
114 | function is_excluded([String]$file_name,
115 | [String]$exclude_pattern,
116 | [String]$include_pattern)
117 | {
118 | if ($exclude_pattern -ne $null -and $file_name -match $exclude_pattern) {
119 | $exclude = $true
120 | } elseif ($include_pattern -ne $null -and -not ($file_name -match $include_pattern)) {
121 | $exclude = $true
122 | } else {
123 | $exclude = $false
124 | }
125 | return $exclude
126 | }
127 |
128 | try {
129 | $Error.clear()
130 | $jobs_started = 0
131 | $start_time = Get-Date
132 | foreach ($f in $CloudFiles) {
133 | $excluded = is_excluded $f $ExcludePattern $IncludePattern
134 | if ($excluded) {
135 | ++$global:excluded_count
136 | ++$global:processed_count
137 | }
138 |
139 | update_global_state
140 |
141 | if ($global:done_count -lt 0) {
142 | # account for leftover jobs, if the script was interrupted
143 | $global:done_count = 0
144 | $Error.clear()
145 | }
146 |
147 | $status, $files_left = update_status $global:processed_count `
148 | $start_time `
149 | $global:fixed_width_rounded_percent `
150 | $global:done_count `
151 | $global:failed_count `
152 | $global:excluded_count `
153 | $number_of_files
154 | $file = $f.FullName
155 |
156 | if ($excluded) {
157 | $message = "Excluding $file"
158 | } else {
159 | $message = "Syncing $file..."
160 | }
161 | Write-Progress -Activity $message -Status $status -PercentComplete $global:percent
162 |
163 | if ($excluded -and ($files_left -ne $jobs_started)) {
164 | continue
165 | }
166 |
167 | $command = {
168 | param($Python, $OdriveScript, $file)
169 | & $Python $OdriveScript sync $file
170 | }
171 |
172 | if ($global:multi_threaded) {
173 | if (!$excluded) {
174 | Start-Job $command -ArgumentList $Python, $OdriveScript, $file >$null
175 | ++$jobs_started
176 | }
177 |
178 | if (($jobs_started -eq $JobCount) -or ($files_left -eq $jobs_started)) {
179 | While (Get-Job -State "Running") {
180 | $match = Get-Job | Select State | Select-String "Running"
181 | $running = $match.count
182 | $finished_jobs = $jobs_started - $running
183 | $processed_files = $global:processed_count + $finished_jobs
184 | if ($processed_files -lt 0) {
185 | # account for leftover jobs, if the script was interrupted
186 | $processed_files = 0
187 | }
188 | $status, $files_left = update_status $processed_files `
189 | $start_time `
190 | $global:fixed_width_rounded_percent `
191 | $global:done_count `
192 | $global:failed_count `
193 | $global:excluded_count `
194 | $number_of_files
195 | Write-Progress -Activity "Waiting for $running job(s) to finish..." `
196 | -Status $status `
197 | -PercentComplete $global:percent
198 | Start-Sleep -Milliseconds 100
199 | }
200 |
201 | Get-Job | Receive-Job >$null 2>&1
202 |
203 | if ($LiveErrorReporting) {
204 | $Error > $ErrorFile
205 | }
206 |
207 | Remove-Job *
208 | $global:processed_count += $jobs_started
209 | $jobs_started = 0
210 | }
211 | } else {
212 | & $command $Python $OdriveScript $file >$null 2>&1
213 | ++$global:processed_count;
214 | }
215 | }
216 | } finally {
217 | try {
218 | update_global_state
219 |
220 | $status, $files_left = update_status $global:processed_count `
221 | $start_time `
222 | $global:fixed_width_rounded_percent `
223 | $global:done_count `
224 | $global:failed_count `
225 | $global:excluded_count `
226 | $number_of_files
227 | $sleep_time_in_sec_to_workaround_rubbish_write_progress = 1
228 | Start-Sleep -Seconds $sleep_time_in_sec_to_workaround_rubbish_write_progress
229 | Write-Progress -Activity "Done" -Status $status -PercentComplete $global:percent
230 | Write-Host $status
231 |
232 | if ($global:multi_threaded) {
233 | Write-Host "Removing finished jobs... " -NoNewLine
234 | Remove-Job * >$null 2>&1
235 | }
236 | } finally {
237 | if ($global:multi_threaded) {
238 | Write-Host "Done"
239 | }
240 |
241 | Write-Host "Capturing errors... " -NoNewLine
242 | Get-Job | Receive-Job >$null 2>&1
243 | $Error > $ErrorFile
244 | Write-Host "Done"
245 |
246 | if ($Error.Count -ne 0) {
247 | Write-Host "Errors were encountered (see $ErrorFile for details)"
248 | }
249 | }
250 | }
251 |
--------------------------------------------------------------------------------
/transmission_re_add_missing_torrents.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | # Helper script to alleviate the pain that this transmission issue causes:
3 | # https://github.com/transmission/transmission/issues/83
4 | # Try to use this script if you see $THE_ERROR. Good luck!
5 |
6 | set -euo pipefail # enable strict mode
7 |
8 | THE_ERROR='Error: No data found! Ensure your drives are connected or use "Set Location". To re-download, remove the torrent and re-add it.'
9 | TMP_DIR=/tmp
10 |
11 | tr_cmd=transmission-remote
12 | host=localhost
13 | port=9091
14 | user=
15 | password=
16 | torrents_dir=$HOME/.config/transmission-daemon/torrents
17 | torrent=
18 |
19 |
20 | #=============================================================================#
21 | ################ FUNCTIONS ################
22 | #=============================================================================#
23 |
24 | function show_usage
25 | {
26 | me=$(basename $0)
27 | echo """Usage: $me (Options)
28 |
29 | Try to remove and re-add torrents with '$THE_ERROR'.
30 |
31 | -u|--user USER a user with access to the transmission deamon
32 | -p|--password PASSWORD the user's password to access the transmission deamon
33 | -t|--torrent TORRENT_NAME operate on a single torrent; otherwise try to re-add every missing torrent
34 | -h|--help print this help message
35 |
36 | """
37 | }
38 |
39 | function re_add_torrent_from_info
40 | {
41 | name="$1"; shift
42 | id="$1"; shift
43 | info="$1"; shift
44 | tolerate_error="$1"; shift
45 |
46 | if [[ "$info" =~ $THE_ERROR ]]; then
47 | torrent_file=$(find . -name "$name*")
48 | echo "torrent file '$torrent_file' (<- empty == error!)"
49 | if [[ -z "$torrent_file" ]]; then
50 | if [[ $tolerate_error = true ]]; then
51 | echo "WARNING Failed to find the torrent file. SKIPPED"
52 | else
53 | exit 1
54 | fi
55 | else
56 | while IFS= read -r line; do
57 | if [[ $line =~ Location:[[:space:]]+([^[:space:]].+) ]]; then
58 | location="${BASH_REMATCH[1]}"
59 | break
60 | fi
61 | done <<< $info
62 | echo "location: '$location' (<- empty == error!)"
63 | if [[ -z "$location" ]]; then
64 | if [[ $tolerate_error = true ]]; then
65 | echo "WARNING Failed to find the torrent location. SKIPPED"
66 | else
67 | exit 1
68 | fi
69 | else
70 | tmp_torrent_file="$TMP_DIR/$(basename "$torrent_file")"
71 | echo "back up $torrent_file to $tmp_torrent_file..."
72 | cp -f "$torrent_file" "$tmp_torrent_file"
73 |
74 | re_add_cmd="$t --add \"$tmp_torrent_file\" --download-dir \"$location\""
75 | echo "TRY RE_ADD: '$re_add_cmd'"
76 | eval "$re_add_cmd"
77 |
78 | remove_cmd="$t -t $id --remove"
79 | echo "REMOVE: '$remove_cmd'"
80 | eval "$remove_cmd"
81 |
82 | echo "RE_ADD: '$re_add_cmd'"
83 | eval "$re_add_cmd"
84 | fi
85 | fi
86 | else
87 | echo SKIPPED
88 | fi
89 | }
90 |
91 | function re_add_torrent_from_line
92 | {
93 | torrent_line="$1"
94 | echo "$torrent_line"
95 |
96 | if [[ $torrent_line =~ ^[[:space:]]*([[:digit:]]+).*Stopped[[:space:]]+(.+) ]]; then
97 | id="${BASH_REMATCH[1]}"
98 | name="${BASH_REMATCH[2]}"
99 | else
100 | echo "Unexpected torrent line format!" >&2 && exit 1
101 | fi
102 | echo "id:'$id' name:'$name'"
103 |
104 | info=$($t -t $id --info)
105 | tolerate_error=true
106 |
107 | re_add_torrent_from_info "$name" "$id" "$info" "$tolerate_error"
108 | }
109 |
110 |
111 | #=============================================================================#
112 | ################ ARGPARSE ################
113 | #=============================================================================#
114 |
115 | while [[ $# -gt 0 ]]; do
116 | case $1 in
117 | -u|--user)
118 | user="$2"
119 | shift # past argument
120 | shift # past value
121 | ;;
122 | -p|--password)
123 | password="$2"
124 | shift # past argument
125 | shift # past value
126 | ;;
127 | -t|--torrent)
128 | torrent="$2"
129 | shift # past argument
130 | shift # past value
131 | ;;
132 | -h|--help)
133 | show_usage
134 | exit 0
135 | ;;
136 | *)
137 | echo "Unknown option $1"
138 | show_usage
139 | exit 1
140 | ;;
141 | esac
142 | done
143 |
144 | if [[ -z "$user" || -z "$password" ]]; then
145 | show_usage
146 | exit 1
147 | fi
148 |
149 |
150 | #=============================================================================#
151 | ################ MAIN ################
152 | #=============================================================================#
153 |
154 | t="$tr_cmd $host:$port --auth $user:$password"
155 | cd $torrents_dir
156 |
157 | if [[ -n "$torrent" ]]; then
158 | torrent_file=$(find . -name "$torrent*")
159 | hash_line=$(transmission-show $torrent_file | fgrep "Hash:")
160 | torrent_hash=$(echo $hash_line | cut -d' ' -f 2)
161 | info=$($t -t $torrent_hash --info)
162 | tolerate_error=false
163 |
164 | re_add_torrent_from_info "$torrent" "$torrent_hash" "$info" "$tolerate_error"
165 | else
166 | while IFS= read -r line; do
167 | re_add_torrent_from_line "$line"
168 | done < <($t --list | grep Stopped | grep Done)
169 | fi
170 |
171 |
--------------------------------------------------------------------------------
/utils.ps1:
--------------------------------------------------------------------------------
1 | Function pause ($message)
2 | {
3 | # Check if running Powershell ISE
4 | if ($psISE) {
5 | Add-Type -AssemblyName System.Windows.Forms
6 | [System.Windows.Forms.MessageBox]::Show("$message")
7 | } else {
8 | Write-Host "$message" -ForegroundColor Yellow
9 | $x = $host.ui.RawUI.ReadKey("NoEcho,IncludeKeyDown")
10 | }
11 | }
--------------------------------------------------------------------------------