Python实现视频桌面

IyAtKi0gY29kaW5nOiB1dGYtOCAtKi0KTCmltcG9ydCBvcwppbXBvcnQgdGltZQppbXBvcnQgeWFtbAoKaW1wb3J0IHdpbjMyYXBpCmltcG9ydCB3aW4zMmNvbgppbXBvcnQgd2luMzJndWkKaW1wb3J0IHN1YnByb2Nlc3MKZnJvbSBzY3JlZW5pbmZvIGltcG9ydCBnZXRfbW9uaXRvcnMKCmltcG9ydCBrZXlib2FyZAppbXBvcnQgdGhyZWFkaW5nCgp2aWRlb19oID0gTm9uZQpjb25maWcgPSBOb25lCgoKY2xhc3MgV2luREludGVyY2VwdG9yOgogICAgZGVmIF9faW5pdF9fKHNlbGYpOgogICAgICAgIHNlbGYuaXNfaW50ZXJjZXB0aW5nID0gRmFsc2UKICAgICAgICBzZWxmLmludGVyY2VwdF90aHJlYWQgPSBOb25lCgogICAgZGVmIHN0YXJ0X2ludGVyY2VwdChzZWxmKToKICAgICAgICBpZiBub3Qgc2VsZi5pc19pbnRlcmNlcHRpbmc6CiAgICAgICAgICAgIHNlbGYuaXNfaW50ZXJjZXB0aW5nID0gVHJ1ZQogICAgICAgICAgICBzZWxmLmludGVyY2VwdF90aHJlYWQgPSB0aHJlYWRpbmcuVGhyZWFkKHRhcmdldD1zZWxmLl9pbnRlcmNlcHRfbG9vcCkKICAgICAgICAgICAgc2VsZi5pbnRlcmNlcHRfdGhyZWFkLnN0YXJ0KCkKCiAgICBkZWYgc3RvcF9pbnRlcmNlcHQoc2VsZik6CiAgICAgICAgcHJpbnQoJ3N0b3BfaW50ZXJjZXB0JykKICAgICAgICBpZiBzZWxmLmlzX2ludGVyY2VwdGluZzoKICAgICAgICAgICAgc2VsZi5pc19pbnRlcmNlcHRpbmcgPSBGYWxzZQogICAgICAgICAgICBzZWxmLmludGVyY2VwdF90aHJlYWQuam9pbigpCgogICAgZGVmIF9pbnRlcmNlcHRfbG9vcChzZWxmKToKICAgICAgICBrZXlib2FyZC5vbl9wcmVzcyhzZWxmLl9vbl9rZXlfcHJlc3MpCiAgICAgICAga2V5Ym9hcmQud2FpdCgnZXNjJykKICAgICAgICBrZXlib2FyZC51bmhvb2tfYWxsKCkKCiAgICBkZWYgX29uX2tleV9wcmVzcyhzZWxmLCBldmVudCk6CiAgICAgICAgaWYgZXZlbnQubmFtZSA9PSAnZCcgYW5kIGtleWJvYXJkLmlzX3ByZXNzZWQoJ3dpbicpOgogICAgICAgICAgICBod25kID0gd2luMzJndWkuRmluZFdpbmRvdygiUHJvZ21hbiIsICJQcm9ncmFtIE1hbmFnZXIiKQogICAgICAgICAgICB0aW1lLnNsZWVwKDAuMSkKICAgICAgICAgICAgd2luMzJndWkuU2hvd1dpbmRvdyh2aWRlb19oLCB3aW4zMmNvbi5TV19SRVNUT1JFKQoKCmNsYXNzIFZpZGVvUGxheWVyOgogICAgZGVmIF9faW5pdF9fKHNlbGYsIHZpZGVvX3BhdGgpOgogICAgICAgIHNlbGYucGxheWVyX3BhdGggPSBvcy5wYXRoLmFic3BhdGgoImZmcGxheS5leGUiKQogICAgICAgIHNlbGYudmlkZW9fcGF0aCA9IHZpZGVvX3BhdGgKCiAgICBkZWYgcGxheV92aWRlbyhzZWxmKToKICAgICAgICBtb25pdG9ycyA9IGdldF9tb25pdG9ycygpCiAgICAgICAgc2NyZWVuX3dpZHRoID0gbW9uaXRvcnNbMF0ud2lkdGgKICAgICAgICBzY3JlZW5faGVpZ2h0ID0gbW9uaXRvcnNbMF0uaGVpZ2h0CgogICAgICAgIHBhcmFtZXRlcnMgPSBbCiAgICAgICAgICAgIHNlbGYucGxheWVyX3BhdGgsCiAgICAgICAgICAgIHNlbGYudmlkZW9fcGF0aCwKICAgICAgICAgICAgIi1ub2JvcmRlciIsCiAgICAgICAgICAgICItdmYiLAogICAgICAgICAgICBmInNjYWxlPXtzY3JlZW5fd2lkdGh9OntzY3JlZW5faGVpZ2h0fSxzZXRzYXI9MSIsCiAgICAgICAgICAgICItbG9vcCIsICIwIiwKICAgICAgICAgICAgIi1hbiIKICAgICAgICBdCgogICAgICAgIGlmICJhdWRpbyIgaW4gY29uZmlnOgogICAgICAgICAgICBpZiBjb25maWdbJ2F1ZGlvJ10gPT0gMToKICAgICAgICAgICAgICAgIHBhcmFtZXRlcnMucmVtb3ZlKCItYW4iKQoKICAgICAgICBzdGFydHVwX2luZm8gPSBzdWJwcm9jZXNzLlNUQVJUVVBJTkZPKCkKICAgICAgICBwcm9jZXNzID0gc3VicHJvY2Vzcy5Qb3BlbihwYXJhbWV0ZXJzLCBzdGFydHVwaW5mbz1zdGFydHVwX2luZm8pCiAgICAgICAgdGltZS5zbGVlcCgwLjIpCiAgICAgICAgcmV0dXJuIHByb2Nlc3MKCgpkZWYgZm9yY2VfaGlkZV93b3JrdzIoKToKICAgIGh3bmQgPSB3aW4zMmd1aS5GaW5kV2luZG93KCJQcm9nbWFuIiwgIlByb2dyYW0gTWFuYWdlciIpCiAgICB3b3JrZXJXMSA9IE5vbmUKICAgIHdoaWxlIDE6CiAgICAgICAgd29ya2VyVzEgPSB3aW4zMmd1aS5GaW5kV2luZG93RXgoTm9uZSwgd29ya2VyVzEsICJXb3JrZXJXIiwgTm9uZSkKICAgICAgICBpZiBub3Qgd29ya2VyVzE6CiAgICAgICAgICAgIGNvbnRpbnVlCiAgICAgICAgIyBwcmludCgnd29ya2VyVzE6ICcsIHdvcmtlclcxKQogICAgICAgIHN1Yldpbk9mV29ya2VyVzEgPSB3aW4zMmd1aS5GaW5kV2luZG93RXgod29ya2VyVzEsIE5vbmUsICJTSEVMTERMTF9EZWZWaWV3IiwgTm9uZSkKICAgICAgICBpZiBub3Qgc3ViV2luT2ZXb3JrZXJXMToKICAgICAgICAgICAgY29udGludWUKICAgICAgICAjIHByaW50KCdzdWJXaW5PZldvcmtlclcxOiAnLCBzdWJXaW5PZldvcmtlclcxKQogICAgICAgIHdvcmtlclcyID0gd2luMzJndWkuRmluZFdpbmRvd0V4KE5vbmUsIHdvcmtlclcxLCAiV29ya2VyVyIsIE5vbmUpCiAgICA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V93aW5faCkKICAgIHdpbjMyZ3VpLlNldFBhcmVudCh2aWRlb19oLCBwcm9ncmFtX3dpbl9oKQoKaWYgX19uYW1lX18gPT0gIl9fbWFpbl9fIjoKICAgICMg6K+75Y+WWUFNTOmFjee9ruaWh+S7tgogICAgd2l0aCBvcGVuKCdjb25maWcueWFtbCcsICdyJywgZW5jb2Rpbmc9J3V0Zi04JykgYXMgZjoKICAgICAgICBjb25maWcgPSB5YW1sLnNhZmVfbG9hZChmKQoKICAgICMg5riF55CG5bey5pyJ55qE6KeG6aKR56qX5Y+jCiAgICBvcy5zeXN0ZW0oInRza2lsbCBmZnBsYXkqIikKICAgIHRpbWUuc2xlZXAoMC4xKQoKICAgICMg5omT5byA6KeG6aKR5paH5Lu2CiAgICBwbGF5ZXIgPSBWaWRlb1BsYXllcihjb25maWdbJ3ZpZGVvJ11bMF0pCiAgICBwcm9jZXNzID0gcGxheWVyLnBsYXlfdmlkZW8oKQoKICAgIHNwbGl0X2Rlc2t0b3Bfd2luKCkKCiAgICBzZXRfdmlkZW9fcGFyZW50KCkKCiAgICBmb3JjZV9oaWRlX3dvcmt3MigpCgogICAgIyDkuLvnqIvluo/npLrkvosKICAgIGludGVyY2VwdG9yID0gV2luREludGVyY2VwdG9yKCkKICAgIGludGVyY2VwdG9yLnN0YXJ0X2ludGVyY2VwdCgpCiAgICB0cnk6CiAgICAgICAgcHJvY2Vzcy53YWl0KCkKICAgIGZpbmFsbHk6CiAgICAgICAgb3Muc3lzdGVtKCJ0c2tpbGwgZmZwbGF5KiIpCiAgICAgICAgaW50ZXJjZXB0b3Iuc3RvcF9pbnRlcmNlcHQoKQoK
posted @ 2023-08-27 21:36  Eric-Liu  阅读(211)  评论(0编辑  收藏  举报