[
  {
    "path": ".github/workflows/python-package.yaml",
    "content": "# This workflow will install Python dependencies, run tests and lint with a variety of Python versions\n# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python\n\nname: Python package\n\non:\n  push:\n    branches: [ \"master\" ]\n  pull_request:\n    branches: [ \"master\" ]\n\njobs:\n  build:\n\n    runs-on: ubuntu-latest\n    strategy:\n      fail-fast: false\n      matrix:\n        python-version: [\"3.12\", \"3.13\"]\n\n    steps:\n    - uses: actions/checkout@v4\n    - name: Set up Python ${{ matrix.python-version }}\n      uses: actions/setup-python@v3\n      with:\n        python-version: ${{ matrix.python-version }}\n    - name: Install dependencies\n      run: |\n        python -m pip install --upgrade pip\n        python -m pip install flake8 pytest build\n        if [ -f requirements.txt ]; then pip install -r requirements.txt; fi\n    - name: Lint with flake8\n      run: |\n        # stop the build if there are Python syntax errors or undefined names\n        flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics\n        # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide\n        # flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics\n    - name: Build\n      run: |\n        python -m build\n    # - name: Test with pytest\n    #   run: |\n    #     pytest\n"
  },
  {
    "path": ".gitignore",
    "content": "secrets.cfg\n# Byte-compiled / optimized / DLL files\n__pycache__/\n*.py[cod]\n*$py.class\n\n# C extensions\n*.so\n\n# Distribution / packaging\n.Python\nenv/\nbuild/\ndevelop-eggs/\ndist/\ndownloads/\neggs/\n.eggs/\nlib/\nlib64/\nparts/\nsdist/\nvar/\n*.egg-info/\n.installed.cfg\n*.egg\n\n# PyInstaller\n#  Usually these files are written by a python script from a template\n#  before PyInstaller builds the exe, so as to inject date/other infos into it.\n*.manifest\n*.spec\n\n# Installer logs\npip-log.txt\npip-delete-this-directory.txt\n\n# Unit test / coverage reports\nhtmlcov/\n.tox/\n.coverage\n.coverage.*\n.cache\nnosetests.xml\ncoverage.xml\n*,cover\n\n# Translations\n*.mo\n*.pot\n\n# Django stuff:\n*.log\n\n# Sphinx documentation\ndocs/_build/\n\n# PyBuilder\ntarget/\n\n.idea/\nvenv/"
  },
  {
    "path": "LICENSE.md",
    "content": "\n                    GNU GENERAL PUBLIC LICENSE\n                       Version 3, 29 June 2007\n\n Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>\n Everyone is permitted to copy and distribute verbatim copies\n of this license document, but changing it is not allowed.\n\n                            Preamble\n\n  The GNU General Public License is a free, copyleft license for\nsoftware and other kinds of works.\n\n  The licenses for most software and other practical works are designed\nto take away your freedom to share and change the works.  By contrast,\nthe GNU General Public License is intended to guarantee your freedom to\nshare and change all versions of a program--to make sure it remains free\nsoftware for all its users.  We, the Free Software Foundation, use the\nGNU General Public License for most of our software; it applies also to\nany other work released this way by its authors.  You can apply it to\nyour programs, too.\n\n  When we speak of free software, we are referring to freedom, not\nprice.  Our General Public Licenses are designed to make sure that you\nhave the freedom to distribute copies of free software (and charge for\nthem if you wish), that you receive source code or can get it if you\nwant it, that you can change the software or use pieces of it in new\nfree programs, and that you know you can do these things.\n\n  To protect your rights, we need to prevent others from denying you\nthese rights or asking you to surrender the rights.  Therefore, you have\ncertain responsibilities if you distribute copies of the software, or if\nyou modify it: responsibilities to respect the freedom of others.\n\n  For example, if you distribute copies of such a program, whether\ngratis or for a fee, you must pass on to the recipients the same\nfreedoms that you received.  You must make sure that they, too, receive\nor can get the source code.  And you must show them these terms so they\nknow their rights.\n\n  Developers that use the GNU GPL protect your rights with two steps:\n(1) assert copyright on the software, and (2) offer you this License\ngiving you legal permission to copy, distribute and/or modify it.\n\n  For the developers' and authors' protection, the GPL clearly explains\nthat there is no warranty for this free software.  For both users' and\nauthors' sake, the GPL requires that modified versions be marked as\nchanged, so that their problems will not be attributed erroneously to\nauthors of previous versions.\n\n  Some devices are designed to deny users access to install or run\nmodified versions of the software inside them, although the manufacturer\ncan do so.  This is fundamentally incompatible with the aim of\nprotecting users' freedom to change the software.  The systematic\npattern of such abuse occurs in the area of products for individuals to\nuse, which is precisely where it is most unacceptable.  Therefore, we\nhave designed this version of the GPL to prohibit the practice for those\nproducts.  If such problems arise substantially in other domains, we\nstand ready to extend this provision to those domains in future versions\nof the GPL, as needed to protect the freedom of users.\n\n  Finally, every program is threatened constantly by software patents.\nStates should not allow patents to restrict development and use of\nsoftware on general-purpose computers, but in those that do, we wish to\navoid the special danger that patents applied to a free program could\nmake it effectively proprietary.  To prevent this, the GPL assures that\npatents cannot be used to render the program non-free.\n\n  The precise terms and conditions for copying, distribution and\nmodification follow.\n\n                       TERMS AND CONDITIONS\n\n  0. Definitions.\n\n  \"This License\" refers to version 3 of the GNU General Public License.\n\n  \"Copyright\" also means copyright-like laws that apply to other kinds of\nworks, such as semiconductor masks.\n\n  \"The Program\" refers to any copyrightable work licensed under this\nLicense.  Each licensee is addressed as \"you\".  \"Licensees\" and\n\"recipients\" may be individuals or organizations.\n\n  To \"modify\" a work means to copy from or adapt all or part of the work\nin a fashion requiring copyright permission, other than the making of an\nexact copy.  The resulting work is called a \"modified version\" of the\nearlier work or a work \"based on\" the earlier work.\n\n  A \"covered work\" means either the unmodified Program or a work based\non the Program.\n\n  To \"propagate\" a work means to do anything with it that, without\npermission, would make you directly or secondarily liable for\ninfringement under applicable copyright law, except executing it on a\ncomputer or modifying a private copy.  Propagation includes copying,\ndistribution (with or without modification), making available to the\npublic, and in some countries other activities as well.\n\n  To \"convey\" a work means any kind of propagation that enables other\nparties to make or receive copies.  Mere interaction with a user through\na computer network, with no transfer of a copy, is not conveying.\n\n  An interactive user interface displays \"Appropriate Legal Notices\"\nto the extent that it includes a convenient and prominently visible\nfeature that (1) displays an appropriate copyright notice, and (2)\ntells the user that there is no warranty for the work (except to the\nextent that warranties are provided), that licensees may convey the\nwork under this License, and how to view a copy of this License.  If\nthe interface presents a list of user commands or options, such as a\nmenu, a prominent item in the list meets this criterion.\n\n  1. Source Code.\n\n  The \"source code\" for a work means the preferred form of the work\nfor making modifications to it.  \"Object code\" means any non-source\nform of a work.\n\n  A \"Standard Interface\" means an interface that either is an official\nstandard defined by a recognized standards body, or, in the case of\ninterfaces specified for a particular programming language, one that\nis widely used among developers working in that language.\n\n  The \"System Libraries\" of an executable work include anything, other\nthan the work as a whole, that (a) is included in the normal form of\npackaging a Major Component, but which is not part of that Major\nComponent, and (b) serves only to enable use of the work with that\nMajor Component, or to implement a Standard Interface for which an\nimplementation is available to the public in source code form.  A\n\"Major Component\", in this context, means a major essential component\n(kernel, window system, and so on) of the specific operating system\n(if any) on which the executable work runs, or a compiler used to\nproduce the work, or an object code interpreter used to run it.\n\n  The \"Corresponding Source\" for a work in object code form means all\nthe source code needed to generate, install, and (for an executable\nwork) run the object code and to modify the work, including scripts to\ncontrol those activities.  However, it does not include the work's\nSystem Libraries, or general-purpose tools or generally available free\nprograms which are used unmodified in performing those activities but\nwhich are not part of the work.  For example, Corresponding Source\nincludes interface definition files associated with source files for\nthe work, and the source code for shared libraries and dynamically\nlinked subprograms that the work is specifically designed to require,\nsuch as by intimate data communication or control flow between those\nsubprograms and other parts of the work.\n\n  The Corresponding Source need not include anything that users\ncan regenerate automatically from other parts of the Corresponding\nSource.\n\n  The Corresponding Source for a work in source code form is that\nsame work.\n\n  2. Basic Permissions.\n\n  All rights granted under this License are granted for the term of\ncopyright on the Program, and are irrevocable provided the stated\nconditions are met.  This License explicitly affirms your unlimited\npermission to run the unmodified Program.  The output from running a\ncovered work is covered by this License only if the output, given its\ncontent, constitutes a covered work.  This License acknowledges your\nrights of fair use or other equivalent, as provided by copyright law.\n\n  You may make, run and propagate covered works that you do not\nconvey, without conditions so long as your license otherwise remains\nin force.  You may convey covered works to others for the sole purpose\nof having them make modifications exclusively for you, or provide you\nwith facilities for running those works, provided that you comply with\nthe terms of this License in conveying all material for which you do\nnot control copyright.  Those thus making or running the covered works\nfor you must do so exclusively on your behalf, under your direction\nand control, on terms that prohibit them from making any copies of\nyour copyrighted material outside their relationship with you.\n\n  Conveying under any other circumstances is permitted solely under\nthe conditions stated below.  Sublicensing is not allowed; section 10\nmakes it unnecessary.\n\n  3. Protecting Users' Legal Rights From Anti-Circumvention Law.\n\n  No covered work shall be deemed part of an effective technological\nmeasure under any applicable law fulfilling obligations under article\n11 of the WIPO copyright treaty adopted on 20 December 1996, or\nsimilar laws prohibiting or restricting circumvention of such\nmeasures.\n\n  When you convey a covered work, you waive any legal power to forbid\ncircumvention of technological measures to the extent such circumvention\nis effected by exercising rights under this License with respect to\nthe covered work, and you disclaim any intention to limit operation or\nmodification of the work as a means of enforcing, against the work's\nusers, your or third parties' legal rights to forbid circumvention of\ntechnological measures.\n\n  4. Conveying Verbatim Copies.\n\n  You may convey verbatim copies of the Program's source code as you\nreceive it, in any medium, provided that you conspicuously and\nappropriately publish on each copy an appropriate copyright notice;\nkeep intact all notices stating that this License and any\nnon-permissive terms added in accord with section 7 apply to the code;\nkeep intact all notices of the absence of any warranty; and give all\nrecipients a copy of this License along with the Program.\n\n  You may charge any price or no price for each copy that you convey,\nand you may offer support or warranty protection for a fee.\n\n  5. Conveying Modified Source Versions.\n\n  You may convey a work based on the Program, or the modifications to\nproduce it from the Program, in the form of source code under the\nterms of section 4, provided that you also meet all of these conditions:\n\n    a) The work must carry prominent notices stating that you modified\n    it, and giving a relevant date.\n\n    b) The work must carry prominent notices stating that it is\n    released under this License and any conditions added under section\n    7.  This requirement modifies the requirement in section 4 to\n    \"keep intact all notices\".\n\n    c) You must license the entire work, as a whole, under this\n    License to anyone who comes into possession of a copy.  This\n    License will therefore apply, along with any applicable section 7\n    additional terms, to the whole of the work, and all its parts,\n    regardless of how they are packaged.  This License gives no\n    permission to license the work in any other way, but it does not\n    invalidate such permission if you have separately received it.\n\n    d) If the work has interactive user interfaces, each must display\n    Appropriate Legal Notices; however, if the Program has interactive\n    interfaces that do not display Appropriate Legal Notices, your\n    work need not make them do so.\n\n  A compilation of a covered work with other separate and independent\nworks, which are not by their nature extensions of the covered work,\nand which are not combined with it such as to form a larger program,\nin or on a volume of a storage or distribution medium, is called an\n\"aggregate\" if the compilation and its resulting copyright are not\nused to limit the access or legal rights of the compilation's users\nbeyond what the individual works permit.  Inclusion of a covered work\nin an aggregate does not cause this License to apply to the other\nparts of the aggregate.\n\n  6. Conveying Non-Source Forms.\n\n  You may convey a covered work in object code form under the terms\nof sections 4 and 5, provided that you also convey the\nmachine-readable Corresponding Source under the terms of this License,\nin one of these ways:\n\n    a) Convey the object code in, or embodied in, a physical product\n    (including a physical distribution medium), accompanied by the\n    Corresponding Source fixed on a durable physical medium\n    customarily used for software interchange.\n\n    b) Convey the object code in, or embodied in, a physical product\n    (including a physical distribution medium), accompanied by a\n    written offer, valid for at least three years and valid for as\n    long as you offer spare parts or customer support for that product\n    model, to give anyone who possesses the object code either (1) a\n    copy of the Corresponding Source for all the software in the\n    product that is covered by this License, on a durable physical\n    medium customarily used for software interchange, for a price no\n    more than your reasonable cost of physically performing this\n    conveying of source, or (2) access to copy the\n    Corresponding Source from a network server at no charge.\n\n    c) Convey individual copies of the object code with a copy of the\n    written offer to provide the Corresponding Source.  This\n    alternative is allowed only occasionally and noncommercially, and\n    only if you received the object code with such an offer, in accord\n    with subsection 6b.\n\n    d) Convey the object code by offering access from a designated\n    place (gratis or for a charge), and offer equivalent access to the\n    Corresponding Source in the same way through the same place at no\n    further charge.  You need not require recipients to copy the\n    Corresponding Source along with the object code.  If the place to\n    copy the object code is a network server, the Corresponding Source\n    may be on a different server (operated by you or a third party)\n    that supports equivalent copying facilities, provided you maintain\n    clear directions next to the object code saying where to find the\n    Corresponding Source.  Regardless of what server hosts the\n    Corresponding Source, you remain obligated to ensure that it is\n    available for as long as needed to satisfy these requirements.\n\n    e) Convey the object code using peer-to-peer transmission, provided\n    you inform other peers where the object code and Corresponding\n    Source of the work are being offered to the general public at no\n    charge under subsection 6d.\n\n  A separable portion of the object code, whose source code is excluded\nfrom the Corresponding Source as a System Library, need not be\nincluded in conveying the object code work.\n\n  A \"User Product\" is either (1) a \"consumer product\", which means any\ntangible personal property which is normally used for personal, family,\nor household purposes, or (2) anything designed or sold for incorporation\ninto a dwelling.  In determining whether a product is a consumer product,\ndoubtful cases shall be resolved in favor of coverage.  For a particular\nproduct received by a particular user, \"normally used\" refers to a\ntypical or common use of that class of product, regardless of the status\nof the particular user or of the way in which the particular user\nactually uses, or expects or is expected to use, the product.  A product\nis a consumer product regardless of whether the product has substantial\ncommercial, industrial or non-consumer uses, unless such uses represent\nthe only significant mode of use of the product.\n\n  \"Installation Information\" for a User Product means any methods,\nprocedures, authorization keys, or other information required to install\nand execute modified versions of a covered work in that User Product from\na modified version of its Corresponding Source.  The information must\nsuffice to ensure that the continued functioning of the modified object\ncode is in no case prevented or interfered with solely because\nmodification has been made.\n\n  If you convey an object code work under this section in, or with, or\nspecifically for use in, a User Product, and the conveying occurs as\npart of a transaction in which the right of possession and use of the\nUser Product is transferred to the recipient in perpetuity or for a\nfixed term (regardless of how the transaction is characterized), the\nCorresponding Source conveyed under this section must be accompanied\nby the Installation Information.  But this requirement does not apply\nif neither you nor any third party retains the ability to install\nmodified object code on the User Product (for example, the work has\nbeen installed in ROM).\n\n  The requirement to provide Installation Information does not include a\nrequirement to continue to provide support service, warranty, or updates\nfor a work that has been modified or installed by the recipient, or for\nthe User Product in which it has been modified or installed.  Access to a\nnetwork may be denied when the modification itself materially and\nadversely affects the operation of the network or violates the rules and\nprotocols for communication across the network.\n\n  Corresponding Source conveyed, and Installation Information provided,\nin accord with this section must be in a format that is publicly\ndocumented (and with an implementation available to the public in\nsource code form), and must require no special password or key for\nunpacking, reading or copying.\n\n  7. Additional Terms.\n\n  \"Additional permissions\" are terms that supplement the terms of this\nLicense by making exceptions from one or more of its conditions.\nAdditional permissions that are applicable to the entire Program shall\nbe treated as though they were included in this License, to the extent\nthat they are valid under applicable law.  If additional permissions\napply only to part of the Program, that part may be used separately\nunder those permissions, but the entire Program remains governed by\nthis License without regard to the additional permissions.\n\n  When you convey a copy of a covered work, you may at your option\nremove any additional permissions from that copy, or from any part of\nit.  (Additional permissions may be written to require their own\nremoval in certain cases when you modify the work.)  You may place\nadditional permissions on material, added by you to a covered work,\nfor which you have or can give appropriate copyright permission.\n\n  Notwithstanding any other provision of this License, for material you\nadd to a covered work, you may (if authorized by the copyright holders of\nthat material) supplement the terms of this License with terms:\n\n    a) Disclaiming warranty or limiting liability differently from the\n    terms of sections 15 and 16 of this License; or\n\n    b) Requiring preservation of specified reasonable legal notices or\n    author attributions in that material or in the Appropriate Legal\n    Notices displayed by works containing it; or\n\n    c) Prohibiting misrepresentation of the origin of that material, or\n    requiring that modified versions of such material be marked in\n    reasonable ways as different from the original version; or\n\n    d) Limiting the use for publicity purposes of names of licensors or\n    authors of the material; or\n\n    e) Declining to grant rights under trademark law for use of some\n    trade names, trademarks, or service marks; or\n\n    f) Requiring indemnification of licensors and authors of that\n    material by anyone who conveys the material (or modified versions of\n    it) with contractual assumptions of liability to the recipient, for\n    any liability that these contractual assumptions directly impose on\n    those licensors and authors.\n\n  All other non-permissive additional terms are considered \"further\nrestrictions\" within the meaning of section 10.  If the Program as you\nreceived it, or any part of it, contains a notice stating that it is\ngoverned by this License along with a term that is a further\nrestriction, you may remove that term.  If a license document contains\na further restriction but permits relicensing or conveying under this\nLicense, you may add to a covered work material governed by the terms\nof that license document, provided that the further restriction does\nnot survive such relicensing or conveying.\n\n  If you add terms to a covered work in accord with this section, you\nmust place, in the relevant source files, a statement of the\nadditional terms that apply to those files, or a notice indicating\nwhere to find the applicable terms.\n\n  Additional terms, permissive or non-permissive, may be stated in the\nform of a separately written license, or stated as exceptions;\nthe above requirements apply either way.\n\n  8. Termination.\n\n  You may not propagate or modify a covered work except as expressly\nprovided under this License.  Any attempt otherwise to propagate or\nmodify it is void, and will automatically terminate your rights under\nthis License (including any patent licenses granted under the third\nparagraph of section 11).\n\n  However, if you cease all violation of this License, then your\nlicense from a particular copyright holder is reinstated (a)\nprovisionally, unless and until the copyright holder explicitly and\nfinally terminates your license, and (b) permanently, if the copyright\nholder fails to notify you of the violation by some reasonable means\nprior to 60 days after the cessation.\n\n  Moreover, your license from a particular copyright holder is\nreinstated permanently if the copyright holder notifies you of the\nviolation by some reasonable means, this is the first time you have\nreceived notice of violation of this License (for any work) from that\ncopyright holder, and you cure the violation prior to 30 days after\nyour receipt of the notice.\n\n  Termination of your rights under this section does not terminate the\nlicenses of parties who have received copies or rights from you under\nthis License.  If your rights have been terminated and not permanently\nreinstated, you do not qualify to receive new licenses for the same\nmaterial under section 10.\n\n  9. Acceptance Not Required for Having Copies.\n\n  You are not required to accept this License in order to receive or\nrun a copy of the Program.  Ancillary propagation of a covered work\noccurring solely as a consequence of using peer-to-peer transmission\nto receive a copy likewise does not require acceptance.  However,\nnothing other than this License grants you permission to propagate or\nmodify any covered work.  These actions infringe copyright if you do\nnot accept this License.  Therefore, by modifying or propagating a\ncovered work, you indicate your acceptance of this License to do so.\n\n  10. Automatic Licensing of Downstream Recipients.\n\n  Each time you convey a covered work, the recipient automatically\nreceives a license from the original licensors, to run, modify and\npropagate that work, subject to this License.  You are not responsible\nfor enforcing compliance by third parties with this License.\n\n  An \"entity transaction\" is a transaction transferring control of an\norganization, or substantially all assets of one, or subdividing an\norganization, or merging organizations.  If propagation of a covered\nwork results from an entity transaction, each party to that\ntransaction who receives a copy of the work also receives whatever\nlicenses to the work the party's predecessor in interest had or could\ngive under the previous paragraph, plus a right to possession of the\nCorresponding Source of the work from the predecessor in interest, if\nthe predecessor has it or can get it with reasonable efforts.\n\n  You may not impose any further restrictions on the exercise of the\nrights granted or affirmed under this License.  For example, you may\nnot impose a license fee, royalty, or other charge for exercise of\nrights granted under this License, and you may not initiate litigation\n(including a cross-claim or counterclaim in a lawsuit) alleging that\nany patent claim is infringed by making, using, selling, offering for\nsale, or importing the Program or any portion of it.\n\n  11. Patents.\n\n  A \"contributor\" is a copyright holder who authorizes use under this\nLicense of the Program or a work on which the Program is based.  The\nwork thus licensed is called the contributor's \"contributor version\".\n\n  A contributor's \"essential patent claims\" are all patent claims\nowned or controlled by the contributor, whether already acquired or\nhereafter acquired, that would be infringed by some manner, permitted\nby this License, of making, using, or selling its contributor version,\nbut do not include claims that would be infringed only as a\nconsequence of further modification of the contributor version.  For\npurposes of this definition, \"control\" includes the right to grant\npatent sublicenses in a manner consistent with the requirements of\nthis License.\n\n  Each contributor grants you a non-exclusive, worldwide, royalty-free\npatent license under the contributor's essential patent claims, to\nmake, use, sell, offer for sale, import and otherwise run, modify and\npropagate the contents of its contributor version.\n\n  In the following three paragraphs, a \"patent license\" is any express\nagreement or commitment, however denominated, not to enforce a patent\n(such as an express permission to practice a patent or covenant not to\nsue for patent infringement).  To \"grant\" such a patent license to a\nparty means to make such an agreement or commitment not to enforce a\npatent against the party.\n\n  If you convey a covered work, knowingly relying on a patent license,\nand the Corresponding Source of the work is not available for anyone\nto copy, free of charge and under the terms of this License, through a\npublicly available network server or other readily accessible means,\nthen you must either (1) cause the Corresponding Source to be so\navailable, or (2) arrange to deprive yourself of the benefit of the\npatent license for this particular work, or (3) arrange, in a manner\nconsistent with the requirements of this License, to extend the patent\nlicense to downstream recipients.  \"Knowingly relying\" means you have\nactual knowledge that, but for the patent license, your conveying the\ncovered work in a country, or your recipient's use of the covered work\nin a country, would infringe one or more identifiable patents in that\ncountry that you have reason to believe are valid.\n\n  If, pursuant to or in connection with a single transaction or\narrangement, you convey, or propagate by procuring conveyance of, a\ncovered work, and grant a patent license to some of the parties\nreceiving the covered work authorizing them to use, propagate, modify\nor convey a specific copy of the covered work, then the patent license\nyou grant is automatically extended to all recipients of the covered\nwork and works based on it.\n\n  A patent license is \"discriminatory\" if it does not include within\nthe scope of its coverage, prohibits the exercise of, or is\nconditioned on the non-exercise of one or more of the rights that are\nspecifically granted under this License.  You may not convey a covered\nwork if you are a party to an arrangement with a third party that is\nin the business of distributing software, under which you make payment\nto the third party based on the extent of your activity of conveying\nthe work, and under which the third party grants, to any of the\nparties who would receive the covered work from you, a discriminatory\npatent license (a) in connection with copies of the covered work\nconveyed by you (or copies made from those copies), or (b) primarily\nfor and in connection with specific products or compilations that\ncontain the covered work, unless you entered into that arrangement,\nor that patent license was granted, prior to 28 March 2007.\n\n  Nothing in this License shall be construed as excluding or limiting\nany implied license or other defenses to infringement that may\notherwise be available to you under applicable patent law.\n\n  12. No Surrender of Others' Freedom.\n\n  If conditions are imposed on you (whether by court order, agreement or\notherwise) that contradict the conditions of this License, they do not\nexcuse you from the conditions of this License.  If you cannot convey a\ncovered work so as to satisfy simultaneously your obligations under this\nLicense and any other pertinent obligations, then as a consequence you may\nnot convey it at all.  For example, if you agree to terms that obligate you\nto collect a royalty for further conveying from those to whom you convey\nthe Program, the only way you could satisfy both those terms and this\nLicense would be to refrain entirely from conveying the Program.\n\n  13. Use with the GNU Affero General Public License.\n\n  Notwithstanding any other provision of this License, you have\npermission to link or combine any covered work with a work licensed\nunder version 3 of the GNU Affero General Public License into a single\ncombined work, and to convey the resulting work.  The terms of this\nLicense will continue to apply to the part which is the covered work,\nbut the special requirements of the GNU Affero General Public License,\nsection 13, concerning interaction through a network will apply to the\ncombination as such.\n\n  14. Revised Versions of this License.\n\n  The Free Software Foundation may publish revised and/or new versions of\nthe GNU General Public License from time to time.  Such new versions will\nbe similar in spirit to the present version, but may differ in detail to\naddress new problems or concerns.\n\n  Each version is given a distinguishing version number.  If the\nProgram specifies that a certain numbered version of the GNU General\nPublic License \"or any later version\" applies to it, you have the\noption of following the terms and conditions either of that numbered\nversion or of any later version published by the Free Software\nFoundation.  If the Program does not specify a version number of the\nGNU General Public License, you may choose any version ever published\nby the Free Software Foundation.\n\n  If the Program specifies that a proxy can decide which future\nversions of the GNU General Public License can be used, that proxy's\npublic statement of acceptance of a version permanently authorizes you\nto choose that version for the Program.\n\n  Later license versions may give you additional or different\npermissions.  However, no additional obligations are imposed on any\nauthor or copyright holder as a result of your choosing to follow a\nlater version.\n\n  15. Disclaimer of Warranty.\n\n  THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY\nAPPLICABLE LAW.  EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT\nHOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM \"AS IS\" WITHOUT WARRANTY\nOF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,\nTHE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\nPURPOSE.  THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM\nIS WITH YOU.  SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF\nALL NECESSARY SERVICING, REPAIR OR CORRECTION.\n\n  16. Limitation of Liability.\n\n  IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING\nWILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS\nTHE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY\nGENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE\nUSE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF\nDATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD\nPARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),\nEVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF\nSUCH DAMAGES.\n\n  17. Interpretation of Sections 15 and 16.\n\n  If the disclaimer of warranty and limitation of liability provided\nabove cannot be given local legal effect according to their terms,\nreviewing courts shall apply local law that most closely approximates\nan absolute waiver of all civil liability in connection with the\nProgram, unless a warranty or assumption of liability accompanies a\ncopy of the Program in return for a fee.\n\n                     END OF TERMS AND CONDITIONS\n\n            How to Apply These Terms to Your New Programs\n\n  If you develop a new program, and you want it to be of the greatest\npossible use to the public, the best way to achieve this is to make it\nfree software which everyone can redistribute and change under these terms.\n\n  To do so, attach the following notices to the program.  It is safest\nto attach them to the start of each source file to most effectively\nstate the exclusion of warranty; and each file should have at least\nthe \"copyright\" line and a pointer to where the full notice is found.\n\n    <one line to give the program's name and a brief idea of what it does.>\n    Copyright (C) <year>  <name of author>\n\n    This program is free software: you can redistribute it and/or modify\n    it under the terms of the GNU General Public License as published by\n    the Free Software Foundation, either version 3 of the License, or\n    (at your option) any later version.\n\n    This program is distributed in the hope that it will be useful,\n    but WITHOUT ANY WARRANTY; without even the implied warranty of\n    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n    GNU General Public License for more details.\n\n    You should have received a copy of the GNU General Public License\n    along with this program.  If not, see <http://www.gnu.org/licenses/>.\n\nAlso add information on how to contact you by electronic and paper mail.\n\n  If the program does terminal interaction, make it output a short\nnotice like this when it starts in an interactive mode:\n\n    {project}  Copyright (C) {year}  {fullname}\n    This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.\n    This is free software, and you are welcome to redistribute it\n    under certain conditions; type `show c' for details.\n\nThe hypothetical commands `show w' and `show c' should show the appropriate\nparts of the General Public License.  Of course, your program's commands\nmight be different; for a GUI interface, you would use an \"about box\".\n\n  You should also get your employer (if you work as a programmer) or school,\nif any, to sign a \"copyright disclaimer\" for the program, if necessary.\nFor more information on this, and how to apply and follow the GNU GPL, see\n<http://www.gnu.org/licenses/>.\n\n  The GNU General Public License does not permit incorporating your program\ninto proprietary programs.  If your program is a subroutine library, you\nmay consider it more useful to permit linking proprietary applications with\nthe library.  If this is what you want to do, use the GNU Lesser General\nPublic License instead of this License.  But first, please read\n<http://www.gnu.org/philosophy/why-not-lgpl.html>.\n"
  },
  {
    "path": "Pipfile",
    "content": "[[source]]\nname = \"pypi\"\nurl = \"https://pypi.org/simple\"\nverify_ssl = true\n\n[dev-packages]\n\n[packages]\npillow = \"*\"\npyyaml = \"*\"\nrequests = \"*\"\nnumpy = \"*\"\nopencv-python = \"*\"\npysocks = \"*\"\n\n[requires]\n"
  },
  {
    "path": "README.md",
    "content": "<h1 align=\"center\"> Reolink Python Api Client </h1>\n\n<p align=\"center\">\n <img alt=\"Reolink Approval\" src=\"https://img.shields.io/badge/reolink-approved-blue?style=flat-square\">\n <img alt=\"GitHub\" src=\"https://img.shields.io/github/license/ReolinkCameraAPI/reolinkapipy?style=flat-square\">\n <img alt=\"GitHub tag (latest SemVer)\" src=\"https://img.shields.io/github/v/tag/ReolinkCameraAPI/reolinkapipy?style=flat-square\">\n <img alt=\"PyPI\" src=\"https://img.shields.io/pypi/v/reolinkapi?style=flat-square\">\n <img alt=\"Discord\" src=\"https://img.shields.io/discord/773257004911034389?style=flat-square\">\n</p>\n\n---\n\nA Reolink Camera client written in Python. This repository's purpose **(with Reolink's full support)** is to deliver a complete API for the Reolink Cameras,\nalthough they have a basic API document - it does not satisfy the need for extensive camera communication.\n\nCheck out our documentation for more information on how to use the software at [https://reolink.oleaintueri.com](https://reolink.oleaintueri.com)\n\n\nOther Supported Languages:\n - Go: [reolinkapigo](https://github.com/ReolinkCameraAPI/reolinkapigo)\n\n### Join us on Discord\n\n    https://discord.gg/8z3fdAmZJP\n    \n\n### Sponsorship\n\n<a href=\"https://oleaintueri.com\"><img src=\"https://oleaintueri.com/images/oliv.svg\" width=\"60px\"/><img width=\"200px\" style=\"padding-bottom: 10px\" src=\"https://oleaintueri.com/images/oleaintueri.svg\"/></a>\n\n[Oleaintueri](https://oleaintueri.com) is sponsoring the development and maintenance of these projects within their organisation.\n\n\n---\n\n### Get started\n\nImplement a \"Camera\" object by passing it an IP address, Username and Password. By instantiating the object, it will try retrieve a login token from the Reolink Camera. This token is necessary to interact with the Camera using other commands.\n\nSee the `examples` directory.\n\n### Using the library as a Python Module\n\nInstall the package via PyPi\n\n    pip install reolinkapi\n\nInstall from GitHub\n\n    pip install git+https://github.com/ReolinkCameraAPI/reolinkapipy.git\n\nIf you want to include the video streaming functionality you need to include the streaming \"extra\" dependencies\n\n    pip install 'reolinkapi[streaming]'\n    \n## Contributors\n\n---\n\n### Styling and Standards\n\nThis project intends to stick with [PEP8](https://www.python.org/dev/peps/pep-0008/)\n\n### How can I become a contributor?\n\n#### Step 1\n\nGet the Restful API calls by looking through the HTTP Requests made in the camera's web UI. I use Google Chrome developer mode (ctr + shift + i) -> Network.\n\n#### Step 2\n\n- Fork the repository\n- pip install -r requirements.txt\n- Make your changes\n\n#### Step 3\n\nMake a pull request.\n\n### API Requests Implementation Plan:\n\nStream:\n- [X] Blocking RTSP stream\n- [X] Non-Blocking RTSP stream\n\nGET:\n- [X] Login\n- [X] Logout\n- [X] Display -> OSD\n- [X] Recording -> Encode (Clear and Fluent Stream)\n- [X] Recording -> Advance (Scheduling)\n- [X] Network -> General\n- [X] Network -> Advanced\n- [X] Network -> DDNS\n- [X] Network -> NTP\n- [X] Network -> E-mail\n- [X] Network -> FTP\n- [X] Network -> Push\n- [X] Network -> WIFI\n- [X] Alarm -> Motion\n- [X] System -> General\n- [X] System -> DST\n- [X] System -> Information\n- [ ] System -> Maintenance\n- [X] System -> Performance\n- [ ] System -> Reboot\n- [X] User -> Online User\n- [X] User -> Add User\n- [X] User -> Manage User\n- [X] Device -> HDD/SD Card\n- [x] PTZ -> Presets, Calibration Status\n- [x] Zoom\n- [x] Focus\n- [ ] Image (Brightness, Contrast, Saturation, Hue, Sharp, Mirror, Rotate)\n- [ ] Advanced Image (Anti-flicker, Exposure, White Balance, DayNight, Backlight, LED light, 3D-NR)\n- [X] Image Data -> \"Snap\" Frame from Video Stream\n\nSET:\n- [X] Display -> OSD\n- [X] Recording -> Encode (Clear and Fluent Stream)\n- [ ] Recording -> Advance (Scheduling)\n- [X] Network -> General\n- [X] Network -> Advanced\n- [ ] Network -> DDNS\n- [ ] Network -> NTP\n- [ ] Network -> E-mail\n- [ ] Network -> FTP\n- [ ] Network -> Push\n- [X] Network -> WIFI\n- [ ] Alarm -> Motion\n- [ ] System -> General\n- [ ] System -> DST\n- [X] System -> Reboot\n- [X] User -> Online User\n- [X] User -> Add User\n- [X] User -> Manage User\n- [X] Device -> HDD/SD Card (Format)\n- [x] PTZ (including calibrate)\n- [x] Zoom\n- [x] Focus\n- [X] Image (Brightness, Contrast, Saturation, Hue, Sharp, Mirror, Rotate)\n- [X] Advanced Image (Anti-flicker, Exposure, White Balance, DayNight, Backlight, LED light, 3D-NR)\n\n### Supported Cameras\n\nAny Reolink camera that has a web UI should work. The other's requiring special Reolink clients\ndo not work and is not supported here.\n\n- RLC-411WS\n- RLC-423\n- RLC-420-5MP\n- RLC-410-5MP\n- RLC-510A\n- RLC-520\n- RLC-823A\n- C1-Pro\n- D400\n- E1 Zoom\n\n"
  },
  {
    "path": "examples/basic_usage.py",
    "content": "import reolinkapi\n\nif __name__ == \"__main__\":\n    cam = reolinkapi.Camera(\"192.168.0.102\", defer_login=True)\n\n    # must first login since I defer have deferred the login process\n    cam.login()\n\n    dst = cam.get_dst()\n    ok = cam.add_user(\"foo\", \"bar\", \"admin\")\n    alarm = cam.get_alarm_motion()\n    cam.set_device_name(name='my_camera')"
  },
  {
    "path": "examples/custom_ssl_session.py",
    "content": "from reolinkapi import Camera\n\nimport urllib3\nimport requests\nfrom urllib3.util import create_urllib3_context\n\nclass CustomSSLContextHTTPAdapter(requests.adapters.HTTPAdapter):\n    def __init__(self, ssl_context=None, **kwargs):\n        self.ssl_context = ssl_context\n        super().__init__(**kwargs)\n\n    def init_poolmanager(self, connections, maxsize, block=False):\n        self.poolmanager = urllib3.poolmanager.PoolManager(\n            num_pools=connections, maxsize=maxsize,\n            block=block, ssl_context=self.ssl_context)\n\nurllib3.disable_warnings()\nctx = create_urllib3_context()\nctx.load_default_certs()\nctx.set_ciphers(\"AES128-GCM-SHA256\")\nctx.check_hostname = False\n\nsession = requests.session()\nsession.adapters.pop(\"https://\", None)\nsession.mount(\"https://\", CustomSSLContextHTTPAdapter(ctx))\n\n## Add a custom http handler to add in different ciphers that may\n## not be aloud by default in openssl which urlib uses\ncam = Camera(\"url\", \"user\", \"password\", https=True, session=session)\ncam.reboot_camera()\n"
  },
  {
    "path": "examples/download_motions.py",
    "content": "\"\"\"Downloads all motion events from camera from the past hour.\"\"\"\nimport os\nfrom configparser import RawConfigParser\nfrom datetime import datetime as dt, timedelta\nfrom reolinkapi import Camera\n\n\ndef read_config(props_path: str) -> dict:\n    \"\"\"Reads in a properties file into variables.\n\n    NB! this config file is kept out of commits with .gitignore. The structure of this file is such:\n    # secrets.cfg\n        [camera]\n        ip={ip_address}\n        username={username}\n        password={password}\n    \"\"\"\n    config = RawConfigParser()\n    assert os.path.exists(props_path), f\"Path does not exist: {props_path}\"\n    config.read(props_path)\n    return config\n\n\n# Read in your ip, username, & password\n#   (NB! you'll likely have to create this file. See tests/test_camera.py for details on structure)\nconfig = read_config('camera.cfg')\n\nip = config.get('camera', 'ip')\nun = config.get('camera', 'username')\npw = config.get('camera', 'password')\n\n# Connect to camera\ncam = Camera(ip, un, pw, https=True)\n\nstart = dt.combine(dt.now(), dt.min.time())\nend = dt.now()\n# Collect motion events between these timestamps for substream\nprocessed_motions = cam.get_motion_files(start=start, end=end, streamtype='main', channel=0)\nprocessed_motions += cam.get_motion_files(start=start, end=end, streamtype='main', channel=1)\n\nstart = dt.now() - timedelta(days=1)\nend = dt.combine(start, dt.max.time())\nprocessed_motions += cam.get_motion_files(start=start, end=end, streamtype='main', channel=1)\n\n\noutput_files = []\nfor i, motion in enumerate(processed_motions):\n    fname = motion['filename']\n    # Download the mp4\n    print(\"Getting %s\" % (fname))\n    output_path = os.path.join('/tmp/', fname.replace('/','_'))\n    output_files += output_path\n    if not os.path.isfile(output_path):\n        resp = cam.get_file(fname, output_path=output_path)\n"
  },
  {
    "path": "examples/download_playback_video.py",
    "content": "\"\"\"Downloads a video from camera from start to end time.\"\"\"\nimport os\nfrom configparser import RawConfigParser\nfrom datetime import datetime as dt, timedelta\nfrom reolinkapi import Camera\nimport requests\nimport pandas as pd\n\ndef read_config(props_path: str) -> dict:\n    \"\"\"Reads in a properties file into variables.\n\n    NB! this config file is kept out of commits with .gitignore. The structure of this file is such:\n    # secrets.cfg\n        [camera]\n        ip={ip_address}\n        username={username}\n        password={password}\n    \"\"\"\n    config = RawConfigParser()\n    assert os.path.exists(props_path), f\"Path does not exist: {props_path}\"\n    config.read(props_path)\n    return config\n\n\n# Read in your ip, username, & password\n#   (NB! you'll likely have to create this file. See tests/test_camera.py for details on structure)\nconfig = read_config('camera.cfg')\n\nip = config.get('camera', 'ip')\nun = config.get('camera', 'username')\npw = config.get('camera', 'password')\n\n# Connect to camera\ncam = Camera(ip, un, pw)\n\nstart = dt.now() - timedelta(minutes=10)\nend = dt.now() - timedelta(minutes=9)\nchannel  = 0\n\nfiles = cam.get_playback_files(start=start, end=end, channel= channel)\nprint(files)\ndl_dir = os.path.join(os.path.expanduser('~'), 'Downloads')\nfor fname in files:\n    print(fname)\n    # Download the mp4\n    cam.get_file(fname, output_path=os.path.join(dl_dir, fname))\n"
  },
  {
    "path": "examples/network_config.py",
    "content": "import os\nfrom configparser import RawConfigParser\nfrom reolinkapi import Camera\n\n\ndef read_config(props_path: str) -> dict:\n    \"\"\"Reads in a properties file into variables.\n\n    NB! this config file is kept out of commits with .gitignore. The structure of this file is such:\n    # secrets.cfg\n        [camera]\n        ip={ip_address}\n        username={username}\n        password={password}\n    \"\"\"\n    config = RawConfigParser()\n    assert os.path.exists(props_path), f\"Path does not exist: {props_path}\"\n    config.read(props_path)\n    return config\n\n\n# Read in your ip, username, & password\n#   (NB! you'll likely have to create this file. See tests/test_camera.py for details on structure)\nconfig = read_config('camera.cfg')\n\nip = config.get('camera', 'ip')\nun = config.get('camera', 'username')\npw = config.get('camera', 'password')\n\n# Connect to camera\ncam = Camera(ip, un, pw)\n\n# Set NTP\ncam.set_ntp(enable=True, interval=1440, port=123, server=\"time-b.nist.gov\")\n\n# Get current network settings\ncurrent_settings = cam.get_network_general()\nprint(\"Current settings:\", current_settings)\n\n# Configure DHCP\ncam.set_network_settings(\n    ip=\"\",\n    gateway=\"\",\n    mask=\"\",\n    dns1=\"\",\n    dns2=\"\",\n    mac=current_settings[0]['value']['LocalLink']['mac'],\n    use_dhcp=True,\n    auto_dns=True\n)\n\n# Configure static IP\n# cam.set_network_settings(\n#     ip=\"192.168.1.102\",\n#     gateway=\"192.168.1.1\",\n#     mask=\"255.255.255.0\",\n#     dns1=\"8.8.8.8\",\n#     dns2=\"8.8.4.4\",\n#     mac=current_settings[0]['value']['LocalLink']['mac'],\n#     use_dhcp=False,\n#     auto_dns=False\n# )"
  },
  {
    "path": "examples/response/GetAlarmMotion.json",
    "content": "[\n  {\n    \"cmd\": \"GetAlarm\",\n    \"code\": 0,\n    \"initial\": {\n      \"Alarm\": {\n        \"action\": { \"mail\": 1, \"push\": 1, \"recChannel\": [0] },\n        \"channel\": 0,\n        \"enable\": 1,\n        \"schedule\": {\n          \"table\": \"111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111\"\n        },\n        \"scope\": {\n          \"cols\": 80,\n          \"rows\": 45,\n          \"table\": \"111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111\"\n        },\n        \"sens\": [\n          {\n            \"beginHour\": 0,\n            \"beginMin\": 0,\n            \"endHour\": 6,\n            \"endMin\": 0,\n            \"sensitivity\": 10\n          },\n          {\n            \"beginHour\": 6,\n            \"beginMin\": 0,\n            \"endHour\": 12,\n            \"endMin\": 0,\n            \"sensitivity\": 10\n          },\n          {\n            \"beginHour\": 12,\n            \"beginMin\": 0,\n            \"endHour\": 18,\n            \"endMin\": 0,\n            \"sensitivity\": 10\n          },\n          {\n            \"beginHour\": 18,\n            \"beginMin\": 0,\n            \"endHour\": 23,\n            \"endMin\": 59,\n            \"sensitivity\": 10\n          }\n        ],\n        \"type\": \"md\"\n      }\n    },\n    \"range\": {\n      \"Alarm\": {\n        \"action\": { \"mail\": \"boolean\", \"push\": \"boolean\", \"recChannel\": [0] },\n        \"channel\": 0,\n        \"enable\": \"boolean\",\n        \"schedule\": { \"table\": { \"maxLen\": 168, \"minLen\": 168 } },\n        \"scope\": {\n          \"cols\": { \"max\": 80, \"min\": 80 },\n          \"rows\": { \"max\": 45, \"min\": 45 },\n          \"table\": { \"maxLen\": 8159 }\n        },\n        \"sens\": [\n          {\n            \"beginHour\": { \"max\": 23, \"min\": 0 },\n            \"beginMin\": { \"max\": 59, \"min\": 0 },\n            \"endHour\": { \"max\": 23, \"min\": 0 },\n            \"endMin\": { \"max\": 59, \"min\": 0 },\n            \"id\": 0,\n            \"sensitivity\": { \"max\": 50, \"min\": 1 }\n          },\n          {\n            \"beginHour\": { \"max\": 23, \"min\": 0 },\n            \"beginMin\": { \"max\": 59, \"min\": 0 },\n            \"endHour\": { \"max\": 23, \"min\": 0 },\n            \"endMin\": { \"max\": 59, \"min\": 0 },\n            \"id\": 1,\n            \"sensitivity\": { \"max\": 50, \"min\": 1 }\n          },\n          {\n            \"beginHour\": { \"max\": 23, \"min\": 0 },\n            \"beginMin\": { \"max\": 59, \"min\": 0 },\n            \"endHour\": { \"max\": 23, \"min\": 0 },\n            \"endMin\": { \"max\": 59, \"min\": 0 },\n            \"id\": 2,\n            \"sensitivity\": { \"max\": 50, \"min\": 1 }\n          },\n          {\n            \"beginHour\": { \"max\": 23, \"min\": 0 },\n            \"beginMin\": { \"max\": 59, \"min\": 0 },\n            \"endHour\": { \"max\": 23, \"min\": 0 },\n            \"endMin\": { \"max\": 59, \"min\": 0 },\n            \"id\": 3,\n            \"sensitivity\": { \"max\": 50, \"min\": 1 }\n          }\n        ],\n        \"type\": \"md\"\n      }\n    },\n    \"value\": {\n      \"Alarm\": {\n        \"action\": { \"mail\": 1, \"push\": 1, \"recChannel\": [0] },\n        \"channel\": 0,\n        \"enable\": 1,\n        \"schedule\": {\n          \"table\": \"111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111\"\n        },\n        \"scope\": {\n          \"cols\": 80,\n          \"rows\": 45,\n          \"table\": \"111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111\"\n        },\n        \"sens\": [\n          {\n            \"beginHour\": 0,\n            \"beginMin\": 0,\n            \"endHour\": 6,\n            \"endMin\": 0,\n            \"id\": 0,\n            \"sensitivity\": 10\n          },\n          {\n            \"beginHour\": 6,\n            \"beginMin\": 0,\n            \"endHour\": 12,\n            \"endMin\": 0,\n            \"id\": 1,\n            \"sensitivity\": 10\n          },\n          {\n            \"beginHour\": 12,\n            \"beginMin\": 0,\n            \"endHour\": 18,\n            \"endMin\": 0,\n            \"id\": 2,\n            \"sensitivity\": 10\n          },\n          {\n            \"beginHour\": 18,\n            \"beginMin\": 0,\n            \"endHour\": 23,\n            \"endMin\": 59,\n            \"id\": 3,\n            \"sensitivity\": 10\n          }\n        ],\n        \"type\": \"md\"\n      }\n    }\n  }\n]\n"
  },
  {
    "path": "examples/response/GetDSTInfo.json",
    "content": "[\n  {\n    \"cmd\": \"GetTime\",\n    \"code\": 0,\n    \"value\": {\n      \"Dst\": {\n        \"enable\": 1,\n        \"endHour\": 2,\n        \"endMin\": 0,\n        \"endMon\": 11,\n        \"endSec\": 0,\n        \"endWeek\": 1,\n        \"endWeekday\": 0,\n        \"offset\": 1,\n        \"startHour\": 2,\n        \"startMin\": 0,\n        \"startMon\": 3,\n        \"startSec\": 0,\n        \"startWeek\": 1,\n        \"startWeekday\": 0\n      },\n      \"Time\": {\n        \"day\": 27,\n        \"hour\": 18,\n        \"hourFmt\": 0,\n        \"min\": 50,\n        \"mon\": 10,\n        \"sec\": 46,\n        \"timeFmt\": \"MM/DD/YYYY\",\n        \"timeZone\": 21600,\n        \"year\": 2020\n      }\n    }\n  }\n]\n"
  },
  {
    "path": "examples/response/GetDevInfo.json",
    "content": "[\n  {\n    \"cmd\": \"GetDevInfo\",\n    \"code\": 0,\n    \"value\": {\n      \"DevInfo\": {\n        \"B485\": 0,\n        \"IOInputNum\": 0,\n        \"IOOutputNum\": 0,\n        \"audioNum\": 0,\n        \"buildDay\": \"build 18081408\",\n        \"cfgVer\": \"v2.0.0.0\",\n        \"channelNum\": 1,\n        \"detail\": \"IPC_3816M100000000100000\",\n        \"diskNum\": 1,\n        \"firmVer\": \"v2.0.0.1389_18081408\",\n        \"hardVer\": \"IPC_3816M\",\n        \"model\": \"RLC-411WS\",\n        \"name\": \"Camera1_withpersonality\",\n        \"serial\": \"00000000000000\",\n        \"type\": \"IPC\",\n        \"wifi\": 1\n      }\n    }\n  }\n]\n"
  },
  {
    "path": "examples/response/GetEnc.json",
    "content": "[\n  {\n    \"cmd\": \"GetEnc\",\n    \"code\": 0,\n    \"initial\": {\n      \"Enc\": {\n        \"audio\": 0,\n        \"channel\": 0,\n        \"mainStream\": {\n          \"bitRate\": 4096,\n          \"frameRate\": 15,\n          \"profile\": \"High\",\n          \"size\": \"3072*1728\"\n        },\n        \"subStream\": {\n          \"bitRate\": 160,\n          \"frameRate\": 7,\n          \"profile\": \"High\",\n          \"size\": \"640*360\"\n        }\n      }\n    },\n    \"range\": {\n      \"Enc\": [\n        {\n          \"audio\": \"boolean\",\n          \"mainStream\": {\n            \"bitRate\": [\n              1024,\n              1536,\n              2048,\n              3072,\n              4096,\n              5120,\n              6144,\n              7168,\n              8192\n            ],\n            \"default\": {\n              \"bitRate\": 4096,\n              \"frameRate\": 15\n            },\n            \"frameRate\": [\n              20,\n              18,\n              16,\n              15,\n              12,\n              10,\n              8,\n              6,\n              4,\n              2\n            ],\n            \"profile\": [\n              \"Base\",\n              \"Main\",\n              \"High\"\n            ],\n            \"size\": \"3072*1728\"\n          },\n          \"subStream\": {\n            \"bitRate\": [\n              64,\n              128,\n              160,\n              192,\n              256,\n              384,\n              512\n            ],\n            \"default\": {\n              \"bitRate\": 160,\n              \"frameRate\": 7\n            },\n            \"frameRate\": [\n              15,\n              10,\n              7,\n              4\n            ],\n            \"profile\": [\n              \"Base\",\n              \"Main\",\n              \"High\"\n            ],\n            \"size\": \"640*360\"\n          }\n        },\n        {\n          \"audio\": \"boolean\",\n          \"mainStream\": {\n            \"bitRate\": [\n              1024,\n              1536,\n              2048,\n              3072,\n              4096,\n              5120,\n              6144,\n              7168,\n              8192\n            ],\n            \"default\": {\n              \"bitRate\": 4096,\n              \"frameRate\": 15\n            },\n            \"frameRate\": [\n              20,\n              18,\n              16,\n              15,\n              12,\n              10,\n              8,\n              6,\n              4,\n              2\n            ],\n            \"profile\": [\n              \"Base\",\n              \"Main\",\n              \"High\"\n            ],\n            \"size\": \"2592*1944\"\n          },\n          \"subStream\": {\n            \"bitRate\": [\n              64,\n              128,\n              160,\n              192,\n              256,\n              384,\n              512\n            ],\n            \"default\": {\n              \"bitRate\": 160,\n              \"frameRate\": 7\n            },\n            \"frameRate\": [\n              15,\n              10,\n              7,\n              4\n            ],\n            \"profile\": [\n              \"Base\",\n              \"Main\",\n              \"High\"\n            ],\n            \"size\": \"640*360\"\n          }\n        },\n        {\n          \"audio\": \"boolean\",\n          \"mainStream\": {\n            \"bitRate\": [\n              1024,\n              1536,\n              2048,\n              3072,\n              4096,\n              5120,\n              6144,\n              7168,\n              8192\n            ],\n            \"default\": {\n              \"bitRate\": 3072,\n              \"frameRate\": 15\n            },\n            \"frameRate\": [\n              30,\n              22,\n              20,\n              18,\n              16,\n              15,\n              12,\n              10,\n              8,\n              6,\n              4,\n              2\n            ],\n            \"profile\": [\n              \"Base\",\n              \"Main\",\n              \"High\"\n            ],\n            \"size\": \"2560*1440\"\n          },\n          \"subStream\": {\n            \"bitRate\": [\n              64,\n              128,\n              160,\n              192,\n              256,\n              384,\n              512\n            ],\n            \"default\": {\n              \"bitRate\": 160,\n              \"frameRate\": 7\n            },\n            \"frameRate\": [\n              15,\n              10,\n              7,\n              4\n            ],\n            \"profile\": [\n              \"Base\",\n              \"Main\",\n              \"High\"\n            ],\n            \"size\": \"640*360\"\n          }\n        },\n        {\n          \"audio\": \"boolean\",\n          \"mainStream\": {\n            \"bitRate\": [\n              1024,\n              1536,\n              2048,\n              3072,\n              4096,\n              5120,\n              6144,\n              7168,\n              8192\n            ],\n            \"default\": {\n              \"bitRate\": 3072,\n              \"frameRate\": 15\n            },\n            \"frameRate\": [\n              30,\n              22,\n              20,\n              18,\n              16,\n              15,\n              12,\n              10,\n              8,\n              6,\n              4,\n              2\n            ],\n            \"profile\": [\n              \"Base\",\n              \"Main\",\n              \"High\"\n            ],\n            \"size\": \"2048*1536\"\n          },\n          \"subStream\": {\n            \"bitRate\": [\n              64,\n              128,\n              160,\n              192,\n              256,\n              384,\n              512\n            ],\n            \"default\": {\n              \"bitRate\": 160,\n              \"frameRate\": 7\n            },\n            \"frameRate\": [\n              15,\n              10,\n              7,\n              4\n            ],\n            \"profile\": [\n              \"Base\",\n              \"Main\",\n              \"High\"\n            ],\n            \"size\": \"640*360\"\n          }\n        },\n        {\n          \"audio\": \"boolean\",\n          \"mainStream\": {\n            \"bitRate\": [\n              1024,\n              1536,\n              2048,\n              3072,\n              4096,\n              5120,\n              6144,\n              7168,\n              8192\n            ],\n            \"default\": {\n              \"bitRate\": 3072,\n              \"frameRate\": 15\n            },\n            \"frameRate\": [\n              30,\n              22,\n              20,\n              18,\n              16,\n              15,\n              12,\n              10,\n              8,\n              6,\n              4,\n              2\n            ],\n            \"profile\": [\n              \"Base\",\n              \"Main\",\n              \"High\"\n            ],\n            \"size\": \"2304*1296\"\n          },\n          \"subStream\": {\n            \"bitRate\": [\n              64,\n              128,\n              160,\n              192,\n              256,\n              384,\n              512\n            ],\n            \"default\": {\n              \"bitRate\": 160,\n              \"frameRate\": 7\n            },\n            \"frameRate\": [\n              15,\n              10,\n              7,\n              4\n            ],\n            \"profile\": [\n              \"Base\",\n              \"Main\",\n              \"High\"\n            ],\n            \"size\": \"640*360\"\n          }\n        }\n      ]\n    },\n    \"value\": {\n      \"Enc\": {\n        \"audio\": 0,\n        \"channel\": 0,\n        \"mainStream\": {\n          \"bitRate\": 2048,\n          \"frameRate\": 20,\n          \"profile\": \"Main\",\n          \"size\": \"3072*1728\"\n        },\n        \"subStream\": {\n          \"bitRate\": 64,\n          \"frameRate\": 4,\n          \"profile\": \"High\",\n          \"size\": \"640*360\"\n        }\n      }\n    }\n  }\n]\n"
  },
  {
    "path": "examples/response/GetGeneralSystem.json",
    "content": "[\n  {\n    \"cmd\": \"GetTime\",\n    \"code\": 0,\n    \"initial\": {\n      \"Dst\": {\n        \"enable\": 0,\n        \"endHour\": 2,\n        \"endMin\": 0,\n        \"endMon\": 10,\n        \"endSec\": 0,\n        \"endWeek\": 5,\n        \"endWeekday\": 0,\n        \"offset\": 1,\n        \"startHour\": 2,\n        \"startMin\": 0,\n        \"startMon\": 3,\n        \"startSec\": 0,\n        \"startWeek\": 2,\n        \"startWeekday\": 0\n      },\n      \"Time\": {\n        \"day\": 1,\n        \"hour\": 0,\n        \"hourFmt\": 0,\n        \"min\": 0,\n        \"mon\": 0,\n        \"sec\": 0,\n        \"timeFmt\": \"DD/MM/YYYY\",\n        \"timeZone\": 28800,\n        \"year\": 0\n      }\n    },\n    \"range\": {\n      \"Dst\": {\n        \"enable\": \"boolean\",\n        \"endHour\": { \"max\": 23, \"min\": 0 },\n        \"endMin\": { \"max\": 59, \"min\": 0 },\n        \"endMon\": { \"max\": 12, \"min\": 1 },\n        \"endSec\": { \"max\": 59, \"min\": 0 },\n        \"endWeek\": { \"max\": 5, \"min\": 1 },\n        \"endWeekday\": { \"max\": 6, \"min\": 0 },\n        \"offset\": { \"max\": 2, \"min\": 1 },\n        \"startHour\": { \"max\": 23, \"min\": 0 },\n        \"startMin\": { \"max\": 59, \"min\": 0 },\n        \"startMon\": { \"max\": 12, \"min\": 1 },\n        \"startSec\": { \"max\": 59, \"min\": 0 },\n        \"startWeek\": { \"max\": 5, \"min\": 1 },\n        \"startWeekday\": { \"max\": 6, \"min\": 0 }\n      },\n      \"Time\": {\n        \"day\": { \"max\": 31, \"min\": 1 },\n        \"hour\": { \"max\": 23, \"min\": 0 },\n        \"hourFmt\": { \"max\": 1, \"min\": 0 },\n        \"min\": { \"max\": 59, \"min\": 0 },\n        \"mon\": { \"max\": 12, \"min\": 1 },\n        \"sec\": { \"max\": 59, \"min\": 0 },\n        \"timeFmt\": [\"MM/DD/YYYY\", \"YYYY/MM/DD\", \"DD/MM/YYYY\"],\n        \"timeZone\": { \"max\": 43200, \"min\": -46800 },\n        \"year\": { \"max\": 2100, \"min\": 1900 }\n      }\n    },\n    \"value\": {\n      \"Dst\": {\n        \"enable\": 1,\n        \"endHour\": 2,\n        \"endMin\": 0,\n        \"endMon\": 11,\n        \"endSec\": 0,\n        \"endWeek\": 1,\n        \"endWeekday\": 0,\n        \"offset\": 1,\n        \"startHour\": 2,\n        \"startMin\": 0,\n        \"startMon\": 3,\n        \"startSec\": 0,\n        \"startWeek\": 1,\n        \"startWeekday\": 0\n      },\n      \"Time\": {\n        \"day\": 9,\n        \"hour\": 15,\n        \"hourFmt\": 0,\n        \"min\": 33,\n        \"mon\": 12,\n        \"sec\": 58,\n        \"timeFmt\": \"MM/DD/YYYY\",\n        \"timeZone\": 21600,\n        \"year\": 2020\n      }\n    }\n  },\n  {\n    \"cmd\": \"GetNorm\",\n    \"code\": 0,\n    \"initial\": { \"norm\": \"NTSC\" },\n    \"range\": { \"norm\": [\"PAL\", \"NTSC\"] },\n    \"value\": { \"norm\": \"NTSC\" }\n  }\n]\n"
  },
  {
    "path": "examples/response/GetHddInfo.json",
    "content": "[\n  {\n    \"cmd\": \"GetHddInfo\",\n    \"code\": 0,\n    \"value\": {\n      \"HddInfo\": [\n        {\n          \"capacity\": 15181,\n          \"format\": 1,\n          \"id\": 0,\n          \"mount\": 1,\n          \"size\": 15181\n        }\n      ]\n    }\n  }\n]\n"
  },
  {
    "path": "examples/response/GetMask.json",
    "content": "[\n  {\n    \"cmd\": \"GetMask\",\n    \"code\": 0,\n    \"initial\": {\n      \"Mask\": {\n        \"area\": [\n          {\n            \"block\": {\n              \"height\": 0,\n              \"width\": 0,\n              \"x\": 0,\n              \"y\": 0\n            },\n            \"screen\": {\n              \"height\": 0,\n              \"width\": 0\n            }\n          }\n        ],\n        \"channel\": 0,\n        \"enable\": 0\n      }\n    },\n    \"range\": {\n      \"Mask\": {\n        \"channel\": 0,\n        \"enable\": \"boolean\",\n        \"maxAreas\": 4\n      }\n    },\n    \"value\": {\n      \"Mask\": {\n        \"area\": null,\n        \"channel\": 0,\n        \"enable\": 0\n      }\n    }\n  }\n]\n"
  },
  {
    "path": "examples/response/GetNetworkAdvanced.json",
    "content": "[\n  {\n    \"cmd\": \"GetNetPort\",\n    \"code\": 0,\n    \"initial\": {\n      \"NetPort\": {\n        \"httpPort\": 80,\n        \"httpsPort\": 443,\n        \"mediaPort\": 9000,\n        \"onvifPort\": 8000,\n        \"rtmpPort\": 1935,\n        \"rtspPort\": 554\n      }\n    },\n    \"range\": {\n      \"NetPort\": {\n        \"httpPort\": { \"max\": 65535, \"min\": 1 },\n        \"httpsPort\": { \"max\": 65535, \"min\": 1 },\n        \"mediaPort\": { \"max\": 65535, \"min\": 1 },\n        \"onvifPort\": { \"max\": 65535, \"min\": 1 },\n        \"rtmpPort\": { \"max\": 65535, \"min\": 1 },\n        \"rtspPort\": { \"max\": 65535, \"min\": 1 }\n      }\n    },\n    \"value\": {\n      \"NetPort\": {\n        \"httpPort\": 80,\n        \"httpsPort\": 443,\n        \"mediaPort\": 9000,\n        \"onvifPort\": 8000,\n        \"rtmpPort\": 1935,\n        \"rtspPort\": 554\n      }\n    }\n  },\n  { \"cmd\": \"GetUpnp\", \"code\": 0, \"value\": { \"Upnp\": { \"enable\": 0 } } },\n  {\n    \"cmd\": \"GetP2p\",\n    \"code\": 0,\n    \"value\": { \"P2p\": { \"enable\": 0, \"uid\": \"99999999999999\" } }\n  }\n]\n"
  },
  {
    "path": "examples/response/GetNetworkDDNS.json",
    "content": "[\n  {\n    \"cmd\": \"GetDdns\",\n    \"code\": 0,\n    \"value\": {\n      \"Ddns\": {\n        \"domain\": \"\",\n        \"enable\": 0,\n        \"password\": \"\",\n        \"type\": \"no-ip\",\n        \"userName\": \"\"\n      }\n    }\n  }\n]\n"
  },
  {
    "path": "examples/response/GetNetworkEmail.json",
    "content": "[\n  {\n    \"cmd\": \"GetEmail\",\n    \"code\": 0,\n    \"value\": {\n      \"Email\": {\n        \"addr1\": \"\",\n        \"addr2\": \"\",\n        \"addr3\": \"\",\n        \"attachment\": \"picture\",\n        \"interval\": \"5 Minutes\",\n        \"nickName\": \"\",\n        \"password\": \"\",\n        \"schedule\": {\n          \"enable\": 1,\n          \"table\": \"111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111\"\n        },\n        \"smtpPort\": 465,\n        \"smtpServer\": \"smtp.gmail.com\",\n        \"ssl\": 1,\n        \"userName\": \"\"\n      }\n    }\n  }\n]\n"
  },
  {
    "path": "examples/response/GetNetworkFtp.json",
    "content": "[\n  {\n    \"cmd\": \"GetFtp\",\n    \"code\": 0,\n    \"value\": {\n      \"Ftp\": {\n        \"anonymous\": 0,\n        \"interval\": 30,\n        \"maxSize\": 100,\n        \"mode\": 0,\n        \"password\": \"\",\n        \"port\": 21,\n        \"remoteDir\": \"\",\n        \"schedule\": {\n          \"enable\": 1,\n          \"table\": \"111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111\"\n        },\n        \"server\": \"\",\n        \"streamType\": 0,\n        \"userName\": \"\"\n      }\n    }\n  }\n]\n"
  },
  {
    "path": "examples/response/GetNetworkGeneral.json",
    "content": "[\n  {\n    \"cmd\": \"GetLocalLink\",\n    \"code\": 0,\n    \"value\": {\n      \"LocalLink\": {\n        \"activeLink\": \"LAN\",\n        \"dns\": { \"auto\": 1, \"dns1\": \"192.168.255.4\", \"dns2\": \"192.168.255.4\" },\n        \"mac\": \"EC:71:DB:AA:59:CF\",\n        \"static\": {\n          \"gateway\": \"192.168.255.1\",\n          \"ip\": \"192.168.255.58\",\n          \"mask\": \"255.255.255.0\"\n        },\n        \"type\": \"DHCP\"\n      }\n    }\n  }\n]\n"
  },
  {
    "path": "examples/response/GetNetworkNTP.json",
    "content": "[\n  {\n    \"cmd\": \"GetNtp\",\n    \"code\": 0,\n    \"value\": {\n      \"Ntp\": {\n        \"enable\": 1,\n        \"interval\": 1440,\n        \"port\": 123,\n        \"server\": \"ntp.moos.xyz\"\n      }\n    }\n  }\n]\n"
  },
  {
    "path": "examples/response/GetNetworkPush.json",
    "content": "[\n  {\n    \"cmd\": \"GetPush\",\n    \"code\": 0,\n    \"value\": {\n      \"Push\": {\n        \"schedule\": {\n          \"enable\": 1,\n          \"table\": \"111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111\"\n        }\n      }\n    }\n  }\n]\n"
  },
  {
    "path": "examples/response/GetOnline.json",
    "content": "[\n  {\n    \"cmd\": \"GetOnline\",\n    \"code\": 0,\n    \"value\": {\n      \"User\": [\n        {\n          \"canbeDisconn\": 0,\n          \"ip\": \"192.168.1.100\",\n          \"level\": \"admin\",\n          \"sessionId\": 1000,\n          \"userName\": \"admin\"\n        }\n      ]\n    }\n  }\n]\n"
  },
  {
    "path": "examples/response/GetOsd.json",
    "content": "[\n  {\n    \"cmd\": \"GetOsd\",\n    \"code\": 0,\n    \"initial\": {\n      \"Osd\": {\n        \"bgcolor\": 0,\n        \"channel\": 0,\n        \"osdChannel\": {\n          \"enable\": 1,\n          \"name\": \"Camera1\",\n          \"pos\": \"Lower Right\"\n        },\n        \"osdTime\": {\n          \"enable\": 1,\n          \"pos\": \"Top Center\"\n        }\n      }\n    },\n    \"range\": {\n      \"Osd\": {\n        \"bgcolor\": \"boolean\",\n        \"channel\": 0,\n        \"osdChannel\": {\n          \"enable\": \"boolean\",\n          \"name\": {\n            \"maxLen\": 31\n          },\n          \"pos\": [\n            \"Upper Left\",\n            \"Top Center\",\n            \"Upper Right\",\n            \"Lower Left\",\n            \"Bottom Center\",\n            \"Lower Right\"\n          ]\n        },\n        \"osdTime\": {\n          \"enable\": \"boolean\",\n          \"pos\": [\n            \"Upper Left\",\n            \"Top Center\",\n            \"Upper Right\",\n            \"Lower Left\",\n            \"Bottom Center\",\n            \"Lower Right\"\n          ]\n        }\n      }\n    },\n    \"value\": {\n      \"Osd\": {\n        \"bgcolor\": 0,\n        \"channel\": 0,\n        \"osdChannel\": {\n          \"enable\": 0,\n          \"name\": \"FarRight\",\n          \"pos\": \"Lower Right\"\n        },\n        \"osdTime\": {\n          \"enable\": 0,\n          \"pos\": \"Top Center\"\n        }\n      }\n    }\n  }\n]"
  },
  {
    "path": "examples/response/GetPerformance.json",
    "content": "[\n  {\n    \"cmd\": \"GetPerformance\",\n    \"code\": 0,\n    \"value\": {\n      \"Performance\": {\n        \"codecRate\": 2154,\n        \"cpuUsed\": 14,\n        \"netThroughput\": 0\n      }\n    }\n  }\n]\n"
  },
  {
    "path": "examples/response/GetPtzCheckState.json",
    "content": "[\n  {\n    \"cmd\": \"GetPtzCheckState\",\n    \"code\": 0,\n    \"initial\": {\n      \"PtzCheckState\": 2\n    },\n    \"range\": {\n      \"PtzCheckState\": [\n        0,\n        1,\n        2\n      ]\n    },\n    \"value\": {\n      \"PtzCheckState\": 2\n    }\n  }\n]\n"
  },
  {
    "path": "examples/response/GetPtzPresets.json",
    "content": "[\n  {\n    \"cmd\": \"GetPtzPreset\",\n    \"code\": 0,\n    \"initial\": {\n      \"PtzPreset\": [\n        {\n          \"channel\": 0,\n          \"enable\": 1,\n          \"id\": 0,\n          \"imgName\": \"preset_00\",\n          \"name\": \"namepos0\"\n        },\n        {\n          \"channel\": 0,\n          \"enable\": 1,\n          \"id\": 1,\n          \"imgName\": \"preset_01\",\n          \"name\": \"othernamepos1\"\n        },\n        {\n          \"channel\": 0,\n          \"enable\": 0,\n          \"id\": 2,\n          \"imgName\": \"\",\n          \"name\": \"pos3\"\n        },\n        {\n          \"channel\": 0,\n          \"enable\": 0,\n          \"id\": 3,\n          \"imgName\": \"\",\n          \"name\": \"pos4\"\n        },\n        {\n          \"channel\": 0,\n          \"enable\": 0,\n          \"id\": 4,\n          \"imgName\": \"\",\n          \"name\": \"pos5\"\n        },\n        {\n          \"channel\": 0,\n          \"enable\": 0,\n          \"id\": 5,\n          \"imgName\": \"\",\n          \"name\": \"pos6\"\n        },\n        {\n          \"channel\": 0,\n          \"enable\": 0,\n          \"id\": 6,\n          \"imgName\": \"\",\n          \"name\": \"pos7\"\n        },\n        {\n          \"channel\": 0,\n          \"enable\": 0,\n          \"id\": 7,\n          \"imgName\": \"\",\n          \"name\": \"pos8\"\n        },\n        {\n          \"channel\": 0,\n          \"enable\": 0,\n          \"id\": 8,\n          \"imgName\": \"\",\n          \"name\": \"pos9\"\n        },\n        {\n          \"channel\": 0,\n          \"enable\": 0,\n          \"id\": 9,\n          \"imgName\": \"\",\n          \"name\": \"pos10\"\n        },\n        {\n          \"channel\": 0,\n          \"enable\": 0,\n          \"id\": 10,\n          \"imgName\": \"\",\n          \"name\": \"pos11\"\n        },\n        {\n          \"channel\": 0,\n          \"enable\": 0,\n          \"id\": 11,\n          \"imgName\": \"\",\n          \"name\": \"pos12\"\n        },\n        {\n          \"channel\": 0,\n          \"enable\": 0,\n          \"id\": 12,\n          \"imgName\": \"\",\n          \"name\": \"pos13\"\n        },\n        {\n          \"channel\": 0,\n          \"enable\": 0,\n          \"id\": 13,\n          \"imgName\": \"\",\n          \"name\": \"pos14\"\n        },\n        {\n          \"channel\": 0,\n          \"enable\": 0,\n          \"id\": 14,\n          \"imgName\": \"\",\n          \"name\": \"pos15\"\n        },\n        {\n          \"channel\": 0,\n          \"enable\": 0,\n          \"id\": 15,\n          \"imgName\": \"\",\n          \"name\": \"pos16\"\n        },\n        {\n          \"channel\": 0,\n          \"enable\": 0,\n          \"id\": 16,\n          \"imgName\": \"\",\n          \"name\": \"pos17\"\n        },\n        {\n          \"channel\": 0,\n          \"enable\": 0,\n          \"id\": 17,\n          \"imgName\": \"\",\n          \"name\": \"pos18\"\n        },\n        {\n          \"channel\": 0,\n          \"enable\": 0,\n          \"id\": 18,\n          \"imgName\": \"\",\n          \"name\": \"pos19\"\n        },\n        {\n          \"channel\": 0,\n          \"enable\": 0,\n          \"id\": 19,\n          \"imgName\": \"\",\n          \"name\": \"pos20\"\n        },\n        {\n          \"channel\": 0,\n          \"enable\": 0,\n          \"id\": 20,\n          \"imgName\": \"\",\n          \"name\": \"pos21\"\n        },\n        {\n          \"channel\": 0,\n          \"enable\": 0,\n          \"id\": 21,\n          \"imgName\": \"\",\n          \"name\": \"pos22\"\n        },\n        {\n          \"channel\": 0,\n          \"enable\": 0,\n          \"id\": 22,\n          \"imgName\": \"\",\n          \"name\": \"pos23\"\n        },\n        {\n          \"channel\": 0,\n          \"enable\": 0,\n          \"id\": 23,\n          \"imgName\": \"\",\n          \"name\": \"pos24\"\n        },\n        {\n          \"channel\": 0,\n          \"enable\": 0,\n          \"id\": 24,\n          \"imgName\": \"\",\n          \"name\": \"pos25\"\n        },\n        {\n          \"channel\": 0,\n          \"enable\": 0,\n          \"id\": 25,\n          \"imgName\": \"\",\n          \"name\": \"pos26\"\n        },\n        {\n          \"channel\": 0,\n          \"enable\": 0,\n          \"id\": 26,\n          \"imgName\": \"\",\n          \"name\": \"pos27\"\n        },\n        {\n          \"channel\": 0,\n          \"enable\": 0,\n          \"id\": 27,\n          \"imgName\": \"\",\n          \"name\": \"pos28\"\n        },\n        {\n          \"channel\": 0,\n          \"enable\": 0,\n          \"id\": 28,\n          \"imgName\": \"\",\n          \"name\": \"pos29\"\n        },\n        {\n          \"channel\": 0,\n          \"enable\": 0,\n          \"id\": 29,\n          \"imgName\": \"\",\n          \"name\": \"pos30\"\n        },\n        {\n          \"channel\": 0,\n          \"enable\": 0,\n          \"id\": 30,\n          \"imgName\": \"\",\n          \"name\": \"pos31\"\n        },\n        {\n          \"channel\": 0,\n          \"enable\": 0,\n          \"id\": 31,\n          \"imgName\": \"\",\n          \"name\": \"pos32\"\n        },\n        {\n          \"channel\": 0,\n          \"enable\": 0,\n          \"id\": 32,\n          \"imgName\": \"\",\n          \"name\": \"pos33\"\n        },\n        {\n          \"channel\": 0,\n          \"enable\": 0,\n          \"id\": 33,\n          \"imgName\": \"\",\n          \"name\": \"pos34\"\n        },\n        {\n          \"channel\": 0,\n          \"enable\": 0,\n          \"id\": 34,\n          \"imgName\": \"\",\n          \"name\": \"pos35\"\n        },\n        {\n          \"channel\": 0,\n          \"enable\": 0,\n          \"id\": 35,\n          \"imgName\": \"\",\n          \"name\": \"pos36\"\n        },\n        {\n          \"channel\": 0,\n          \"enable\": 0,\n          \"id\": 36,\n          \"imgName\": \"\",\n          \"name\": \"pos37\"\n        },\n        {\n          \"channel\": 0,\n          \"enable\": 0,\n          \"id\": 37,\n          \"imgName\": \"\",\n          \"name\": \"pos38\"\n        },\n        {\n          \"channel\": 0,\n          \"enable\": 0,\n          \"id\": 38,\n          \"imgName\": \"\",\n          \"name\": \"pos39\"\n        },\n        {\n          \"channel\": 0,\n          \"enable\": 0,\n          \"id\": 39,\n          \"imgName\": \"\",\n          \"name\": \"pos40\"\n        },\n        {\n          \"channel\": 0,\n          \"enable\": 0,\n          \"id\": 40,\n          \"imgName\": \"\",\n          \"name\": \"pos41\"\n        },\n        {\n          \"channel\": 0,\n          \"enable\": 0,\n          \"id\": 41,\n          \"imgName\": \"\",\n          \"name\": \"pos42\"\n        },\n        {\n          \"channel\": 0,\n          \"enable\": 0,\n          \"id\": 42,\n          \"imgName\": \"\",\n          \"name\": \"pos43\"\n        },\n        {\n          \"channel\": 0,\n          \"enable\": 0,\n          \"id\": 43,\n          \"imgName\": \"\",\n          \"name\": \"pos44\"\n        },\n        {\n          \"channel\": 0,\n          \"enable\": 0,\n          \"id\": 44,\n          \"imgName\": \"\",\n          \"name\": \"pos45\"\n        },\n        {\n          \"channel\": 0,\n          \"enable\": 0,\n          \"id\": 45,\n          \"imgName\": \"\",\n          \"name\": \"pos46\"\n        },\n        {\n          \"channel\": 0,\n          \"enable\": 0,\n          \"id\": 46,\n          \"imgName\": \"\",\n          \"name\": \"pos47\"\n        },\n        {\n          \"channel\": 0,\n          \"enable\": 0,\n          \"id\": 47,\n          \"imgName\": \"\",\n          \"name\": \"pos48\"\n        },\n        {\n          \"channel\": 0,\n          \"enable\": 0,\n          \"id\": 48,\n          \"imgName\": \"\",\n          \"name\": \"pos49\"\n        },\n        {\n          \"channel\": 0,\n          \"enable\": 0,\n          \"id\": 49,\n          \"imgName\": \"\",\n          \"name\": \"pos50\"\n        },\n        {\n          \"channel\": 0,\n          \"enable\": 0,\n          \"id\": 50,\n          \"imgName\": \"\",\n          \"name\": \"pos51\"\n        },\n        {\n          \"channel\": 0,\n          \"enable\": 0,\n          \"id\": 51,\n          \"imgName\": \"\",\n          \"name\": \"pos52\"\n        },\n        {\n          \"channel\": 0,\n          \"enable\": 0,\n          \"id\": 52,\n          \"imgName\": \"\",\n          \"name\": \"pos53\"\n        },\n        {\n          \"channel\": 0,\n          \"enable\": 0,\n          \"id\": 53,\n          \"imgName\": \"\",\n          \"name\": \"pos54\"\n        },\n        {\n          \"channel\": 0,\n          \"enable\": 0,\n          \"id\": 54,\n          \"imgName\": \"\",\n          \"name\": \"pos55\"\n        },\n        {\n          \"channel\": 0,\n          \"enable\": 0,\n          \"id\": 55,\n          \"imgName\": \"\",\n          \"name\": \"pos56\"\n        },\n        {\n          \"channel\": 0,\n          \"enable\": 0,\n          \"id\": 56,\n          \"imgName\": \"\",\n          \"name\": \"pos57\"\n        },\n        {\n          \"channel\": 0,\n          \"enable\": 0,\n          \"id\": 57,\n          \"imgName\": \"\",\n          \"name\": \"pos58\"\n        },\n        {\n          \"channel\": 0,\n          \"enable\": 0,\n          \"id\": 58,\n          \"imgName\": \"\",\n          \"name\": \"pos59\"\n        },\n        {\n          \"channel\": 0,\n          \"enable\": 0,\n          \"id\": 59,\n          \"imgName\": \"\",\n          \"name\": \"pos60\"\n        },\n        {\n          \"channel\": 0,\n          \"enable\": 0,\n          \"id\": 60,\n          \"imgName\": \"\",\n          \"name\": \"pos61\"\n        },\n        {\n          \"channel\": 0,\n          \"enable\": 0,\n          \"id\": 61,\n          \"imgName\": \"\",\n          \"name\": \"pos62\"\n        },\n        {\n          \"channel\": 0,\n          \"enable\": 0,\n          \"id\": 62,\n          \"imgName\": \"\",\n          \"name\": \"pos63\"\n        },\n        {\n          \"channel\": 0,\n          \"enable\": 0,\n          \"id\": 63,\n          \"imgName\": \"\",\n          \"name\": \"pos64\"\n        }\n      ]\n    },\n    \"range\": {\n      \"PtzPreset\": {\n        \"channel\": 0,\n        \"enable\": \"boolean\",\n        \"id\": {\n          \"max\": 64,\n          \"min\": 1\n        },\n        \"imgName\": {\n          \"maxLen\": 31\n        },\n        \"name\": {\n          \"maxLen\": 31\n        }\n      }\n    },\n    \"value\": {\n      \"PtzPreset\": [\n        {\n          \"channel\": 0,\n          \"enable\": 1,\n          \"id\": 0,\n          \"imgName\": \"preset_00\",\n          \"name\": \"0\"\n        },\n        {\n          \"channel\": 0,\n          \"enable\": 1,\n          \"id\": 1,\n          \"imgName\": \"preset_01\",\n          \"name\": \"1\"\n        },\n        {\n          \"channel\": 0,\n          \"enable\": 0,\n          \"id\": 2,\n          \"imgName\": \"\",\n          \"name\": \"pos3\"\n        },\n        {\n          \"channel\": 0,\n          \"enable\": 0,\n          \"id\": 3,\n          \"imgName\": \"\",\n          \"name\": \"pos4\"\n        },\n        {\n          \"channel\": 0,\n          \"enable\": 0,\n          \"id\": 4,\n          \"imgName\": \"\",\n          \"name\": \"pos5\"\n        },\n        {\n          \"channel\": 0,\n          \"enable\": 0,\n          \"id\": 5,\n          \"imgName\": \"\",\n          \"name\": \"pos6\"\n        },\n        {\n          \"channel\": 0,\n          \"enable\": 0,\n          \"id\": 6,\n          \"imgName\": \"\",\n          \"name\": \"pos7\"\n        },\n        {\n          \"channel\": 0,\n          \"enable\": 0,\n          \"id\": 7,\n          \"imgName\": \"\",\n          \"name\": \"pos8\"\n        },\n        {\n          \"channel\": 0,\n          \"enable\": 0,\n          \"id\": 8,\n          \"imgName\": \"\",\n          \"name\": \"pos9\"\n        },\n        {\n          \"channel\": 0,\n          \"enable\": 0,\n          \"id\": 9,\n          \"imgName\": \"\",\n          \"name\": \"pos10\"\n        },\n        {\n          \"channel\": 0,\n          \"enable\": 0,\n          \"id\": 10,\n          \"imgName\": \"\",\n          \"name\": \"pos11\"\n        },\n        {\n          \"channel\": 0,\n          \"enable\": 0,\n          \"id\": 11,\n          \"imgName\": \"\",\n          \"name\": \"pos12\"\n        },\n        {\n          \"channel\": 0,\n          \"enable\": 0,\n          \"id\": 12,\n          \"imgName\": \"\",\n          \"name\": \"pos13\"\n        },\n        {\n          \"channel\": 0,\n          \"enable\": 0,\n          \"id\": 13,\n          \"imgName\": \"\",\n          \"name\": \"pos14\"\n        },\n        {\n          \"channel\": 0,\n          \"enable\": 0,\n          \"id\": 14,\n          \"imgName\": \"\",\n          \"name\": \"pos15\"\n        },\n        {\n          \"channel\": 0,\n          \"enable\": 0,\n          \"id\": 15,\n          \"imgName\": \"\",\n          \"name\": \"pos16\"\n        },\n        {\n          \"channel\": 0,\n          \"enable\": 0,\n          \"id\": 16,\n          \"imgName\": \"\",\n          \"name\": \"pos17\"\n        },\n        {\n          \"channel\": 0,\n          \"enable\": 0,\n          \"id\": 17,\n          \"imgName\": \"\",\n          \"name\": \"pos18\"\n        },\n        {\n          \"channel\": 0,\n          \"enable\": 0,\n          \"id\": 18,\n          \"imgName\": \"\",\n          \"name\": \"pos19\"\n        },\n        {\n          \"channel\": 0,\n          \"enable\": 0,\n          \"id\": 19,\n          \"imgName\": \"\",\n          \"name\": \"pos20\"\n        },\n        {\n          \"channel\": 0,\n          \"enable\": 0,\n          \"id\": 20,\n          \"imgName\": \"\",\n          \"name\": \"pos21\"\n        },\n        {\n          \"channel\": 0,\n          \"enable\": 0,\n          \"id\": 21,\n          \"imgName\": \"\",\n          \"name\": \"pos22\"\n        },\n        {\n          \"channel\": 0,\n          \"enable\": 0,\n          \"id\": 22,\n          \"imgName\": \"\",\n          \"name\": \"pos23\"\n        },\n        {\n          \"channel\": 0,\n          \"enable\": 0,\n          \"id\": 23,\n          \"imgName\": \"\",\n          \"name\": \"pos24\"\n        },\n        {\n          \"channel\": 0,\n          \"enable\": 0,\n          \"id\": 24,\n          \"imgName\": \"\",\n          \"name\": \"pos25\"\n        },\n        {\n          \"channel\": 0,\n          \"enable\": 0,\n          \"id\": 25,\n          \"imgName\": \"\",\n          \"name\": \"pos26\"\n        },\n        {\n          \"channel\": 0,\n          \"enable\": 0,\n          \"id\": 26,\n          \"imgName\": \"\",\n          \"name\": \"pos27\"\n        },\n        {\n          \"channel\": 0,\n          \"enable\": 0,\n          \"id\": 27,\n          \"imgName\": \"\",\n          \"name\": \"pos28\"\n        },\n        {\n          \"channel\": 0,\n          \"enable\": 0,\n          \"id\": 28,\n          \"imgName\": \"\",\n          \"name\": \"pos29\"\n        },\n        {\n          \"channel\": 0,\n          \"enable\": 0,\n          \"id\": 29,\n          \"imgName\": \"\",\n          \"name\": \"pos30\"\n        },\n        {\n          \"channel\": 0,\n          \"enable\": 0,\n          \"id\": 30,\n          \"imgName\": \"\",\n          \"name\": \"pos31\"\n        },\n        {\n          \"channel\": 0,\n          \"enable\": 0,\n          \"id\": 31,\n          \"imgName\": \"\",\n          \"name\": \"pos32\"\n        },\n        {\n          \"channel\": 0,\n          \"enable\": 0,\n          \"id\": 32,\n          \"imgName\": \"\",\n          \"name\": \"pos33\"\n        },\n        {\n          \"channel\": 0,\n          \"enable\": 0,\n          \"id\": 33,\n          \"imgName\": \"\",\n          \"name\": \"pos34\"\n        },\n        {\n          \"channel\": 0,\n          \"enable\": 0,\n          \"id\": 34,\n          \"imgName\": \"\",\n          \"name\": \"pos35\"\n        },\n        {\n          \"channel\": 0,\n          \"enable\": 0,\n          \"id\": 35,\n          \"imgName\": \"\",\n          \"name\": \"pos36\"\n        },\n        {\n          \"channel\": 0,\n          \"enable\": 0,\n          \"id\": 36,\n          \"imgName\": \"\",\n          \"name\": \"pos37\"\n        },\n        {\n          \"channel\": 0,\n          \"enable\": 0,\n          \"id\": 37,\n          \"imgName\": \"\",\n          \"name\": \"pos38\"\n        },\n        {\n          \"channel\": 0,\n          \"enable\": 0,\n          \"id\": 38,\n          \"imgName\": \"\",\n          \"name\": \"pos39\"\n        },\n        {\n          \"channel\": 0,\n          \"enable\": 0,\n          \"id\": 39,\n          \"imgName\": \"\",\n          \"name\": \"pos40\"\n        },\n        {\n          \"channel\": 0,\n          \"enable\": 0,\n          \"id\": 40,\n          \"imgName\": \"\",\n          \"name\": \"pos41\"\n        },\n        {\n          \"channel\": 0,\n          \"enable\": 0,\n          \"id\": 41,\n          \"imgName\": \"\",\n          \"name\": \"pos42\"\n        },\n        {\n          \"channel\": 0,\n          \"enable\": 0,\n          \"id\": 42,\n          \"imgName\": \"\",\n          \"name\": \"pos43\"\n        },\n        {\n          \"channel\": 0,\n          \"enable\": 0,\n          \"id\": 43,\n          \"imgName\": \"\",\n          \"name\": \"pos44\"\n        },\n        {\n          \"channel\": 0,\n          \"enable\": 0,\n          \"id\": 44,\n          \"imgName\": \"\",\n          \"name\": \"pos45\"\n        },\n        {\n          \"channel\": 0,\n          \"enable\": 0,\n          \"id\": 45,\n          \"imgName\": \"\",\n          \"name\": \"pos46\"\n        },\n        {\n          \"channel\": 0,\n          \"enable\": 0,\n          \"id\": 46,\n          \"imgName\": \"\",\n          \"name\": \"pos47\"\n        },\n        {\n          \"channel\": 0,\n          \"enable\": 0,\n          \"id\": 47,\n          \"imgName\": \"\",\n          \"name\": \"pos48\"\n        },\n        {\n          \"channel\": 0,\n          \"enable\": 0,\n          \"id\": 48,\n          \"imgName\": \"\",\n          \"name\": \"pos49\"\n        },\n        {\n          \"channel\": 0,\n          \"enable\": 0,\n          \"id\": 49,\n          \"imgName\": \"\",\n          \"name\": \"pos50\"\n        },\n        {\n          \"channel\": 0,\n          \"enable\": 0,\n          \"id\": 50,\n          \"imgName\": \"\",\n          \"name\": \"pos51\"\n        },\n        {\n          \"channel\": 0,\n          \"enable\": 0,\n          \"id\": 51,\n          \"imgName\": \"\",\n          \"name\": \"pos52\"\n        },\n        {\n          \"channel\": 0,\n          \"enable\": 0,\n          \"id\": 52,\n          \"imgName\": \"\",\n          \"name\": \"pos53\"\n        },\n        {\n          \"channel\": 0,\n          \"enable\": 0,\n          \"id\": 53,\n          \"imgName\": \"\",\n          \"name\": \"pos54\"\n        },\n        {\n          \"channel\": 0,\n          \"enable\": 0,\n          \"id\": 54,\n          \"imgName\": \"\",\n          \"name\": \"pos55\"\n        },\n        {\n          \"channel\": 0,\n          \"enable\": 0,\n          \"id\": 55,\n          \"imgName\": \"\",\n          \"name\": \"pos56\"\n        },\n        {\n          \"channel\": 0,\n          \"enable\": 0,\n          \"id\": 56,\n          \"imgName\": \"\",\n          \"name\": \"pos57\"\n        },\n        {\n          \"channel\": 0,\n          \"enable\": 0,\n          \"id\": 57,\n          \"imgName\": \"\",\n          \"name\": \"pos58\"\n        },\n        {\n          \"channel\": 0,\n          \"enable\": 0,\n          \"id\": 58,\n          \"imgName\": \"\",\n          \"name\": \"pos59\"\n        },\n        {\n          \"channel\": 0,\n          \"enable\": 0,\n          \"id\": 59,\n          \"imgName\": \"\",\n          \"name\": \"pos60\"\n        },\n        {\n          \"channel\": 0,\n          \"enable\": 0,\n          \"id\": 60,\n          \"imgName\": \"\",\n          \"name\": \"pos61\"\n        },\n        {\n          \"channel\": 0,\n          \"enable\": 0,\n          \"id\": 61,\n          \"imgName\": \"\",\n          \"name\": \"pos62\"\n        },\n        {\n          \"channel\": 0,\n          \"enable\": 0,\n          \"id\": 62,\n          \"imgName\": \"\",\n          \"name\": \"pos63\"\n        },\n        {\n          \"channel\": 0,\n          \"enable\": 0,\n          \"id\": 63,\n          \"imgName\": \"\",\n          \"name\": \"pos64\"\n        }\n      ]\n    }\n  }\n]\n"
  },
  {
    "path": "examples/response/GetRec.json",
    "content": "[\n  {\n    \"cmd\": \"GetRec\",\n    \"code\": 0,\n    \"initial\": {\n      \"Rec\": {\n        \"channel\": 0,\n        \"overwrite\": 1,\n        \"postRec\": \"15 Seconds\",\n        \"preRec\": 1,\n        \"schedule\": {\n          \"enable\": 1,\n          \"table\": \"111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111\"\n        }\n      }\n    },\n    \"range\": {\n      \"Rec\": {\n        \"channel\": 0,\n        \"overwrite\": \"boolean\",\n        \"postRec\": [\n          \"15 Seconds\",\n          \"30 Seconds\",\n          \"1 Minute\"\n        ],\n        \"preRec\": \"boolean\",\n        \"schedule\": {\n          \"enable\": \"boolean\"\n        }\n      }\n    },\n    \"value\": {\n      \"Rec\": {\n        \"channel\": 0,\n        \"overwrite\": 1,\n        \"postRec\": \"15 Seconds\",\n        \"preRec\": 1,\n        \"schedule\": {\n          \"enable\": 1,\n          \"table\": \"000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\"\n        }\n      }\n    }\n  }\n]\n"
  },
  {
    "path": "examples/response/GetUser.json",
    "content": "[\n  {\n    \"cmd\": \"GetUser\",\n    \"code\": 0,\n    \"initial\": {\n      \"User\": {\n        \"level\": \"guest\"\n      }\n    },\n    \"range\": {\n      \"User\": {\n        \"level\": [\n          \"guest\",\n          \"admin\"\n        ],\n        \"password\": {\n          \"maxLen\": 31,\n          \"minLen\": 6\n        },\n        \"userName\": {\n          \"maxLen\": 31,\n          \"minLen\": 1\n        }\n      }\n    },\n    \"value\": {\n      \"User\": [\n        {\n          \"level\": \"admin\",\n          \"userName\": \"admin\"\n        }\n      ]\n    }\n  }\n]\n"
  },
  {
    "path": "examples/response/Login.json",
    "content": "[\n  {\n    \"cmd\": \"Login\",\n    \"code\": 0,\n    \"value\": { \"Token\": { \"leaseTime\": 3600, \"name\": \"xxxxxxxxxxxx\" } }\n  }\n]\n"
  },
  {
    "path": "examples/response/Logout.json",
    "content": "[\n  {\n    \"cmd\": \"Logout\",\n    \"code\": 0,\n    \"value\": { \"rspCode\": 200 }\n  }\n]\n"
  },
  {
    "path": "examples/response/PtzCheck.json",
    "content": "[{\"cmd\": \"PtzCheck\", \"code\": 0, \"value\": {\"rspCode\": 200}}]"
  },
  {
    "path": "examples/response/PtzCtrl.json",
    "content": "[\n    {\n       \"cmd\" : \"PtzCtrl\",\n       \"code\" : 0,\n       \"value\" : {\n          \"rspCode\" : 200\n       }\n    }\n ]"
  },
  {
    "path": "examples/response/Reboot.json",
    "content": "[\n    {\n        \"cmd\": \"Reboot\",\n        \"code\": 0,\n        \"value\": {\n            \"rspCode\": 200\n        }\n    }\n]\n"
  },
  {
    "path": "examples/response/SetAdvImageSettings.json",
    "content": "[\n    {\n       \"cmd\" : \"SetIsp\",\n       \"code\" : 0,\n       \"value\" : {\n          \"rspCode\" : 200\n       }\n    }\n ]\n "
  },
  {
    "path": "examples/response/SetImageSettings.json",
    "content": "[\n    {\n       \"cmd\" : \"SetImage\",\n       \"code\" : 0,\n       \"value\" : {\n          \"rspCode\" : 200\n       }\n    }\n ]\n "
  },
  {
    "path": "examples/response/SetPtzPreset.json",
    "content": "[\n    {\n       \"cmd\" : \"SetPtzPreset\",\n       \"code\" : 0,\n       \"value\" : {\n          \"rspCode\" : 200\n       }\n    }\n ]\n "
  },
  {
    "path": "examples/stream_gui.py",
    "content": "import sys\nimport os\nfrom configparser import RawConfigParser\nfrom PyQt6.QtWidgets import QApplication, QWidget, QVBoxLayout, QHBoxLayout, QSlider\nfrom PyQt6.QtMultimedia import QMediaPlayer, QAudioOutput\nfrom PyQt6.QtMultimediaWidgets import QVideoWidget\nfrom PyQt6.QtCore import Qt, QUrl, QTimer\nfrom PyQt6.QtGui import QWheelEvent\nfrom reolinkapi import Camera\nfrom threading import Lock\n\nimport urllib3\nurllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)\n\ndef read_config(props_path: str) -> dict:\n    config = RawConfigParser()\n    assert os.path.exists(props_path), f\"Path does not exist: {props_path}\"\n    config.read(props_path)\n    return config\n\nclass ZoomSlider(QSlider):\n    def __init__(self, *args, **kwargs):\n        super().__init__(*args, **kwargs)\n\n    def keyPressEvent(self, event):\n        if event.key() in (Qt.Key.Key_Left, Qt.Key.Key_Right, Qt.Key.Key_Up, Qt.Key.Key_Down):\n            event.ignore()\n        else:\n            super().keyPressEvent(event)\n\nclass CameraPlayer(QWidget):\n    def __init__(self, rtsp_url_wide, rtsp_url_telephoto, camera: Camera):\n        super().__init__()\n        self.setWindowTitle(\"Reolink PTZ Streamer\")\n        self.setGeometry(10, 10, 2400, 900)\n        self.setFocusPolicy(Qt.FocusPolicy.StrongFocus) \n\n        self.camera = camera\n        self.zoom_timer = QTimer(self)\n        self.zoom_timer.timeout.connect(self.stop_zoom)\n\n        # Create media players\n        self.media_player_wide = QMediaPlayer()\n        self.media_player_telephoto = QMediaPlayer()\n\n        # Create video widgets\n        self.video_widget_wide = QVideoWidget()\n        self.video_widget_telephoto = QVideoWidget()\n        self.media_player_wide.setVideoOutput(self.video_widget_wide)\n        self.media_player_telephoto.setVideoOutput(self.video_widget_telephoto)\n        self.video_widget_wide.wheelEvent = self.handle_wheel_event\n        self.video_widget_telephoto.wheelEvent = self.handle_wheel_event\n\n        # Create layout\n        layout = QHBoxLayout()\n        layout.addWidget(self.video_widget_wide, 2)\n        layout.addWidget(self.video_widget_telephoto, 2)\n        self.setLayout(layout)\n\n        # Start playing the streams\n        self.media_player_wide.setSource(QUrl(rtsp_url_wide))\n        self.media_player_telephoto.setSource(QUrl(rtsp_url_telephoto))\n        self.media_player_wide.play()\n        self.media_player_telephoto.play()\n\n\n    def keyPressEvent(self, event):\n        if event.isAutoRepeat():\n            return\n        if event.key() == Qt.Key.Key_Escape:\n            self.close()\n        elif event.key() in (Qt.Key.Key_Left, Qt.Key.Key_Right, Qt.Key.Key_Up, Qt.Key.Key_Down):\n            self.start_move(event.key())\n\n    def keyReleaseEvent(self, event):\n        if event.isAutoRepeat():\n            return\n        if event.key() in (Qt.Key.Key_Left, Qt.Key.Key_Right, Qt.Key.Key_Up, Qt.Key.Key_Down):\n            self.stop_move()\n\n    def start_move(self, key):\n        direction = {\n            Qt.Key.Key_Left: \"left\",\n            Qt.Key.Key_Right: \"right\",\n            Qt.Key.Key_Up: \"up\",\n            Qt.Key.Key_Down: \"down\"\n        }.get(key)\n\n        if direction:\n            self.move_camera(direction)\n\n    def stop_move(self):\n        response = self.camera.stop_ptz()\n        print(\"Stop PTZ\")\n        if response[0].get('code') != 0:\n            self.show_error_message(\"Failed to stop camera movement\", str(response[0]))\n\n    def move_camera(self, direction):\n        speed = 25\n        if direction == \"left\":\n            response = self.camera.move_left(speed)\n        elif direction == \"right\":\n            response = self.camera.move_right(speed)\n        elif direction == \"up\":\n            response = self.camera.move_up(speed)\n        elif direction == \"down\":\n            response = self.camera.move_down(speed)\n        else:\n            print(f\"Invalid direction: {direction}\")\n            return\n\n        if response[0].get('code') == 0:\n            print(f\"Moving camera {direction}\")\n        else:\n            self.show_error_message(f\"Failed to move camera {direction}\", str(response[0]))\n\n    def handle_wheel_event(self, event: QWheelEvent):\n        delta = event.angleDelta().y()\n        if delta > 0:\n            self.zoom_in()\n        elif delta < 0:\n            self.zoom_out()\n\n    def zoom_in(self):\n        self.start_zoom('in')\n\n    def zoom_out(self):\n        self.start_zoom('out')\n\n    def start_zoom(self, direction: str):\n        self.zoom_timer.stop()  # Stop any ongoing zoom timer\n        speed = 60  # You can adjust this value as needed\n        if direction == 'in':\n            response = self.camera.start_zooming_in(speed)\n        else:\n            response = self.camera.start_zooming_out(speed)\n        \n        if response[0].get('code') == 0:\n            print(f\"Zooming {direction}\")\n            self.zoom_timer.start(200)  # Stop zooming after 200ms\n        else:\n            self.show_error_message(f\"Failed to start zooming {direction}\", str(response[0]))\n\n    def stop_zoom(self):\n        response = self.camera.stop_zooming()\n        if response[0].get('code') != 0:\n            self.show_error_message(\"Failed to stop zooming\", str(response[0]))\n\n    def show_error_message(self, title, message):\n        print(f\"Error: {title} {message}\")\n\n    def handle_error(self, error):\n        print(f\"Media player error: {error}\")\n\n\nif __name__ == '__main__':\n    # Read in your ip, username, & password from the configuration file\n    config = read_config('camera.cfg')\n    ip = config.get('camera', 'ip')\n    un = config.get('camera', 'username')\n    pw = config.get('camera', 'password')\n\n    # Connect to camera\n    cam = Camera(ip, un, pw, https=True)\n\n    rtsp_url_wide =      f\"rtsp://{un}:{pw}@{ip}/Preview_01_sub\"\n    rtsp_url_telephoto = f\"rtsp://{un}:{pw}@{ip}/Preview_02_sub\"\n\n    # Connect to camera\n    cam = Camera(ip, un, pw, https=True)\n\n    app = QApplication(sys.argv)\n    player = CameraPlayer(rtsp_url_wide, rtsp_url_telephoto, cam)\n    player.show()\n    sys.exit(app.exec())\n"
  },
  {
    "path": "examples/streaming_video.py",
    "content": "import cv2\nfrom reolinkapi import Camera\n\n\ndef non_blocking():\n    print(\"calling non-blocking\")\n\n    def inner_callback(img):\n        cv2.imshow(\"name\", maintain_aspect_ratio_resize(img, width=600))\n        print(\"got the image non-blocking\")\n        key = cv2.waitKey(1)\n        if key == ord('q'):\n            cv2.destroyAllWindows()\n            exit(1)\n\n    c = Camera(\"192.168.1.112\", \"admin\", \"jUa2kUzi\")\n    # t in this case is a thread\n    t = c.open_video_stream(callback=inner_callback)\n\n    print(t.is_alive())\n    while True:\n        if not t.is_alive():\n            print(\"continuing\")\n            break\n        # stop the stream\n        # client.stop_stream()\n\n\ndef blocking():\n    c = Camera(\"192.168.1.112\", \"admin\", \"jUa2kUzi\")\n    # stream in this case is a generator returning an image (in mat format)\n    stream = c.open_video_stream()\n\n    # using next()\n    # while True:\n    #     img = next(stream)\n    #     cv2.imshow(\"name\", maintain_aspect_ratio_resize(img, width=600))\n    #     print(\"got the image blocking\")\n    #     key = cv2.waitKey(1)\n    #     if key == ord('q'):\n    #         cv2.destroyAllWindows()\n    #         exit(1)\n\n    # or using a for loop\n    for img in stream:\n        cv2.imshow(\"name\", maintain_aspect_ratio_resize(img, width=600))\n        print(\"got the image blocking\")\n        key = cv2.waitKey(1)\n        if key == ord('q'):\n            cv2.destroyAllWindows()\n            exit(1)\n\n\n# Resizes a image and maintains aspect ratio\ndef maintain_aspect_ratio_resize(image, width=None, height=None, inter=cv2.INTER_AREA):\n    # Grab the image size and initialize dimensions\n    dim = None\n    (h, w) = image.shape[:2]\n\n    # Return original image if no need to resize\n    if width is None and height is None:\n        return image\n\n    # We are resizing height if width is none\n    if width is None:\n        # Calculate the ratio of the height and construct the dimensions\n        r = height / float(h)\n        dim = (int(w * r), height)\n    # We are resizing width if height is none\n    else:\n        # Calculate the ratio of the 0idth and construct the dimensions\n        r = width / float(w)\n        dim = (width, int(h * r))\n\n    # Return the resized image\n    return cv2.resize(image, dim, interpolation=inter)\n\n\n# Call the methods. Either Blocking (using generator) or Non-Blocking using threads\n# non_blocking()\nblocking()\n"
  },
  {
    "path": "examples/video_review_gui.py",
    "content": "# Video review GUI\n# https://github.com/sven337/ReolinkLinux/wiki#reolink-video-review-gui\n\nimport os\nimport signal\nimport sys\nimport re\nimport datetime\nimport subprocess\nimport argparse\nfrom configparser import RawConfigParser\nfrom datetime import datetime as dt, timedelta\nfrom reolinkapi import Camera\nfrom PyQt6.QtWidgets import QApplication, QVBoxLayout, QHBoxLayout, QWidget, QTableWidget, QTableWidgetItem, QPushButton, QLabel, QFileDialog, QHeaderView, QStyle, QSlider, QStyleOptionSlider, QSplitter, QTreeWidget, QTreeWidgetItem, QTreeWidgetItemIterator\nfrom PyQt6.QtMultimedia import QMediaPlayer, QAudioOutput\nfrom PyQt6.QtMultimediaWidgets import QVideoWidget\nfrom PyQt6.QtCore import Qt, QUrl, QTimer, QThread, pyqtSignal, QMutex, QWaitCondition\nfrom PyQt6.QtGui import QColor, QBrush, QFont, QIcon\nfrom collections import deque\n\nimport urllib3\nurllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)\n\ndef path_name_from_camera_path(fname):\n   # Mp4Record/2024-08-12/RecM13_DST20240812_214255_214348_1F1E828_4DDA4D.mp4\n   return fname.replace('/', '_')\n\n# Function to decode hex values into individual flags\ndef decode_hex_to_flags(hex_value):\n    flags_mapping = {\n        'resolution_index': (21, 7), \n        'tv_system': (20, 1),        \n        'framerate': (13, 7),        \n        'audio_index': (11, 2),      \n        'ai_pd': (10, 1),          # person  \n        'ai_fd': (9, 1),              # face\n        'ai_vd': (8, 1),             # vehicle\n        'ai_ad': (7, 1),             # animal\n        'encoder_type_index': (5, 2),\n        'is_schedule_record': (4, 1), #scheduled\n        'is_motion_record': (3, 1),  # motion detected\n        'is_rf_record': (2, 1),      \n        'is_doorbell_press_record': (1, 1),\n        'ai_other': (0, 1)               \n    }\n    hex_value = int(hex_value, 16)  # Convert hex string to integer\n    flag_values = {}\n    for flag, (bit_position, bit_size) in flags_mapping.items():\n        mask = ((1 << bit_size) - 1) << bit_position\n        flag_values[flag] = (hex_value & mask) >> bit_position\n    return flag_values\n\ndef parse_filename(file_name):\n    #  Mp4Record_2024-08-12_RecM13_DST20240812_214255_214348_1F1E828_4DDA4D.mp4\n    #  Mp4Record_2024-09-13-RecS09_DST20240907_084519_084612_0_55289080000000_307BC0.mp4\n    # https://github.com/sven337/ReolinkLinux/wiki/Figuring-out-the-file-names#file-name-structure\n    pattern = r'.*?Mp4Record_(\\d{4}-\\d{2}-\\d{2})_Rec[MS](\\d)(\\d)_(DST)?(\\d{8})_(\\d{6})_(\\d{6})'\n    v3_suffix = r'.*_(\\w{4,8})_(\\w{4,8})\\.mp4'\n    v9_suffix = r'.*_(\\d)_(\\w{7})(\\w{7})_(\\w{1,8})\\.mp4'\n    match = re.match(pattern, file_name)\n\n    out = {}\n    version = 0\n\n    if match:\n        date = match.group(1)  # YYYY-MM-DD\n        channel = int(match.group(2))  \n        version = int(match.group(3)) # version\n        start_date = match.group(5)  # YYYYMMDD\n        start_time = match.group(6)  # HHMMSS\n        end_time = match.group(7)  # HHMMSS\n\n        # Combine date and start time into a datetime object\n        start_datetime = datetime.datetime.strptime(f\"{start_date} {start_time}\", \"%Y%m%d %H%M%S\")\n        \n        out = {'start_datetime': start_datetime, 'channel': channel, 'end_time': end_time }\n    else:\n        print(\"parse error\")\n        return None\n       \n    if version == 9:\n        match = re.match(v9_suffix, file_name)\n        if not match:\n            print(f\"v9 parse error for {file_name}\")\n            return None\n\n        animal_type = match.group(1)\n        flags_hex1 = match.group(2)\n        flags_hex2 = match.group(3)\n        file_size = int(match.group(4), 16)\n\n        triggers = decode_hex_to_flags(flags_hex1)\n\n        out.update({'animal_type' : animal_type, 'file_size' : file_size, 'triggers' : triggers })\n\n    elif version == 2 or version == 3:\n        match = re.match(v3_suffix, file_name)\n        if not match:\n            print(f\"v3 parse error for {file_name}\")\n            return None\n\n        flags_hex = match.group(1)\n        file_size = int(match.group(2), 16)\n\n        triggers = decode_hex_to_flags(flags_hex)\n\n        out.update({'file_size' : file_size, 'triggers' : triggers })\n\n    return out\n\nclass ClickableSlider(QSlider):\n    def mousePressEvent(self, event):\n        if event.button() == Qt.MouseButton.LeftButton:\n            val = self.pixelPosToRangeValue(event.pos())\n            self.setValue(val)\n        super().mousePressEvent(event)\n\n    def pixelPosToRangeValue(self, pos):\n        opt = QStyleOptionSlider()\n        self.initStyleOption(opt)\n        gr = self.style().subControlRect(QStyle.ComplexControl.CC_Slider, opt, QStyle.SubControl.SC_SliderGroove, self)\n        sr = self.style().subControlRect(QStyle.ComplexControl.CC_Slider, opt, QStyle.SubControl.SC_SliderHandle, self)\n\n        if self.orientation() == Qt.Orientation.Horizontal:\n            sliderLength = sr.width()\n            sliderMin = gr.x()\n            sliderMax = gr.right() - sliderLength + 1\n            pos = pos.x()\n        else:\n            sliderLength = sr.height()\n            sliderMin = gr.y()\n            sliderMax = gr.bottom() - sliderLength + 1\n            pos = pos.y()\n\n        return QStyle.sliderValueFromPosition(self.minimum(), self.maximum(), pos - sliderMin, sliderMax - sliderMin, opt.upsideDown)\n\nclass DownloadThread(QThread):\n    download_complete = pyqtSignal(str, bool)\n    download_start = pyqtSignal(str)\n\n    def __init__(self, download_queue, cam):\n        super().__init__()\n        self.download_queue = download_queue\n        self.cam = cam\n        self.mutex = QMutex()\n        self.wait_condition = QWaitCondition()\n        self.is_running = True\n\n    def run(self):\n        while self.is_running:\n            self.mutex.lock()\n            if len(self.download_queue) == 0:\n                self.wait_condition.wait(self.mutex)\n            self.mutex.unlock()\n\n            if not self.is_running:\n                break\n\n            try:\n                fname, output_path = self.download_queue.popleft()\n                output_path = os.path.join(video_storage_dir, output_path)\n                print(f\"Downloading: {fname}\")\n                self.download_start.emit(output_path)\n                resp = self.cam.get_file(fname, output_path=output_path)\n                if resp:\n                    print(f\"Download complete: {output_path}\")\n                    self.download_complete.emit(output_path, True)\n                else:\n                    print(f\"Download failed: {fname}\")\n                    self.download_complete.emit(output_path, False)\n            except IndexError:\n                pass\n\n    def stop(self):\n        self.mutex.lock()\n        self.is_running = False\n        self.mutex.unlock()\n        self.wait_condition.wakeAll()\n\n    def add_to_queue(self, fname, output_path, left=False):\n        self.mutex.lock()\n        if left:\n            self.download_queue.appendleft((fname, output_path))\n        else:\n            self.download_queue.append((fname, output_path))\n        self.wait_condition.wakeOne()\n        self.mutex.unlock()\n\n\nclass VideoPlayer(QWidget):\n    file_exists_signal = pyqtSignal(str, bool)\n\n    def __init__(self, video_files):\n        super().__init__()\n        self.setWindowTitle(\"Reolink Video Review GUI\")\n        self.cam = cam\n        self.download_queue = deque()\n        self.download_thread = DownloadThread(self.download_queue, self.cam)\n        self.download_thread.download_start.connect(self.on_download_start)\n        self.download_thread.download_complete.connect(self.on_download_complete)\n        self.download_thread.start()\n\n        # Create media player\n        self.media_player = QMediaPlayer()\n        self.media_player.errorOccurred.connect(self.handle_media_player_error)\n\n        # Create video widget\n        self.video_widget = QVideoWidget()\n        self.media_player.setVideoOutput(self.video_widget)\n        self.media_player.setPlaybackRate(1.5)\n        \n        # Create table widget to display video files\n        self.video_tree = QTreeWidget()\n        self.video_tree.setColumnCount(10)\n        self.video_tree.setHeaderLabels([\"Status\", \"Video Path\", \"Start Datetime\", \"End Time\", \"Channel\", \"Person\", \"Vehicle\", \"Pet\", \"Motion\", \"Timer\"])\n        self.video_tree.setSortingEnabled(True)\n        self.video_tree.itemClicked.connect(self.play_video)\n\n        # Set smaller default column widths\n        self.video_tree.setColumnWidth(0, 35)   # Status\n        self.video_tree.setColumnWidth(1, 120)  # Video Path\n        self.video_tree.setColumnWidth(2, 130)  # Start Datetime\n        self.video_tree.setColumnWidth(3, 70)   # End Time\n        self.video_tree.setColumnWidth(4, 35)   # Channel\n        self.video_tree.setColumnWidth(5, 35)   # Person\n        self.video_tree.setColumnWidth(6, 35)   # Vehicle\n        self.video_tree.setColumnWidth(7, 35)   # Pet\n        self.video_tree.setColumnWidth(8, 35)   # Motion\n        self.video_tree.setColumnWidth(9, 30)   # Timer\n\n        self.video_tree.setIndentation(10)\n\n        QIcon.setThemeName(\"Adwaita\")\n\n        # Create open button to select video files\n        self.open_button = QPushButton(\"Open Videos\")\n        self.open_button.clicked.connect(self.open_videos)\n        \n        self.play_button = QPushButton()\n        self.play_button.setIcon(self.style().standardIcon(QStyle.StandardPixmap.SP_MediaPlay))\n        self.play_button.clicked.connect(self.play_pause)\n\n        self.mpv_button = QPushButton(\"MPV\")\n        self.mpv_button.clicked.connect(self.open_in_mpv)\n       \n        self.get_highres_button = QPushButton(\"GetHighRes\")\n        self.get_highres_button.clicked.connect(self.get_highres_stream_for_file)\n        self.get_highres_button.setEnabled(False)  # Disable by default\n\n        # Create seek slider\n        self.seek_slider = ClickableSlider(Qt.Orientation.Horizontal)\n        self.seek_slider.setRange(0, 0)\n        self.seek_slider.sliderPressed.connect(self.seek_slider_pressed)\n        self.seek_slider.sliderReleased.connect(self.seek_slider_released)\n        self.seek_slider.sliderMoved.connect(self.seek_slider_moved)\n        self.media_player.positionChanged.connect(self.update_position)\n        self.media_player.durationChanged.connect(self.update_duration)\n        \n        # Create playback speed slider\n        self.speed_slider = QSlider(Qt.Orientation.Horizontal)\n        self.speed_slider.setRange(50, 300)\n        self.speed_slider.setValue(200)\n        self.speed_slider.valueChanged.connect(self.set_speed)\n        speed_label = QLabel(\"Speed: 2.0x\")\n        self.speed_slider.valueChanged.connect(lambda v: speed_label.setText(f\"Speed: {v/100:.1f}x\"))\n        \n        main_layout = QHBoxLayout()\n        # Create a splitter\n        splitter = QSplitter(Qt.Orientation.Horizontal)\n        \n        # Left side (table and open button)\n        left_widget = QWidget()\n        left_layout = QVBoxLayout(left_widget)\n        left_layout.addWidget(self.video_tree)\n        left_layout.addWidget(self.open_button)\n        splitter.addWidget(left_widget)\n        \n        # Right side (video player and controls)\n        right_widget = QWidget()\n        right_layout = QVBoxLayout(right_widget)\n        right_layout.addWidget(self.video_widget, 1)\n\n        controls_widget = QWidget()\n        controls_layout = QVBoxLayout(controls_widget)\n\n        control_layout = QHBoxLayout()\n        control_layout.addWidget(self.play_button)\n        control_layout.addWidget(self.seek_slider)\n        control_layout.addWidget(self.mpv_button)\n        control_layout.addWidget(self.get_highres_button)\n        controls_layout.addLayout(control_layout)\n\n        speed_layout = QHBoxLayout()\n        speed_layout.addWidget(QLabel(\"Speed:\"))\n        speed_layout.addWidget(self.speed_slider)\n        speed_layout.addWidget(speed_label)\n        controls_layout.addLayout(speed_layout)\n        right_layout.addWidget(controls_widget)\n        splitter.addWidget(right_widget)\n        \n        # Set initial sizes\n        splitter.setSizes([300, 700]) \n        \n        main_layout.addWidget(splitter)\n        self.setLayout(main_layout)\n        self.file_exists_signal.connect(self.on_download_complete)\n\n        self.add_initial_videos(video_files)\n\n    def add_initial_videos(self, video_files):\n        for video_path in video_files:\n            self.add_video(video_path)\n        self.video_tree.sortItems(2, Qt.SortOrder.DescendingOrder)\n#        self.video_tree.expandAll()\n\n    def open_videos(self):\n        file_dialog = QFileDialog(self)\n        file_dialog.setNameFilters([\"Videos (*.mp4 *.avi *.mov)\"])\n        file_dialog.setFileMode(QFileDialog.FileMode.ExistingFiles) \n        if file_dialog.exec():\n            self.video_tree.setSortingEnabled(False)\n            for file in file_dialog.selectedFiles():\n               self.add_video(os.path.basename(file))\n            self.video_tree.setSortingEnabled(True)\n        self.video_tree.sortItems(2, Qt.SortOrder.DescendingOrder)\n#        self.video_tree.expandAll()\n\n    def add_video(self, video_path):\n        # We are passed the camera file name, e.g. Mp4Record/2024-08-12/RecM13_DST20240812_214255_214348_1F1E828_4DDA4D.mp4\n        file_path = path_name_from_camera_path(video_path)  \n        base_file_name = file_path\n        parsed_data = parse_filename(file_path)\n        if not parsed_data:\n            print(f\"Could not parse file {video_path}\")\n            return\n\n        start_datetime = parsed_data['start_datetime']\n        channel = parsed_data['channel']\n\n        end_time = datetime.datetime.strptime(parsed_data['end_time'], \"%H%M%S\")\n        end_time_str = end_time.strftime(\"%H:%M:%S\")\n\n        video_item = QTreeWidgetItem()\n        video_item.setText(0, \"\") # Status\n        video_item.setTextAlignment(0, Qt.AlignmentFlag.AlignCenter)\n        video_item.setText(1, base_file_name)\n        video_item.setText(2, start_datetime.strftime(\"%Y-%m-%d %H:%M:%S\"))\n        video_item.setData(2, Qt.ItemDataRole.UserRole, parsed_data['start_datetime'])\n        video_item.setText(3, end_time_str)\n        video_item.setText(4, str(channel))\n        video_item.setText(5, \"✓\" if parsed_data['triggers']['ai_pd'] else \"\")\n        video_item.setText(6, \"✓\" if parsed_data['triggers']['ai_vd'] else \"\")\n        video_item.setText(7, \"✓\" if parsed_data['triggers']['ai_ad'] else \"\")\n        video_item.setText(8, \"✓\" if parsed_data['triggers']['is_motion_record'] else \"\")\n        video_item.setText(9, \"✓\" if parsed_data['triggers']['is_schedule_record'] else \"\")\n\n        if parsed_data['triggers']['ai_other']:\n            print(f\"File {file_path} has ai_other flag!\")\n        \n        video_item.setToolTip(1, base_file_name)\n        # Set the style for queued status\n        grey_color = QColor(200, 200, 200)  # Light grey\n        video_item.setForeground(1, QBrush(grey_color))\n        font = QFont()\n        font.setItalic(True)\n        video_item.setFont(1, font)\n\n        # Make the fields non-editable\n        iterator = QTreeWidgetItemIterator(self.video_tree)\n        while iterator.value():\n            item = iterator.value()\n            item.setFlags(item.flags() & ~Qt.ItemFlag.ItemIsEditable)\n            iterator += 1\n\n        # Find a potentially pre-existing channel0 item for this datetime, if so, add as a child\n        # This lets channel1 appear as a child, but also main & sub videos appear in the same group\n        channel_0_item = self.find_channel_0_item(start_datetime)\n        \n        if channel_0_item:\n            # Check if the current item is a main stream and the existing channel_0_item is a sub stream\n            if \"RecM\" in base_file_name and \"RecS\" in channel_0_item.text(1):\n                # Make the current main stream item the new parent\n                new_parent = video_item\n                # Move all children of the sub stream item to the new main stream item\n                while channel_0_item.childCount() > 0:\n                    child = channel_0_item.takeChild(0)\n                    new_parent.addChild(child)\n                # Remove the old sub stream item\n                parent = channel_0_item.parent()\n                if parent:\n                    parent.removeChild(channel_0_item)\n                else:\n                    index = self.video_tree.indexOfTopLevelItem(channel_0_item)\n                    self.video_tree.takeTopLevelItem(index)\n                # Add the new main stream item as a top-level item\n                self.video_tree.addTopLevelItem(new_parent)\n            else:\n                # If it's not a main stream replacing a sub stream, add as a child as before\n                channel_0_item.addChild(video_item)\n        else:\n            self.video_tree.addTopLevelItem(video_item)\n\n        output_path = os.path.join(video_storage_dir, base_file_name)\n        expected_size = parsed_data['file_size']\n\n        need_download = True\n        if os.path.isfile(output_path):\n            actual_size = os.path.getsize(output_path)\n            if actual_size == expected_size:\n                need_download = False\n                self.file_exists_signal.emit(output_path, True)\n            else:\n                print(f\"File size mismatch for {output_path}. Expected: {expected_size}, Actual: {actual_size}. Downloading again\")\n        \n        if need_download:\n            video_item.setIcon(1, self.style().standardIcon(QStyle.StandardPixmap.SP_CommandLink))\n            self.download_thread.add_to_queue(video_path, base_file_name)\n\n    def find_channel_0_item(self, datetime_obj):\n        # Truncate seconds to nearest 10\n        truncated_seconds = datetime_obj.second - (datetime_obj.second % 10)\n        truncated_datetime = datetime_obj.replace(second=truncated_seconds)\n        \n        for i in range(self.video_tree.topLevelItemCount()):\n            item = self.video_tree.topLevelItem(i)\n            item_datetime = item.data(2, Qt.ItemDataRole.UserRole)\n            item_truncated = item_datetime.replace(second=item_datetime.second - (item_datetime.second % 10))\n            if item_truncated == truncated_datetime:\n                return item\n        return None\n\n    def find_item_by_path(self, path):\n        iterator = QTreeWidgetItemIterator(self.video_tree)\n        while iterator.value():\n            item = iterator.value()\n            text = item.text(1)\n            if text == path:\n                return item\n            iterator += 1\n        print(f\"Could not find item by path {path}\")\n        return None\n\n    def on_download_complete(self, video_path, success):\n        item = self.find_item_by_path(os.path.basename(video_path))\n        if not item:\n            print(f\"on_download_complete {video_path} did not find item?!\")\n            return\n        item.setForeground(1, QBrush(QColor(0, 0, 0)))  # Black color for normal text\n        font = item.font(1)\n        font.setItalic(False)\n        font.setBold(False)\n        item.setFont(1, font)\n        if success:\n            if \"RecS\" in item.text(1):\n                # One day (hopefully) offer the option to download the\n                # high-res version This is not trivial because we have to\n                # re-do a camera search for the relevant time period and\n                # match based on start and end dates (+/- one second in my\n                # experience)\n                # For now simply display that this is low-res.\n                item.setText(0, \"sub\")\n            item.setIcon(1, QIcon())\n        else:\n            item.setIcon(1, self.style().standardIcon(QStyle.StandardPixmap.SP_MessageBoxCritical))\n\n\n    def on_download_start(self, video_path):\n        item = self.find_item_by_path(os.path.basename(video_path))\n        if item:\n            grey_color = QColor(200, 200, 200)  # Light grey\n            item.setForeground(1, QBrush(grey_color))\n            font = item.font(1)\n            font.setBold(True)\n            item.setFont(1, font)\n            item.setIcon(1, QIcon.fromTheme(\"emblem-synchronizing\"))\n        else:\n            print(f\"Cannot find item for {video_path}\")\n\n    def play_video(self, file_name_item, column):\n        video_path = os.path.join(video_storage_dir, file_name_item.text(1))\n       \n        if file_name_item.font(1).italic() or file_name_item.foreground(1).color().lightness() >= 200:\n            print(f\"Video {video_path} is not yet downloaded. Moving it to top of queue. Please wait for download.\")\n             # Find the item in the download_queue that matches the base file name\n            found_item = None\n            for item in list(self.download_queue):\n                if item[1] == file_name_item.text(1):\n                    found_item = item\n                    break\n\n            if found_item:\n                # Remove the item from its current position in the queue\n                self.download_queue.remove(found_item)\n                # Add the item to the end of the queue\n                self.download_thread.add_to_queue(*found_item, left=True)\n            return\n\n        # Enable/disable GetHighRes button based on whether it's a sub stream\n        self.get_highres_button.setEnabled(\"RecS\" in file_name_item.text(1))\n\n        print(f\"Playing video: {video_path}\")\n        url = QUrl.fromLocalFile(video_path)\n        self.media_player.setSource(url)\n        self.video_widget.show()\n        def start_playback():\n                # Seek to 5 seconds (pre-record)\n                self.media_player.setPosition(5000)\n                self.media_player.play()\n                self.play_button.setIcon(self.style().standardIcon(QStyle.StandardPixmap.SP_MediaPause))\n                print(f\"Media player state: {self.media_player.playbackState()}\")\n\n        # Timer needed to be able to play at seek offset in the video, otherwise setPosition seems ignored\n        QTimer.singleShot(20, start_playback)\n\n    def get_highres_stream_for_file(self):\n        current_item = self.video_tree.currentItem()\n        if not current_item or \"RecS\" not in current_item.text(1):\n            return\n\n        parsed_data = parse_filename(current_item.text(1))\n        if not parsed_data:\n            print(f\"Could not parse file {current_item.text(1)}\")\n            return\n\n        start_time = parsed_data['start_datetime'] - timedelta(seconds=1)\n        end_time = datetime.datetime.strptime(f\"{parsed_data['start_datetime'].strftime('%Y%m%d')} {parsed_data['end_time']}\", \"%Y%m%d %H%M%S\") + timedelta(seconds=1)\n\n        main_files = self.cam.get_motion_files(start=start_time, end=end_time, streamtype='main', channel=parsed_data['channel'])\n\n        if main_files:\n            for main_file in main_files:\n                self.add_video(main_file['filename'])\n            self.video_tree.sortItems(2, Qt.SortOrder.DescendingOrder)\n        else:\n            print(f\"No main stream file found for {current_item.text(1)}\")\n\n    def play_pause(self):\n        if self.media_player.playbackState() == QMediaPlayer.PlaybackState.PlayingState:\n            self.media_player.pause()\n            self.play_button.setIcon(self.style().standardIcon(QStyle.StandardPixmap.SP_MediaPlay))\n        else:\n            self.media_player.play()\n            self.play_button.setIcon(self.style().standardIcon(QStyle.StandardPixmap.SP_MediaPause))\n\n    def handle_media_player_error(self, error):\n        print(f\"Media player error: {error}\")\n\n    def seek_slider_pressed(self):\n        self.media_player.setPosition(self.seek_slider.value())\n        self.media_player.play()\n\n    def seek_slider_released(self):\n        self.media_player.setPosition(self.seek_slider.value())\n        self.media_player.play()\n\n    def seek_slider_moved(self, position):\n        # Update video frame while dragging\n        self.media_player.setPosition(position)\n\n    def update_position(self, position):\n            self.seek_slider.setValue(position)\n\n    def update_duration(self, duration):\n        self.seek_slider.setRange(0, duration)\n\n    def set_speed(self, speed):\n        self.media_player.setPlaybackRate(speed / 100)\n\n    def open_in_mpv(self):\n        current_video = self.media_player.source().toString()\n        if current_video:\n            # Remove the 'file://' prefix if present\n            video_path = current_video.replace('file://', '')\n            try:\n                subprocess.Popen(['mpv', video_path])\n            except FileNotFoundError:\n                print(\"Error: MPV player not found. Make sure it's installed and in your system PATH.\")\n        else:\n            print(\"No video is currently selected.\")\n\n    def closeEvent(self, event):\n        self.download_thread.stop()\n        self.download_thread.wait(1000)\n        self.download_thread.terminate()\n        self.cam.logout()\n        super().closeEvent(event)\n\ndef read_config(props_path: str) -> dict:\n    \"\"\"Reads in a properties file into variables.\n\n    NB! this config file is kept out of commits with .gitignore. The structure of this file is such:\n    # secrets.cfg\n        [camera]\n        ip={ip_address}\n        username={username}\n        password={password}\n    \"\"\"\n    config = RawConfigParser()\n    assert os.path.exists(props_path), f\"Path does not exist: {props_path}\"\n    config.read(props_path)\n    return config\n\n\ndef signal_handler(sig, frame):\n    print(\"Exiting the application...\")\n    sys.exit(0)\n    cam.logout()\n    QApplication.quit()\n\n\n\nif __name__ == '__main__':\n    signal.signal(signal.SIGINT, signal_handler)\n    \n    parser = argparse.ArgumentParser(description=\"Reolink Video Review GUI\")\n    parser.add_argument('--main', action='store_true', help=\"Search for main channel instead of sub channel\")\n    parser.add_argument('files', nargs='*', help=\"Optional video file names to process\")\n    args = parser.parse_args()\n\n    config = read_config('camera.cfg')\n\n    ip = config.get('camera', 'ip')\n    un = config.get('camera', 'username')\n    pw = config.get('camera', 'password')\n    video_storage_dir = config.get('camera', 'video_storage_dir')\n\n# Connect to camera\n    cam = Camera(ip, un, pw, https=True)\n\n    start = dt.combine(dt.now(), dt.min.time())\n    end = dt.now()\n\n    streamtype = 'sub' if not args.main else 'main'\n    processed_motions = cam.get_motion_files(start=start, end=end, streamtype=streamtype, channel=0)\n    processed_motions += cam.get_motion_files(start=start, end=end, streamtype=streamtype, channel=1)\n\n    start = dt.now() - timedelta(days=1)\n    end = dt.combine(start, dt.max.time())\n    processed_motions += cam.get_motion_files(start=start, end=end, streamtype=streamtype, channel=0)\n    processed_motions += cam.get_motion_files(start=start, end=end, streamtype=streamtype, channel=1)\n\n\n    if len(processed_motions) == 0:\n        print(\"Camera did not return any video?!\")\n\n    video_files = []\n    for i, motion in enumerate(processed_motions):\n        fname = motion['filename']\n        print(\"Processing %s\" % (fname))\n        video_files.append(fname)\n\n    video_files.extend([os.path.basename(file) for file in args.files])\n    app = QApplication(sys.argv)\n    player = VideoPlayer(video_files)\n    player.resize(2400, 1000)\n    player.show()\n    sys.exit(app.exec())\n"
  },
  {
    "path": "make-and-publish-package.sh",
    "content": "rm -rf dist\npython setup.py sdist bdist_wheel\ntwine upload dist/*"
  },
  {
    "path": "reolinkapi/__init__.py",
    "content": "from reolinkapi.handlers.api_handler import APIHandler\nfrom .camera import Camera\n\n__version__ = \"0.4.1\"\n"
  },
  {
    "path": "reolinkapi/camera.py",
    "content": "from reolinkapi.handlers.api_handler import APIHandler\n\n\nclass Camera(APIHandler):\n\n    def __init__(self, ip: str,\n                 username: str = \"admin\",\n                 password: str = \"\",\n                 https: bool = False,\n                 defer_login: bool = False,\n                 profile: str = \"main\",\n                 **kwargs):\n        \"\"\"\n        Initialise the Camera object by passing the ip address.\n        The default details {\"username\":\"admin\", \"password\":\"\"} will be used if nothing passed\n        For deferring the login to the camera, just pass defer_login = True.\n        For connecting to the camera behind a proxy pass a proxy argument: proxy={\"http\": \"socks5://127.0.0.1:8000\"}\n        :param ip:\n        :param username:\n        :param password:\n        :param https: connect to the camera over https\n        :param defer_login: defer the login process\n        :param proxy: Add a proxy dict for requests to consume.\n        eg: {\"http\":\"socks5://[username]:[password]@[host]:[port], \"https\": ...}\n        More information on proxies in requests: https://stackoverflow.com/a/15661226/9313679\n        \"\"\"\n        if profile not in [\"main\", \"sub\"]:\n            raise Exception(\"Profile argument must be either \\\"main\\\" or \\\"sub\\\"\")\n\n        # For when you need to connect to a camera behind a proxy, pass\n        # a proxy argument: proxy={\"http\": \"socks5://127.0.0.1:8000\"}\n        APIHandler.__init__(self, ip, username, password, https=https, **kwargs)\n\n        # Normal call without proxy:\n        # APIHandler.__init__(self, ip, username, password)\n\n        self.ip = ip\n        self.username = username\n        self.password = password\n        self.profile = profile\n\n        if not defer_login:\n            super().login()\n"
  },
  {
    "path": "reolinkapi/handlers/__init__.py",
    "content": ""
  },
  {
    "path": "reolinkapi/handlers/api_handler.py",
    "content": "import requests\nfrom typing import Dict, List, Optional, Union\nfrom reolinkapi.mixins.alarm import AlarmAPIMixin\nfrom reolinkapi.mixins.device import DeviceAPIMixin\nfrom reolinkapi.mixins.display import DisplayAPIMixin\nfrom reolinkapi.mixins.download import DownloadAPIMixin\nfrom reolinkapi.mixins.image import ImageAPIMixin\nfrom reolinkapi.mixins.motion import MotionAPIMixin\nfrom reolinkapi.mixins.network import NetworkAPIMixin\nfrom reolinkapi.mixins.ptz import PtzAPIMixin\nfrom reolinkapi.mixins.record import RecordAPIMixin\nfrom reolinkapi.handlers.rest_handler import Request\nfrom reolinkapi.mixins.stream import StreamAPIMixin\nfrom reolinkapi.mixins.system import SystemAPIMixin\nfrom reolinkapi.mixins.user import UserAPIMixin\nfrom reolinkapi.mixins.zoom import ZoomAPIMixin\nfrom reolinkapi.mixins.nvrdownload import NvrDownloadAPIMixin\n\n\nclass APIHandler(AlarmAPIMixin,\n                 DeviceAPIMixin,\n                 DisplayAPIMixin,\n                 DownloadAPIMixin,\n                 ImageAPIMixin,\n                 MotionAPIMixin,\n                 NetworkAPIMixin,\n                 PtzAPIMixin,\n                 RecordAPIMixin,\n                 SystemAPIMixin,\n                 UserAPIMixin,\n                 ZoomAPIMixin,\n                 StreamAPIMixin,\n                 NvrDownloadAPIMixin):\n    \"\"\"\n    The APIHandler class is the backend part of the API, the actual API calls\n    are implemented in Mixins.\n    This handles communication directly with the camera.\n    Current camera's tested: RLC-411WS\n\n    All Code will try to follow the PEP 8 standard as described here: https://www.python.org/dev/peps/pep-0008/\n    \"\"\"\n\n    def __init__(self, ip: str, username: str, password: str, https: bool = False, **kwargs):\n        \"\"\"\n        Initialise the Camera API Handler (maps api calls into python)\n        :param ip:\n        :param username:\n        :param password:\n        :param https: connect over https\n        :param proxy: Add a proxy dict for requests to consume.\n        eg: {\"http\":\"socks5://[username]:[password]@[host]:[port], \"https\": ...}\n        More information on proxies in requests: https://stackoverflow.com/a/15661226/9313679\n        \"\"\"\n        scheme = 'https' if https else 'http'\n        self.url = f\"{scheme}://{ip}/cgi-bin/api.cgi\"\n        self.ip = ip\n        self.token = None\n        self.username = username\n        self.password = password\n        Request.proxies = kwargs.get(\"proxy\")  # Defaults to None if key isn't found\n        Request.session = kwargs.get(\"session\")  # Defaults to None if key isn't found\n\n    def login(self) -> bool:\n        \"\"\"\n        Get login token\n        Must be called first, before any other operation can be performed\n        :return: bool\n        \"\"\"\n        try:\n            body = [{\"cmd\": \"Login\", \"action\": 0,\n                     \"param\": {\"User\": {\"userName\": self.username, \"password\": self.password}}}]\n            param = {\"cmd\": \"Login\", \"token\": \"null\"}\n            response = Request.post(self.url, data=body, params=param)\n            if response is not None:\n                data = response.json()[0]\n                code = data[\"code\"]\n                if int(code) == 0:\n                    self.token = data[\"value\"][\"Token\"][\"name\"]\n                    print(\"Login success\")\n                    return True\n                print(self.token)\n                return False\n            else:\n                # TODO: Verify this change w/ owner. Delete old code if acceptable.\n                #  A this point, response is NoneType. There won't be a status code property.\n                # print(\"Failed to login\\nStatus Code:\", response.status_code)\n                print(\"Failed to login\\nResponse was null.\")\n                return False\n        except Exception as e:\n            print(\"Error Login\\n\", e)\n            raise\n\n    def logout(self) -> bool:\n        \"\"\"\n        Logout of the camera\n        :return: bool\n        \"\"\"\n        try:\n            data = [{\"cmd\": \"Logout\", \"action\": 0}]\n            self._execute_command('Logout', data)\n            # print(ret)\n            return True\n        except Exception as e:\n            print(\"Error Logout\\n\", e)\n            return False\n\n    def _execute_command(self, command: str, data: List[Dict], multi: bool = False) -> \\\n            Optional[Union[Dict, bool]]:\n        \"\"\"\n        Send a POST request to the IP camera with given data.\n        :param command: name of the command to send\n        :param data: object to send to the camera (send as json)\n        :param multi: whether the given command name should be added to the\n        url parameters of the request. Defaults to False. (Some multi-step\n        commands seem to not have a single command name)\n        :return: response JSON as python object\n        \"\"\"\n        params = {\"token\": self.token, 'cmd': command}\n        if multi:\n            del params['cmd']\n        try:\n            if self.token is None:\n                raise ValueError(\"Login first\")\n            if command == 'Download' or command == 'Playback':\n                # Special handling for downloading an mp4\n                # Pop the filepath from data\n                tgt_filepath = data[0].pop('filepath')\n                # Apply the data to the params\n                params.update(data[0])\n                with requests.get(self.url, params=params, stream=True, verify=False, timeout=(1, None), proxies=Request.proxies) as req:\n                    if req.status_code == 200:\n                        with open(tgt_filepath, 'wb') as f:\n                            f.write(req.content)\n                        return True\n                    else:\n                        print(f'Error received: {req.status_code}')\n                        return False\n\n            else:\n                response = Request.post(self.url, data=data, params=params)\n                return response.json()\n        except Exception as e:\n            print(f\"Command {command} failed: {e}\")\n            raise\n"
  },
  {
    "path": "reolinkapi/handlers/rest_handler.py",
    "content": "import requests\nfrom typing import List, Dict, Union, Optional\n\n\nclass Request:\n    proxies = None\n    session = None\n\n    @staticmethod\n    def __getSession():\n        reqHandler = requests\n        if Request.session is not None:\n            reqHandler = Request.session\n        return reqHandler\n\n    @staticmethod\n    def post(url: str, data: List[Dict], params: Dict[str, Union[str, float]] = None) -> \\\n            Optional[requests.Response]:\n        \"\"\"\n        Post request\n        :param params:\n        :param url:\n        :param data:\n        :return:\n        \"\"\"\n        try:\n            headers = {'content-type': 'application/json'}\n            r = Request.__getSession().post(url, verify=False, params=params, json=data, headers=headers,\n                              proxies=Request.proxies)\n            if r.status_code == 200:\n                return r\n            else:\n                raise ValueError(f\"Http Request had non-200 Status: {r.status_code}\", r.status_code)\n        except Exception as e:\n            print(\"Post Error\\n\", e)\n            raise\n\n    @staticmethod\n    def get(url: str, params: Dict[str, Union[str, float]], timeout: float = 1) -> Optional[requests.Response]:\n        \"\"\"\n        Get request\n        :param url:\n        :param params:\n        :param timeout:\n        :return:\n        \"\"\"\n        try:\n            data = Request.__getSession().get(url=url, verify=False, params=params, timeout=timeout, proxies=Request.proxies)\n            return data\n        except Exception as e:\n            print(\"Get Error\\n\", e)\n            raise\n"
  },
  {
    "path": "reolinkapi/mixins/__init__.py",
    "content": ""
  },
  {
    "path": "reolinkapi/mixins/alarm.py",
    "content": "from typing import Dict\n\n\nclass AlarmAPIMixin:\n    \"\"\"API calls for getting device alarm information.\"\"\"\n\n    def get_alarm_motion(self) -> Dict:\n        \"\"\"\n        Gets the device alarm motion\n        See examples/response/GetAlarmMotion.json for example response data.\n        :return: response json\n        \"\"\"\n        body = [{\"cmd\": \"GetAlarm\", \"action\": 1, \"param\": {\"Alarm\": {\"channel\": 0, \"type\": \"md\"}}}]\n        return self._execute_command('GetAlarm', body)\n"
  },
  {
    "path": "reolinkapi/mixins/device.py",
    "content": "from typing import List, Dict\n\n\nclass DeviceAPIMixin:\n    \"\"\"API calls for getting device information.\"\"\"\n    DEFAULT_HDD_ID = [0]\n\n    def set_device_name(self, name: str) -> bool:\n        \"\"\"\n        Set the device name of the camera.\n        :param name: The new name for the device\n        :return: bool indicating success\n        \"\"\"\n        body = [{\"cmd\": \"SetDevName\", \"action\": 0, \"param\": {\"DevName\": {\"name\": name}}}]\n        self._execute_command('SetDevName', body)\n        print(f\"Successfully set device name to: {name}\")\n        return True\n\n    def get_device_name(self) -> Dict:\n        \"\"\"\n        Get the device name of the camera.\n        :return: Dict containing the device name\n        \"\"\"\n        body = [{\"cmd\": \"GetDevName\", \"action\": 0, \"param\": {}}]\n        return self._execute_command('GetDevName', body)\n    \n    def get_hdd_info(self) -> Dict:\n        \"\"\"\n        Gets all HDD and SD card information from Camera\n        See examples/response/GetHddInfo.json for example response data.\n        :return: response json\n        \"\"\"\n        body = [{\"cmd\": \"GetHddInfo\", \"action\": 0, \"param\": {}}]\n        return self._execute_command('GetHddInfo', body)\n\n    def format_hdd(self, hdd_id: List[float] = None) -> bool:\n        \"\"\"\n        Format specified HDD/SD cards with their id's\n        :param hdd_id: List of id's specified by the camera with get_hdd_info api. Default is 0 (SD card)\n        :return: bool\n        \"\"\"\n        if hdd_id is None:\n            hdd_id = self.DEFAULT_HDD_ID\n        body = [{\"cmd\": \"Format\", \"action\": 0, \"param\": {\"HddInfo\": {\"id\": hdd_id}}}]\n        r_data = self._execute_command('Format', body)[0]\n        if r_data[\"value\"][\"rspCode\"] == 200:\n            return True\n        print(\"Could not format HDD/SD. Camera responded with:\", r_data[\"value\"])\n        return False\n"
  },
  {
    "path": "reolinkapi/mixins/display.py",
    "content": "from typing import Dict\n\n\nclass DisplayAPIMixin:\n    \"\"\"API calls related to the current image (osd, on screen display).\"\"\"\n\n    def get_osd(self) -> Dict:\n        \"\"\"\n        Get OSD information.\n        See examples/response/GetOsd.json for example response data.\n        :return: response json\n        \"\"\"\n        body = [{\"cmd\": \"GetOsd\", \"action\": 1, \"param\": {\"channel\": 0}}]\n        return self._execute_command('GetOsd', body)\n\n    def get_mask(self) -> Dict:\n        \"\"\"\n        Get the camera mask information.\n        See examples/response/GetMask.json for example response data.\n        :return: response json\n        \"\"\"\n        body = [{\"cmd\": \"GetMask\", \"action\": 1, \"param\": {\"channel\": 0}}]\n        return self._execute_command('GetMask', body)\n\n    def set_osd(self, bg_color: bool = 0, channel: float = 0, osd_channel_enabled: bool = 0,\n                osd_channel_name: str = \"\", osd_channel_pos: str = \"Lower Right\", osd_time_enabled: bool = 0,\n                osd_time_pos: str = \"Lower Right\", osd_watermark_enabled: bool = 0) -> bool:\n        \"\"\"\n        Set OSD\n        :param bg_color: bool\n        :param channel: int channel id\n        :param osd_channel_enabled: bool\n        :param osd_channel_name: string channel name\n        :param osd_channel_pos: string channel position\n            [\"Upper Left\",\"Top Center\",\"Upper Right\",\"Lower Left\",\"Bottom Center\",\"Lower Right\"]\n        :param osd_time_enabled: bool\n        :param osd_time_pos: string time position\n            [\"Upper Left\",\"Top Center\",\"Upper Right\",\"Lower Left\",\"Bottom Center\",\"Lower Right\"]\n        :return: whether the action was successful\n        \"\"\"\n        body = [{\"cmd\": \"SetOsd\", \"action\": 1,\n                 \"param\": {\n                    \"Osd\": {\n                        \"bgcolor\": bg_color,\n                        \"channel\": channel,\n                        \"osdChannel\": {\n                            \"enable\": osd_channel_enabled, \"name\": osd_channel_name,\n                            \"pos\": osd_channel_pos\n                        },\n                        \"osdTime\": {\"enable\": osd_time_enabled, \"pos\": osd_time_pos},\n                        \"watermark\": osd_watermark_enabled,\n                    }}}]\n        r_data = self._execute_command('SetOsd', body)[0]\n        if 'value' in r_data and r_data[\"value\"][\"rspCode\"] == 200:\n            return True\n        print(\"Could not set OSD. Camera responded with status:\", r_data[\"error\"])\n        return False\n"
  },
  {
    "path": "reolinkapi/mixins/download.py",
    "content": "class DownloadAPIMixin:\n    \"\"\"API calls for downloading video files.\"\"\"\n    def get_file(self, filename: str, output_path: str, method = 'Playback') -> bool:\n        \"\"\"\n        Download the selected video file\n        On at least Trackmix Wifi, it was observed that the Playback method\n        yields much improved download speeds over the Download method, for\n        unknown reasons.\n        :return: response json\n        \"\"\"\n        body = [\n            {\n                \"cmd\": method,\n                \"source\": filename,\n                \"output\": filename,\n                \"filepath\": output_path\n            }\n        ]\n        resp = self._execute_command(method, body)\n\n        return resp\n"
  },
  {
    "path": "reolinkapi/mixins/image.py",
    "content": "from typing import Dict\n\n\nclass ImageAPIMixin:\n    \"\"\"API calls for image settings.\"\"\"\n\n    def set_adv_image_settings(self,\n                               anti_flicker: str = 'Outdoor',\n                               exposure: str = 'Auto',\n                               gain_min: float = 1,\n                               gain_max: float = 62,\n                               shutter_min: float = 1,\n                               shutter_max: float = 125,\n                               blue_gain: float = 128,\n                               red_gain: float = 128,\n                               white_balance: str = 'Auto',\n                               day_night: str = 'Auto',\n                               back_light: str = 'DynamicRangeControl',\n                               blc: float = 128,\n                               drc: float = 128,\n                               rotation: float = 0,\n                               mirroring: float = 0,\n                               nr3d: float = 1) -> Dict:\n        \"\"\"\n        Sets the advanced camera settings.\n\n        :param anti_flicker: string\n        :param exposure: string\n        :param gain_min: int\n        :param gain_max: string\n        :param shutter_min: int\n        :param shutter_max: int\n        :param blue_gain: int\n        :param red_gain: int\n        :param white_balance: string\n        :param day_night: string\n        :param back_light: string\n        :param blc: int\n        :param drc: int\n        :param rotation: int\n        :param mirroring: int\n        :param nr3d: int\n        :return: response\n        \"\"\"\n        body = [{\n            \"cmd\": \"SetIsp\",\n            \"action\": 0,\n            \"param\": {\n                \"Isp\": {\n                    \"channel\": 0,\n                    \"antiFlicker\": anti_flicker,\n                    \"exposure\": exposure,\n                    \"gain\": {\"min\": gain_min, \"max\": gain_max},\n                    \"shutter\": {\"min\": shutter_min, \"max\": shutter_max},\n                    \"blueGain\": blue_gain,\n                    \"redGain\": red_gain,\n                    \"whiteBalance\": white_balance,\n                    \"dayNight\": day_night,\n                    \"backLight\": back_light,\n                    \"blc\": blc,\n                    \"drc\": drc,\n                    \"rotation\": rotation,\n                    \"mirroring\": mirroring,\n                    \"nr3d\": nr3d\n                }\n            }\n        }]\n        return self._execute_command('SetIsp', body)\n\n    def set_image_settings(self,\n                           brightness: float = 128,\n                           contrast: float = 62,\n                           hue: float = 1,\n                           saturation: float = 125,\n                           sharpness: float = 128) -> Dict:\n        \"\"\"\n        Sets the camera image settings.\n\n        :param brightness: int\n        :param contrast: string\n        :param hue: int\n        :param saturation: int\n        :param sharpness: int\n        :return: response\n        \"\"\"\n        body = [\n            {\n                \"cmd\": \"SetImage\",\n                \"action\": 0,\n                \"param\": {\n                    \"Image\": {\n                        \"bright\": brightness,\n                        \"channel\": 0,\n                        \"contrast\": contrast,\n                        \"hue\": hue,\n                        \"saturation\": saturation,\n                        \"sharpen\": sharpness\n                    }\n                }\n            }\n        ]\n\n        return self._execute_command('SetImage', body)\n"
  },
  {
    "path": "reolinkapi/mixins/motion.py",
    "content": "from typing import Union, List, Dict\nfrom datetime import datetime as dt\n\n\n# Type hints for input and output of the motion api response\nRAW_MOTION_LIST_TYPE = List[Dict[str, Union[str, float, Dict[str, str]]]]\nPROCESSED_MOTION_LIST_TYPE = List[Dict[str, Union[str, dt]]]\n\n\nclass MotionAPIMixin:\n    \"\"\"API calls for past motion alerts.\"\"\"\n    def get_motion_files(self, start: dt, end: dt = dt.now(),\n                         streamtype: str = 'sub', channel = 0) -> PROCESSED_MOTION_LIST_TYPE:\n        \"\"\"\n        Get the timestamps and filenames of motion detection events for the time range provided.\n\n        Args:\n            start: the starting time range to examine\n            end: the end time of the time range to examine\n            streamtype: 'main' or 'sub' - the stream to examine\n        :return: response json\n        \"\"\"\n        search_params = {\n            'Search': {\n                'channel': channel,\n                'streamType': streamtype,\n                'onlyStatus': 0,\n                'StartTime': {\n                    'year': start.year,\n                    'mon': start.month,\n                    'day': start.day,\n                    'hour': start.hour,\n                    'min': start.minute,\n                    'sec': start.second\n                },\n                'EndTime': {\n                    'year': end.year,\n                    'mon': end.month,\n                    'day': end.day,\n                    'hour': end.hour,\n                    'min': end.minute,\n                    'sec': end.second\n                }\n            }\n        }\n        body = [{\"cmd\": \"Search\", \"action\": 1, \"param\": search_params}]\n\n        resp = self._execute_command('Search', body)[0]\n        if 'value' not in resp:\n            return []\n        values = resp['value']\n        if 'SearchResult' not in values:\n            return []\n        result = values['SearchResult']\n        files = result.get('File', [])\n        if len(files) > 0:\n            # Begin processing files\n            processed_files = self._process_motion_files(files)\n            return processed_files\n        return []\n\n    @staticmethod\n    def _process_motion_files(motion_files: RAW_MOTION_LIST_TYPE) -> PROCESSED_MOTION_LIST_TYPE:\n        \"\"\"Processes raw list of dicts containing motion timestamps\n        and the filename associated with them\"\"\"\n        # Process files\n        processed_motions = []\n        replace_fields = {'mon': 'month', 'sec': 'second', 'min': 'minute'}\n        for file in motion_files:\n            time_range = {}\n            for x in ['Start', 'End']:\n                # Get raw dict\n                raw = file[f'{x}Time']\n                # Replace certain keys\n                for k, v in replace_fields.items():\n                    if k in raw.keys():\n                        raw[v] = raw.pop(k)\n                time_range[x.lower()] = dt(**raw)\n            start, end = time_range.values()\n            processed_motions.append({\n                'start': start,\n                'end': end,\n                'filename': file['name']\n            })\n        return processed_motions\n"
  },
  {
    "path": "reolinkapi/mixins/network.py",
    "content": "from typing import Dict\n\n\nclass NetworkAPIMixin:\n    \"\"\"API calls for network settings.\"\"\"\n    def set_network_settings(self, ip: str, gateway: str, mask: str, dns1: str, dns2: str, mac: str,\n                            use_dhcp: bool = True, auto_dns: bool = True) -> Dict:\n        \"\"\"\n        Set network settings including IP, gateway, subnet mask, DNS, and connection type (DHCP or Static).\n        \n        :param ip: str\n        :param gateway: str\n        :param mask: str\n        :param dns1: str\n        :param dns2: str\n        :param mac: str\n        :param use_dhcp: bool\n        :param auto_dns: bool\n        :return: Dict\n        \"\"\"\n        body = [{\"cmd\": \"SetLocalLink\", \"action\": 0, \"param\": {\n            \"LocalLink\": {\n                \"dns\": {\n                    \"auto\": 1 if auto_dns else 0,\n                    \"dns1\": dns1,\n                    \"dns2\": dns2\n                },\n                \"mac\": mac,\n                \"static\": {\n                    \"gateway\": gateway,\n                    \"ip\": ip,\n                    \"mask\": mask\n                },\n                \"type\": \"DHCP\" if use_dhcp else \"Static\"\n            }\n        }}]\n        \n        return self._execute_command('SetLocalLink', body)\n        print(\"Successfully Set Network Settings\")\n        return True\n\n    def set_net_port(self, http_port: float = 80, https_port: float = 443, media_port: float = 9000,\n                     onvif_port: float = 8000, rtmp_port: float = 1935, rtsp_port: float = 554) -> bool:\n        \"\"\"\n        Set network ports\n        If nothing is specified, the default values will be used\n        :param rtsp_port: int\n        :param rtmp_port: int\n        :param onvif_port: int\n        :param media_port: int\n        :param https_port: int\n        :type http_port: int\n        :return: bool\n        \"\"\"\n        body = [{\"cmd\": \"SetNetPort\", \"action\": 0, \"param\": {\"NetPort\": {\n            \"httpPort\": http_port,\n            \"httpsPort\": https_port,\n            \"mediaPort\": media_port,\n            \"onvifPort\": onvif_port,\n            \"rtmpPort\": rtmp_port,\n            \"rtspPort\": rtsp_port\n        }}}]\n        self._execute_command('SetNetPort', body, multi=True)\n        print(\"Successfully Set Network Ports\")\n        return True\n\n    def set_wifi(self, ssid: str, password: str) -> Dict:\n        body = [{\"cmd\": \"SetWifi\", \"action\": 0, \"param\": {\n            \"Wifi\": {\n                \"ssid\": ssid,\n                \"password\": password\n            }}}]\n        return self._execute_command('SetWifi', body)\n\n    def set_ntp(self, enable: bool = True, interval: int = 1440, port: int = 123, server: str = \"pool.ntp.org\") -> Dict:\n        \"\"\"\n        Set NTP settings.\n\n        :param enable: bool\n        :param interval: int\n        :param port: int\n        :param server: str\n        :return: Dict\n        \"\"\"\n        body = [{\"cmd\": \"SetNtp\", \"action\": 0, \"param\": {\n            \"Ntp\": {\n                \"enable\": int(enable),\n                \"interval\": interval,\n                \"port\": port,\n                \"server\": server\n            }}}]\n        response = self._execute_command('SetNtp', body)\n        print(\"Successfully Set NTP Settings\")\n        return response\n\n    def get_net_ports(self) -> Dict:\n        \"\"\"\n        Get network ports\n        See examples/response/GetNetworkAdvanced.json for example response data.\n        :return: response json\n        \"\"\"\n        body = [{\"cmd\": \"GetNetPort\", \"action\": 1, \"param\": {}},\n                {\"cmd\": \"GetUpnp\", \"action\": 0, \"param\": {}},\n                {\"cmd\": \"GetP2p\", \"action\": 0, \"param\": {}}]\n        return self._execute_command('GetNetPort', body, multi=True)\n\n    def get_wifi(self) -> Dict:\n        body = [{\"cmd\": \"GetWifi\", \"action\": 1, \"param\": {}}]\n        return self._execute_command('GetWifi', body)\n\n    def scan_wifi(self) -> Dict:\n        body = [{\"cmd\": \"ScanWifi\", \"action\": 1, \"param\": {}}]\n        return self._execute_command('ScanWifi', body)\n\n    def get_network_general(self) -> Dict:\n        \"\"\"\n        Get the camera information\n        See examples/response/GetNetworkGeneral.json for example response data.\n        :return: response json\n        \"\"\"\n        body = [{\"cmd\": \"GetLocalLink\", \"action\": 0, \"param\": {}}]\n        return self._execute_command('GetLocalLink', body)\n\n    def get_network_ddns(self) -> Dict:\n        \"\"\"\n        Get the camera DDNS network information\n        See examples/response/GetNetworkDDNS.json for example response data.\n        :return: response json\n        \"\"\"\n        body = [{\"cmd\": \"GetDdns\", \"action\": 0, \"param\": {}}]\n        return self._execute_command('GetDdns', body)\n\n    def get_network_ntp(self) -> Dict:\n        \"\"\"\n        Get the camera NTP network information\n        See examples/response/GetNetworkNTP.json for example response data.\n        :return: response json\n        \"\"\"\n        body = [{\"cmd\": \"GetNtp\", \"action\": 0, \"param\": {}}]\n        return self._execute_command('GetNtp', body)\n\n    def get_network_email(self) -> Dict:\n        \"\"\"\n        Get the camera email network information\n        See examples/response/GetNetworkEmail.json for example response data.\n        :return: response json\n        \"\"\"\n        body = [{\"cmd\": \"GetEmail\", \"action\": 0, \"param\": {}}]\n        return self._execute_command('GetEmail', body)\n\n    def get_network_ftp(self) -> Dict:\n        \"\"\"\n        Get the camera FTP network information\n        See examples/response/GetNetworkFtp.json for example response data.\n        :return: response json\n        \"\"\"\n        body = [{\"cmd\": \"GetFtp\", \"action\": 0, \"param\": {}}]\n        return self._execute_command('GetFtp', body)\n\n    def get_network_push(self) -> Dict:\n        \"\"\"\n        Get the camera push network information\n        See examples/response/GetNetworkPush.json for example response data.\n        :return: response json\n        \"\"\"\n        body = [{\"cmd\": \"GetPush\", \"action\": 0, \"param\": {}}]\n        return self._execute_command('GetPush', body)\n\n    def get_network_status(self) -> Dict:\n        \"\"\"\n        Get the camera status network information\n        See examples/response/GetNetworkGeneral.json for example response data.\n        :return: response json\n        \"\"\"\n        return self.get_network_general()\n"
  },
  {
    "path": "reolinkapi/mixins/nvrdownload.py",
    "content": "from datetime import datetime as dt\n\nclass NvrDownloadAPIMixin:\n    \"\"\"API calls for NvrDownload.\"\"\"\n    def get_playback_files(self, start: dt, end: dt = dt.now(), channel: int = 0,\n                         streamtype: str = 'sub'):\n        \"\"\"\n        Get the filenames of the videos for the time range provided.\n\n        Args:\n            start: the starting time range to examine\n            end: the end time of the time range to examine\n            channel: which channel to download from\n            streamtype: 'main' or 'sub' - the stream to examine\n        :return: response json\n        \"\"\"\n        search_params = {\n            'NvrDownload': {\n                'channel': channel,\n                'iLogicChannel': 0,\n                'streamType': streamtype,\n                'StartTime': {\n                    'year': start.year,\n                    'mon': start.month,\n                    'day': start.day,\n                    'hour': start.hour,\n                    'min': start.minute,\n                    'sec': start.second\n                },\n                'EndTime': {\n                    'year': end.year,\n                    'mon': end.month,\n                    'day': end.day,\n                    'hour': end.hour,\n                    'min': end.minute,\n                    'sec': end.second\n                }\n            }\n        }\n        body = [{\"cmd\": \"NvrDownload\", \"action\": 1, \"param\": search_params}]\n        try:\n            resp = self._execute_command('NvrDownload', body)[0]\n        except Exception as e:\n            print(f\"Error: {e}\")\n            return []\n        if 'value' not in resp:\n            return []\n        values = resp['value']\n        if 'fileList' not in values:\n            return []\n        files = values['fileList']\n        if len(files) > 0:\n            return [file['fileName'] for file in files]\n        return []\n"
  },
  {
    "path": "reolinkapi/mixins/ptz.py",
    "content": "from typing import Dict\n\n\nclass PtzAPIMixin:\n    \"\"\"\n    API for PTZ functions.\n    \"\"\"\n    def get_ptz_check_state(self) -> Dict:\n        \"\"\"\n        Get PTZ Check State Information that indicates whether calibration is required (0) running (1) or done (2)\n        Value is contained in response[0][\"value\"][\"PtzCheckState\"].\n        See examples/response/GetPtzCheckState.json for example response data.\n        :return: response json\n        \"\"\"\n        body = [{\"cmd\": \"GetPtzCheckState\", \"action\": 1, \"param\": { \"channel\": 0}}]\n        return self._execute_command('GetPtzCheckState', body)\n\n    def get_ptz_presets(self) -> Dict:\n        \"\"\"\n        Get ptz presets\n        See examples/response/GetPtzPresets.json for example response data.\n        :return: response json\n        \"\"\"\n\n        body = [{\"cmd\": \"GetPtzPreset\", \"action\": 1, \"param\": { \"channel\": 0}}]\n        return self._execute_command('GetPtzPreset', body)\n\n    def perform_calibration(self) -> Dict:\n        \"\"\"\n        Do the calibration (like app -> ptz -> three dots -> calibration). Moves camera to all end positions.\n        If not calibrated, your viewpoint of presets might drift. So before setting new presets, or moving to preset,\n        check calibration status (get_ptz_check_state -> 2 = calibrated) and perform calibration if not yet calibrated.\n        As of 2024-01-23 (most recent firmware 3.1.0.1711_23010700 for E1 Zoom) does not do this on startup.\n        Method blocks while calibrating.\n        See examples/response/PtzCheck.json for example response data.\n        :return: response json\n        \"\"\"\n        data = [{\"cmd\": \"PtzCheck\", \"action\": 0, \"param\": {\"channel\": 0}}]\n        return self._execute_command('PtzCheck', data)\n\n    def _send_operation(self, operation: str, speed: float, index: float = None) -> Dict:\n        # Refactored to reduce redundancy\n        param = {\"channel\": 0, \"op\": operation, \"speed\": speed}\n        if index is not None:\n            param['id'] = index\n        data = [{\"cmd\": \"PtzCtrl\", \"action\": 0, \"param\": param}]\n        return self._execute_command('PtzCtrl', data)\n\n    def _send_noparm_operation(self, operation: str) -> Dict:\n        data = [{\"cmd\": \"PtzCtrl\", \"action\": 0, \"param\": {\"channel\": 0, \"op\": operation}}]\n        return self._execute_command('PtzCtrl', data)\n\n    def _send_set_preset(self, enable: float, preset: float = 1, name: str = 'pos1') -> Dict:\n        data = [{\"cmd\": \"SetPtzPreset\", \"action\": 0, \"param\": { \"PtzPreset\": {\n            \"channel\": 0, \"enable\": enable, \"id\": preset, \"name\": name}}}]\n        return self._execute_command('PtzCtrl', data)\n\n    def go_to_preset(self, speed: float = 60, index: float = 1) -> Dict:\n        \"\"\"\n        Move the camera to a preset location\n        :return: response json\n        \"\"\"\n        return self._send_operation('ToPos', speed=speed, index=index)\n\n    def add_preset(self, preset: float = 1, name: str = 'pos1') -> Dict:\n        \"\"\"\n        Adds the current camera position to the specified preset.\n        :return: response json\n        \"\"\"\n        return self._send_set_preset(enable=1, preset=preset, name=name)\n\n    def remove_preset(self, preset: float = 1, name: str = 'pos1') -> Dict:\n        \"\"\"\n        Removes the specified preset\n        :return: response json\n        \"\"\"\n        return self._send_set_preset(enable=0, preset=preset, name=name)\n\n    def move_right(self, speed: float = 25) -> Dict:\n        \"\"\"\n        Move the camera to the right\n        The camera moves self.stop_ptz() is called.\n        :return: response json\n        \"\"\"\n        return self._send_operation('Right', speed=speed)\n\n    def move_right_up(self, speed: float = 25) -> Dict:\n        \"\"\"\n        Move the camera to the right and up\n        The camera moves self.stop_ptz() is called.\n        :return: response json\n        \"\"\"\n        return self._send_operation('RightUp', speed=speed)\n\n    def move_right_down(self, speed: float = 25) -> Dict:\n        \"\"\"\n        Move the camera to the right and down\n        The camera moves self.stop_ptz() is called.\n        :return: response json\n        \"\"\"\n        return self._send_operation('RightDown', speed=speed)\n\n    def move_left(self, speed: float = 25) -> Dict:\n        \"\"\"\n        Move the camera to the left\n        The camera moves self.stop_ptz() is called.\n        :return: response json\n        \"\"\"\n        return self._send_operation('Left', speed=speed)\n\n    def move_left_up(self, speed: float = 25) -> Dict:\n        \"\"\"\n        Move the camera to the left and up\n        The camera moves self.stop_ptz() is called.\n        :return: response json\n        \"\"\"\n        return self._send_operation('LeftUp', speed=speed)\n\n    def move_left_down(self, speed: float = 25) -> Dict:\n        \"\"\"\n        Move the camera to the left and down\n        The camera moves self.stop_ptz() is called.\n        :return: response json\n        \"\"\"\n        return self._send_operation('LeftDown', speed=speed)\n\n    def move_up(self, speed: float = 25) -> Dict:\n        \"\"\"\n        Move the camera up.\n        The camera moves self.stop_ptz() is called.\n        :return: response json\n        \"\"\"\n        return self._send_operation('Up', speed=speed)\n\n    def move_down(self, speed: float = 25) -> Dict:\n        \"\"\"\n        Move the camera down.\n        The camera moves self.stop_ptz() is called.\n        :return: response json\n        \"\"\"\n        return self._send_operation('Down', speed=speed)\n\n    def stop_ptz(self) -> Dict:\n        \"\"\"\n        Stops the cameras current action.\n        :return: response json\n        \"\"\"\n        return self._send_noparm_operation('Stop')\n\n    def auto_movement(self, speed: float = 25) -> Dict:\n        \"\"\"\n        Move the camera in a clockwise rotation.\n        The camera moves self.stop_ptz() is called.\n        :return: response json\n        \"\"\"\n        return self._send_operation('Auto', speed=speed)\n"
  },
  {
    "path": "reolinkapi/mixins/record.py",
    "content": "from typing import Dict\n\n\nclass RecordAPIMixin:\n    \"\"\"API calls for the recording settings\"\"\"\n\n    def get_recording_encoding(self) -> Dict:\n        \"\"\"\n        Get the current camera encoding settings for \"Clear\" and \"Fluent\" profiles.\n        See examples/response/GetEnc.json for example response data.\n        :return: response json\n        \"\"\"\n        body = [{\"cmd\": \"GetEnc\", \"action\": 1, \"param\": {\"channel\": 0}}]\n        return self._execute_command('GetEnc', body)\n\n    def get_recording_advanced(self) -> Dict:\n        \"\"\"\n        Get recording advanced setup data\n        See examples/response/GetRec.json for example response data.\n        :return: response json\n        \"\"\"\n        body = [{\"cmd\": \"GetRec\", \"action\": 1, \"param\": {\"channel\": 0}}]\n        return self._execute_command('GetRec', body)\n\n    def set_recording_encoding(self,\n                               audio: float = 0,\n                               main_bit_rate: float = 8192,\n                               main_frame_rate: float = 8,\n                               main_profile: str = 'High',\n                               main_size: str = \"2560*1440\",\n                               sub_bit_rate: float = 160,\n                               sub_frame_rate: float = 7,\n                               sub_profile: str = 'High',\n                               sub_size: str = '640*480') -> Dict:\n        \"\"\"\n        Sets the current camera encoding settings for \"Clear\" and \"Fluent\" profiles.\n        :param audio: int Audio on or off\n        :param main_bit_rate: int Clear Bit Rate\n        :param main_frame_rate: int Clear Frame Rate\n        :param main_profile: string Clear Profile\n        :param main_size: string Clear Size\n        :param sub_bit_rate: int Fluent Bit Rate\n        :param sub_frame_rate: int Fluent Frame Rate\n        :param sub_profile: string Fluent Profile\n        :param sub_size: string Fluent Size\n        :return: response\n        \"\"\"\n        body = [\n            {\n                \"cmd\": \"SetEnc\",\n                \"action\": 0,\n                \"param\": {\n                    \"Enc\": {\n                        \"audio\": audio,\n                        \"channel\": 0,\n                        \"mainStream\": {\n                            \"bitRate\": main_bit_rate,\n                            \"frameRate\": main_frame_rate,\n                            \"profile\": main_profile,\n                            \"size\": main_size\n                        },\n                        \"subStream\": {\n                            \"bitRate\": sub_bit_rate,\n                            \"frameRate\": sub_frame_rate,\n                            \"profile\": sub_profile,\n                            \"size\": sub_size\n                        }\n                    }\n                }\n            }\n        ]\n        return self._execute_command('SetEnc', body)\n"
  },
  {
    "path": "reolinkapi/mixins/stream.py",
    "content": "import string\nfrom random import choices\nfrom typing import Any, Optional\nfrom urllib import parse\nfrom io import BytesIO\n\nimport requests\n\ntry:\n    from PIL.Image import Image, open as open_image\n\n    from reolinkapi.utils.rtsp_client import RtspClient\n\n\n    class StreamAPIMixin:\n        \"\"\" API calls for opening a video stream or capturing an image from the camera.\"\"\"\n\n        def open_video_stream(self, callback: Any = None, proxies: Any = None) -> Any:\n            \"\"\"\n            'https://support.reolink.com/hc/en-us/articles/360007010473-How-to-Live-View-Reolink-Cameras-via-VLC-Media-Player'\n            Blocking function creates a generator and returns the frames as it is spawned\n            :param callback:\n            :param proxies: Default is none, example: {\"host\": \"localhost\", \"port\": 8000}\n            \"\"\"\n            rtsp_client = RtspClient(\n                ip=self.ip, username=self.username, password=self.password, profile=self.profile, proxies=proxies, callback=callback)\n            return rtsp_client.open_stream()\n\n        def get_snap(self, timeout: float = 3, proxies: Any = None) -> Optional[Image]:\n            \"\"\"\n            Gets a \"snap\" of the current camera video data and returns a Pillow Image or None\n            :param timeout: Request timeout to camera in seconds\n            :param proxies: http/https proxies to pass to the request object.\n            :return: Image or None\n            \"\"\"\n            data = {\n                'cmd': 'Snap',\n                'channel': 0,\n                'rs': ''.join(choices(string.ascii_uppercase + string.digits, k=10)),\n                'user': self.username,\n                'password': self.password,\n            }\n            parms = parse.urlencode(data, safe=\"!\").encode(\"utf-8\")\n\n            try:\n                response = requests.get(self.url, proxies=proxies, params=parms, timeout=timeout)\n                if response.status_code == 200:\n                    return open_image(BytesIO(response.content))\n                print(\"Could not retrieve data from camera successfully. Status:\", response.status_code)\n                return None\n\n            except Exception as e:\n                print(\"Could not get Image data\\n\", e)\n                raise\nexcept ImportError as err:\n    print(\"ImportError\", err)\n\n    class StreamAPIMixin:\n        \"\"\" API calls for opening a video stream or capturing an image from the camera.\"\"\"\n\n        def open_video_stream(self, callback: Any = None, proxies: Any = None) -> Any:\n            raise ImportError(f'open_video_stream requires streaming extra dependencies\\nFor instance \"pip install '\n                              f'reolinkapi[streaming]\"')\n\n        def get_snap(self, timeout: float = 3, proxies: Any = None) -> Optional['Image']:\n            raise ImportError(\n                f'get_snap requires streaming extra dependencies\\nFor instance \"pip install reolinkapi[streaming]\"')\n"
  },
  {
    "path": "reolinkapi/mixins/system.py",
    "content": "from typing import Dict\n\n\nclass SystemAPIMixin:\n    \"\"\"API for accessing general system information of the camera.\"\"\"\n    def get_general_system(self) -> Dict:\n        \"\"\":return: response json\"\"\"\n        body = [{\"cmd\": \"GetTime\", \"action\": 1, \"param\": {}}, {\"cmd\": \"GetNorm\", \"action\": 1, \"param\": {}}]\n        return self._execute_command('get_general_system', body, multi=True)\n\n    def get_performance(self) -> Dict:\n        \"\"\"\n        Get a snapshot of the current performance of the camera.\n        See examples/response/GetPerformance.json for example response data.\n        :return: response json\n        \"\"\"\n        body = [{\"cmd\": \"GetPerformance\", \"action\": 0, \"param\": {}}]\n        return self._execute_command('GetPerformance', body)\n\n    def get_information(self) -> Dict:\n        \"\"\"\n        Get the camera information\n        See examples/response/GetDevInfo.json for example response data.\n        :return: response json\n        \"\"\"\n        body = [{\"cmd\": \"GetDevInfo\", \"action\": 0, \"param\": {}}]\n        return self._execute_command('GetDevInfo', body)\n\n    def reboot_camera(self) -> Dict:\n        \"\"\"\n        Reboots the camera\n        :return: response json\n        \"\"\"\n        body = [{\"cmd\": \"Reboot\", \"action\": 0, \"param\": {}}]\n        return self._execute_command('Reboot', body)\n\n    def get_dst(self) -> Dict:\n        \"\"\"\n        Get the camera DST information\n        See examples/response/GetDSTInfo.json for example response data.\n        :return: response json\n        \"\"\"\n        body = [{\"cmd\": \"GetTime\", \"action\": 0, \"param\": {}}]\n        return self._execute_command('GetTime', body)\n"
  },
  {
    "path": "reolinkapi/mixins/user.py",
    "content": "from typing import Dict\n\n\nclass UserAPIMixin:\n    \"\"\"User-related API calls.\"\"\"\n    def get_online_user(self) -> Dict:\n        \"\"\"\n        Return a list of current logged-in users in json format\n        See examples/response/GetOnline.json for example response data.\n        :return: response json\n        \"\"\"\n        body = [{\"cmd\": \"GetOnline\", \"action\": 1, \"param\": {}}]\n        return self._execute_command('GetOnline', body)\n\n    def get_users(self) -> Dict:\n        \"\"\"\n        Return a list of user accounts from the camera in json format.\n        See examples/response/GetUser.json for example response data.\n        :return: response json\n        \"\"\"\n        body = [{\"cmd\": \"GetUser\", \"action\": 1, \"param\": {}}]\n        return self._execute_command('GetUser', body)\n\n    def add_user(self, username: str, password: str, level: str = \"guest\") -> bool:\n        \"\"\"\n        Add a new user account to the camera\n        :param username: The user's username\n        :param password: The user's password\n        :param level: The privilege level 'guest' or 'admin'. Default is 'guest'\n        :return: whether the user was added successfully\n        \"\"\"\n        body = [{\"cmd\": \"AddUser\", \"action\": 0,\n                 \"param\": {\"User\": {\"userName\": username, \"password\": password, \"level\": level}}}]\n        r_data = self._execute_command('AddUser', body)[0]\n        if r_data[\"value\"][\"rspCode\"] == 200:\n            return True\n        print(\"Could not add user. Camera responded with:\", r_data[\"value\"])\n        return False\n\n    def modify_user(self, username: str, password: str) -> bool:\n        \"\"\"\n        Modify the user's password by specifying their username\n        :param username: The user which would want to be modified\n        :param password: The new password\n        :return: whether the user was modified successfully\n        \"\"\"\n        body = [{\"cmd\": \"ModifyUser\", \"action\": 0, \"param\": {\"User\": {\"userName\": username, \"password\": password}}}]\n        r_data = self._execute_command('ModifyUser', body)[0]\n        if r_data[\"value\"][\"rspCode\"] == 200:\n            return True\n        print(f\"Could not modify user: {username}\\nCamera responded with: {r_data['value']}\")\n        return False\n\n    def delete_user(self, username: str) -> bool:\n        \"\"\"\n        Delete a user by specifying their username\n        :param username: The user which would want to be deleted\n        :return: whether the user was deleted successfully\n        \"\"\"\n        body = [{\"cmd\": \"DelUser\", \"action\": 0, \"param\": {\"User\": {\"userName\": username}}}]\n        r_data = self._execute_command('DelUser', body)[0]\n        if r_data[\"value\"][\"rspCode\"] == 200:\n            return True\n        print(f\"Could not delete user: {username}\\nCamera responded with: {r_data['value']}\")\n        return False\n"
  },
  {
    "path": "reolinkapi/mixins/zoom.py",
    "content": "from typing import Dict\n\n\nclass ZoomAPIMixin:\n    \"\"\"\n    API for zooming and changing focus.\n    Note that the API does not allow zooming/focusing by absolute\n    values rather that changing focus/zoom for a given time.\n    \"\"\"\n    def _start_operation(self, operation: str, speed: float) -> Dict:\n        data = [{\"cmd\": \"PtzCtrl\", \"action\": 0, \"param\": {\"channel\": 0, \"op\": operation, \"speed\": speed}}]\n        return self._execute_command('PtzCtrl', data)\n\n    def _stop_zooming_or_focusing(self) -> Dict:\n        \"\"\"This command stops any ongoing zooming or focusing actions.\"\"\"\n        data = [{\"cmd\": \"PtzCtrl\", \"action\": 0, \"param\": {\"channel\": 0, \"op\": \"Stop\"}}]\n        return self._execute_command('PtzCtrl', data)\n\n    def get_zoom_focus(self) -> Dict:\n        \"\"\"This command returns the current zoom and focus values.\"\"\"\n        data = [{\"cmd\": \"GetZoomFocus\", \"action\": 0, \"param\": {\"channel\": 0}}]\n        return self._execute_command('GetZoomFocus', data)\n\n    def start_zoom_pos(self, position: float) -> Dict:\n        \"\"\"This command sets the zoom position.\"\"\"\n        data = [{\"cmd\": \"StartZoomFocus\", \"action\": 0, \"param\": {\"ZoomFocus\": {\"channel\": 0, \"op\": \"ZoomPos\", \"pos\": position}}}]\n        return self._execute_command('StartZoomFocus', data)\n\n    def start_focus_pos(self, position: float) -> Dict:\n        \"\"\"This command sets the focus position.\"\"\"\n        data = [{\"cmd\": \"StartZoomFocus\", \"action\": 0, \"param\": {\"ZoomFocus\": {\"channel\": 0, \"op\": \"FocusPos\", \"pos\": position}}}]\n        return self._execute_command('StartZoomFocus', data)\n\n    def get_auto_focus(self) -> Dict:\n        \"\"\"This command returns the current auto focus status.\"\"\"\n        data = [{\"cmd\": \"GetAutoFocus\", \"action\": 0, \"param\": {\"channel\": 0}}]\n        return self._execute_command('GetAutoFocus', data)\n    \n    def set_auto_focus(self, disable: bool) -> Dict:\n        \"\"\"This command sets the auto focus status.\"\"\"\n        data = [{\"cmd\": \"SetAutoFocus\", \"action\": 0, \"param\": {\"AutoFocus\": {\"channel\": 0, \"disable\": 1 if disable else 0}}}]\n        return self._execute_command('SetAutoFocus', data)\n\n    def start_zooming_in(self, speed: float = 60) -> Dict:\n        \"\"\"\n        The camera zooms in until self.stop_zooming() is called.\n        :return: response json\n        \"\"\"\n        return self._start_operation('ZoomInc', speed=speed)\n\n    def start_zooming_out(self, speed: float = 60) -> Dict:\n        \"\"\"\n        The camera zooms out until self.stop_zooming() is called.\n        :return: response json\n        \"\"\"\n        return self._start_operation('ZoomDec', speed=speed)\n\n    def stop_zooming(self) -> Dict:\n        \"\"\"\n        Stop zooming.\n        :return: response json\n        \"\"\"\n        return self._stop_zooming_or_focusing()\n\n    def start_focusing_in(self, speed: float = 32) -> Dict:\n        \"\"\"\n        The camera focuses in until self.stop_focusing() is called.\n        :return: response json\n        \"\"\"\n        return self._start_operation('FocusInc', speed=speed)\n\n    def start_focusing_out(self, speed: float = 32) -> Dict:\n        \"\"\"\n        The camera focuses out until self.stop_focusing() is called.\n        :return: response json\n        \"\"\"\n        return self._start_operation('FocusDec', speed=speed)\n\n    def stop_focusing(self) -> Dict:\n        \"\"\"\n        Stop focusing.\n        :return: response json\n        \"\"\"\n        return self._stop_zooming_or_focusing()\n"
  },
  {
    "path": "reolinkapi/utils/__init__.py",
    "content": ""
  },
  {
    "path": "reolinkapi/utils/rtsp_client.py",
    "content": "import os\nfrom threading import ThreadError\nfrom typing import Any\nimport cv2\nfrom reolinkapi.utils.util import threaded\n\n\nclass RtspClient:\n    \"\"\"\n    This is a wrapper of the OpenCV VideoCapture method\n    Inspiration from:\n        - https://benhowell.github.io/guide/2015/03/09/opencv-and-web-cam-streaming\n        - https://stackoverflow.com/questions/19846332/python-threading-inside-a-class\n        - https://stackoverflow.com/questions/55828451/video-streaming-from-ip-camera-in-python-using-opencv-cv2-videocapture\n    \"\"\"\n\n    def __init__(self, ip: str, username: str, password: str, port: float = 554, profile: str = \"main\",\n                 use_udp: bool = True, callback: Any = None, **kwargs):\n        \"\"\"\n        RTSP client is used to retrieve frames from the camera in a stream\n\n        :param ip: Camera IP\n        :param username: Camera Username\n        :param password: Camera User Password\n        :param port: RTSP port\n        :param profile: \"main\" or \"sub\"\n        :param use_upd: True to use UDP, False to use TCP\n        :param proxies: {\"host\": \"localhost\", \"port\": 8000}\n        \"\"\"\n        self.capture = None\n        self.thread_cancelled = False\n        self.callback = callback\n\n        capture_options = 'rtsp_transport;'\n        self.ip = ip\n        self.username = username\n        self.password = password\n        self.port = port\n        self.proxy = kwargs.get(\"proxies\")\n        self.url = f'rtsp://{self.username}:{self.password}@{self.ip}:{self.port}//h264Preview_01_{profile}'\n        capture_options += 'udp' if use_udp else 'tcp'\n\n        os.environ[\"OPENCV_FFMPEG_CAPTURE_OPTIONS\"] = capture_options\n\n        # opens the stream capture, but does not retrieve any frames yet.\n        self._open_video_capture()\n\n    def _open_video_capture(self):\n        # To CAP_FFMPEG or not To ?\n        self.capture = cv2.VideoCapture(self.url, cv2.CAP_FFMPEG)\n\n    def _stream_blocking(self):\n        while True:\n            try:\n                if self.capture.isOpened():\n                    ret, frame = self.capture.read()\n                    if ret:\n                        yield frame\n                else:\n                    print(\"stream closed\")\n                    self.capture.release()\n                    return\n            except Exception as e:\n                print(e)\n                self.capture.release()\n                return\n\n    @threaded\n    def _stream_non_blocking(self):\n        while not self.thread_cancelled:\n            try:\n                if self.capture.isOpened():\n                    ret, frame = self.capture.read()\n                    if ret:\n                        self.callback(frame)\n                else:\n                    print(\"stream is closed\")\n                    self.stop_stream()\n            except ThreadError as e:\n                print(e)\n                self.stop_stream()\n\n    def stop_stream(self):\n        self.capture.release()\n        self.thread_cancelled = True\n\n    def open_stream(self):\n        \"\"\"\n        Opens OpenCV Video stream and returns the result according to the OpenCV documentation\n        https://docs.opencv.org/3.4/d8/dfe/classcv_1_1VideoCapture.html#a473055e77dd7faa4d26d686226b292c1\n        \"\"\"\n\n        # Reset the capture object\n        if self.capture is None or not self.capture.isOpened():\n            self._open_video_capture()\n\n        print(\"opening stream\")\n\n        if self.callback is None:\n            return self._stream_blocking()\n        else:\n            # reset the thread status if the object was not re-created\n            if not self.thread_cancelled:\n                self.thread_cancelled = False\n            return self._stream_non_blocking()\n"
  },
  {
    "path": "reolinkapi/utils/util.py",
    "content": "from threading import Thread\n\n\ndef threaded(fn):\n    def wrapper(*args, **kwargs):\n        thread = Thread(target=fn, args=args, kwargs=kwargs)\n        thread.daemon = True\n        thread.start()\n        return thread\n\n    return wrapper\n"
  },
  {
    "path": "requirements.txt",
    "content": "."
  },
  {
    "path": "setup.py",
    "content": "#!/usr/bin/python3\nimport os\nimport re\nimport codecs\nfrom setuptools import setup, find_packages\n\n\ndef read(*parts):\n    with codecs.open(os.path.join(here, *parts), 'r') as fp:\n        return fp.read()\n\n\ndef find_version(*file_paths):\n    version_file = read(*file_paths)\n    version_match = re.search(r\"^__version__ = ['\\\"]([^'\\\"]*)['\\\"]\", version_file, re.M)\n    if version_match:\n        return version_match.group(1)\n    raise RuntimeError(\"Unable to find version string.\")\n\n\n# Package meta-data.\nNAME = 'reolinkapi'\nDESCRIPTION = 'Reolink Camera API client written in Python 3'\nURL = 'https://github.com/ReolinkCameraAPI/reolinkapipy'\nAUTHOR_EMAIL = 'alanoterblanche@gmail.com'\nAUTHOR = 'Benehiko'\nLICENSE = 'GPL-3.0'\nINSTALL_REQUIRES = [\n    'setuptools',\n    'PySocks==1.7.1',\n    'PyYaml==6.0.2',\n    'requests>=2.32.3',\n]\nEXTRAS_REQUIRE = {\n    'streaming': [\n        'numpy==2.0.1',\n        'opencv-python==4.10.0.84',\n        'Pillow==10.4.0',\n    ],\n}\n\n\nhere = os.path.abspath(os.path.dirname(__file__))\n# read the contents of your README file\nwith open(os.path.join(here, 'README.md'), encoding='utf-8') as f:\n    long_description = f.read()\n\n\nsetup(\n    name=NAME,\n    python_requires='>=3.12.4',\n    version=find_version('reolinkapi', '__init__.py'),\n    description=DESCRIPTION,\n    long_description=long_description,\n    long_description_content_type='text/markdown',\n    author=AUTHOR,\n    author_email=AUTHOR_EMAIL,\n    url=URL,\n    license=LICENSE,\n    install_requires=INSTALL_REQUIRES,\n    packages=find_packages(exclude=['examples', 'tests']),\n    extras_require=EXTRAS_REQUIRE\n)\n"
  },
  {
    "path": "tests/test_camera.py",
    "content": "import os\nfrom configparser import RawConfigParser\nimport unittest\nfrom reolinkapi import Camera\n\n\ndef read_config(props_path: str) -> dict:\n    \"\"\"Reads in a properties file into variables.\n\n    NB! this config file is kept out of commits with .gitignore. The structure of this file is such:\n    # secrets.cfg\n        [camera]\n        ip={ip_address}\n        username={username}\n        password={password}\n    \"\"\"\n    config = RawConfigParser()\n    assert os.path.exists(props_path), f\"Path does not exist: {props_path}\"\n    config.read(props_path)\n    return config\n\n\nclass TestCamera(unittest.TestCase):\n\n    @classmethod\n    def setUpClass(cls) -> None:\n        cls.config = read_config('../secrets.cfg')\n\n    def setUp(self) -> None:\n        self.cam = Camera(self.config.get('camera', 'ip'), self.config.get('camera', 'username'),\n                          self.config.get('camera', 'password'))\n\n    def test_camera(self):\n        \"\"\"Test that camera connects and gets a token\"\"\"\n        self.assertTrue(self.cam.ip == self.config.get('camera', 'ip'))\n        self.assertTrue(self.cam.token != '')\n\n    def test_snapshot(self):\n        img = self.cam.get_snap()\n        # write Pillow Image to file\n        img.save('./tmp/snaps/camera.jpg')\n        self.assertTrue(os.path.exists('./tmp/snaps/camera.jpg'))\n\n\nif __name__ == '__main__':\n    unittest.main()\n"
  }
]