Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Various ease-of-use enhancements #1

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,9 @@ Warning: This is not meant to be a fool-proof guide. This is oriented towards th

I've only used this on macOS. Linux instructions should be pretty identical. Windows should be pretty close.

* Plug in your USB drive and unmount it.
* Figure out the device node for your FAT32 partition. On macOS, you can find this in Disk Utility when you click the "Info" button for your volume. It should be something like "disk2s1".
* Create a directory for the output.
* Run the script, providing the directory path and device node like so: `sudo ./run.py /dev/disk2s1 myoutputdirectory`
* Plug in your USB drive.
* Run script: `./run.sh`
* Follow insctructions on screen

This will take a while. The script is not made for space or time efficiency. You'll need a lot of spare disk space (possibly up to twice as much as your drive's capacity).

Expand Down
19 changes: 15 additions & 4 deletions run.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ def dumpBinary(data):


if len(sys.argv) < 3:
print 'Usage: '+sys.argv[0]+' input outputdir'
print 'Teslacam recovery tool'
print 'Usage: '+sys.argv[0]+' input output_dir'
print 'Ex: '+sys.argv[0]+' /dev/disk2s1 ~/Downloads/'
sys.exit()

f = open(sys.argv[1], 'rb')
Expand Down Expand Up @@ -185,10 +187,13 @@ def extractMP4s(startCluster, endCluster, maxSize):
os.mkdir('%s/mp4s' % (sys.argv[2]))
except OSError:
pass

print '--- extractMP4s from %d to %d' % (startCluster, endCluster)

cluster = startCluster
while cluster < endCluster:
if cluster % 1000 == 0:
print 'Currently on cluster %d' % (cluster)
print '- cluster %d:' % (cluster)
f.seek(clust2byte(cluster))
header = f.read(12)
if header == '\0\0\0 ftypmp42':
Expand Down Expand Up @@ -216,8 +221,14 @@ def extractMP4s(startCluster, endCluster, maxSize):
#print 'Reading directories...'
#readDirectory(rootDirectoryCluster, 1)

print 'Finding mp4s...'
extractMP4s(0, totalClusters, 40000000)
print '--- Finding mp4 ...'

gStartingCluster = 0
if len(sys.argv) >= 4:
gStartingCluster = int(sys.argv[3])
# print 'Starting cluster = %d' % (gStartingCluster)

extractMP4s(gStartingCluster, totalClusters, 40000000)

print

Expand Down
32 changes: 32 additions & 0 deletions run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/bin/bash

diskId=disk2
deviceNode=/dev/${diskId}s1

isUsbDrive() {
diskutil list $diskId
echo "=== $diskId info"
info=$(diskutil info $diskId | egrep 'Protocol|Whole|Media Name|Removable')

local returnStr=$(printf "$info\n" | grep -m1 Protocol | cut -d ':' -f 2)
echo "Protocol: $returnStr"
if [[ "$returnStr" != *"USB" ]]; then echo "Not $expectedDeviceName. Exit"; exit; fi

returnStr=$(printf "$info\n" | grep -m1 Whole | cut -d ':' -f 2)
echo "Whole: $returnStr"
if [[ "$returnStr" != *"Yes" ]]; then echo "Not whole $expectedDeviceName. Exit"; exit; fi

echo "$info"
}

isUsbDrive

echo ""
read -p "Please confirm that $deviceNode is your teslacam usb? (y/n) " answer
if [ "$answer" != "y" ]; then
echo "In run.sh file, edit the line diskId=disk2 to your usb drive"
exit; fi

diskutil unmount $deviceNode
mkdir -p ~/Downloads/teslacam/
sudo ./run.py $deviceNode ~/Downloads/teslacam/ 0