Skip to content

Commit

Permalink
Preliminary implemented device and location functional modules.
Browse files Browse the repository at this point in the history
  • Loading branch information
Haoke98 committed Nov 15, 2023
1 parent dbda93e commit afae21c
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 7 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ Options:
--help Show this message and exit.

Commands:
photo-download
test

device Device and Location, Find device Location, Get device...
photo-download Manage Photos on your icloud.
test Do some experimental tes.
```
## <img width="50" src="assets/1c11f0fa22d4e93f8dc179b8ff84791d.png"> Photos Download (2FA)
```shell
Expand Down Expand Up @@ -85,7 +85,7 @@ Hidden



## <img width="50" src="docs/statics/location.png"> Device And Location (No 2FA)
## <img width="50" src="docs/statics/location.png"> Device And Location (2FA)


```python
Expand Down
37 changes: 34 additions & 3 deletions icloud.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import logging

import click
from prettytable import PrettyTable

from lib import icloud, logger

Expand Down Expand Up @@ -43,7 +44,8 @@ def main(username, password, china_account):
iService = icloud.IcloudService(username, password, china_account)


@main.command(options_metavar="<options>")
@main.command(options_metavar="<options>",
help="Manage Photos on your icloud. (Transform Album, Download recent photos.)")
@click.option(
"-d", "--directory",
help="Local directory that should be used for download",
Expand Down Expand Up @@ -89,7 +91,36 @@ def photo_download(directory, transfer_album, recent, auto_delete, modify_olds,
max_thread_count=workers)


@main.command(options_metavar="<options>")
@main.command(options_metavar="<options>",
help="Device and Location, Find device Location, Get device Status, Show message on device, Remote lock device.")
def device():
table = PrettyTable()
table.field_names = ["序号", "设备名称", "型号", "探索ID", "状态", "能否获取位置信息?", "是否可以在锁定后擦除?", "是否已开启家人分享?", "能否标记为丢失?", "电池水平",
"丢失时间", "ID"]
devices = iService.devices
for i, device in enumerate(devices):
data = device.data
table.add_row(
[i, data.get("name"), data.get("deviceModel"), data.get("deviceDiscoveryId"), data.get("deviceStatus"),
data.get("locationEnabled"), data.get("canWipeAfterLock"), data.get("fmlyShare"),
data.get("lostModeCapable"), data.get("batteryLevel"), data.get("lostTimeStamp"), data.get("id")])
pass
print(table)
while True:
i = click.prompt('Which device would you like to use?', type=int, default=0)
row = table._rows[i]
device_id = row[-1]
device = devices[device_id]
print("CurrentStatus:", device.status())
print("CurrentLocation:", device.location())
isOk = click.prompt("Do you want to show some message on your device?", type=bool, default=False)
if isOk:
msg = click.prompt("Please input some message here.", default="Don't do anything on my device.")
device.display_message(message=msg)
print("Its Done@!")


@main.command(options_metavar="<options>", help="Do some experimental tes.")
def test():
global iService
for i, album_name in enumerate(iService.photos.albums):
Expand All @@ -105,5 +136,5 @@ def test():


if __name__ == "__main__":
logger.init("icloud")
logger.init("icloud", console_level=logging.INFO)
main()

0 comments on commit afae21c

Please sign in to comment.