Skip to content

Commit

Permalink
feat: add devices property to Info
Browse files Browse the repository at this point in the history
  • Loading branch information
blacktop committed Apr 10, 2023
1 parent be25b71 commit 512fd3a
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,12 @@ import ipsw
client = ipsw.IpswClient(base_url='tcp://127.0.0.1:8080')
info = client.info.get("iPhone15,2_16.5_20F5028e_Restore.ipsw")
print(f'{info.version} ({info.build})')
for device in info.devices:
print(f'- {device}')
```
```bash
16.5 (20F5028e)
- iPhone 14 Pro
```

## Community
Expand Down
14 changes: 14 additions & 0 deletions ipsw/models/info.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,20 @@ def build(self):
The iOS version.
"""
return self.attrs["info"]["Plists"]["restore"].get("ProductBuildVersion", None)

@property
def devices(self):
"""
The iOS devices.
"""
devices = set()
for dt in self.attrs['info']['DeviceTrees'].values():
for child in dt['device-tree']['children']:
if 'product' in child:
devices.add(child['product']['product-name'])
devlist = list(devices)
devlist.sort()
return devlist


class InfoCollection(Collection):
Expand Down

0 comments on commit 512fd3a

Please sign in to comment.