aidandenlinger / SnapchatMemoriesCaptionAdder

Adds metadata (captions and timestamps) to your exported Snapchat memories.
MIT License
23 stars 4 forks source link

python -m pip install -r requirements.txt #2

Closed swagdakies closed 1 year ago

swagdakies commented 1 year ago

I have everything installed including Python, I was wondering where I run the python -m pip install -r requirements.txt link

aidandenlinger commented 1 year ago

Hi! You should download the repo, either by using the Git command line tool to clone it or by clicking on the Code button, download ZIP, and unzipping the repo:

image

Once you have the repo cloned, you want to open a terminal in that folder. You could navigate to the folder by using the cd command in Powershell/Terminal. If you're unfamiliar with the terminal, other ways you can do this are

You should now be inside the folder, and can run the python command:

image

This project has gotten more attention than I planned on, these instructions are intended for those more familiar with developer tooling, and even then it's still a bit of a pain. I make no promises, but I'll try to look into making an actual application with windows and buttons and such instead of a terminal so this can be more usable by everyone :)

Let me know if you run into any other problems or questions!

swagdakies commented 1 year ago

Thank you so much for answering. With your instructions I was able to start running the main.py script. It started running the script, then popped up with “AssertionError” and stopped running

aidandenlinger commented 1 year ago

That means there's something wrong with my code :) Could you copy and paste everything the program output (including the full error) so I can investigate? Thanks!

swagdakies commented 1 year ago

I tried running the code again and got a different error

"Exception: input/memories_history.json is not a file! Please place it in the default location (input/memories_history.json) or specify the path with the --memories-history flag."

I do have the memories_history.json in the input file. I'm on a MacBook.

aidandenlinger commented 1 year ago

The code expects a folder named input with a memories_history.json file and a memories folder inside of it. It should have the same structure as the test folder. Let me know if you have that and it isn't working!

swagdakies commented 1 year ago

Yes I have that and it’s not working

On Sat, Oct 21, 2023 at 2:30 AM Aidan @.***> wrote:

The code expects a folder named input with a memories_history.json file and a memories folder inside of it. It should have the same structure as the test folder. Let me know if you have that and it isn't working!

— Reply to this email directly, view it on GitHub https://github.com/aidandenlinger/SnapchatMemoriesMetadataAdder/issues/2#issuecomment-1773705542, or unsubscribe https://github.com/notifications/unsubscribe-auth/BDLMB3XQODTMMYXDT7DQQ7TYAN2YFAVCNFSM6AAAAAA6ESYHUOVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTONZTG4YDKNJUGI . You are receiving this because you authored the thread.Message ID: @.*** com>

aidandenlinger commented 1 year ago

Just to provide a visual example, it should look something like this:

image

This is the folder with the code, with an input folder I've added. The name of the folder specifically needs to be input.

image

This is what's inside the input folder: a memories folder and a memories_history.json file.

If this is your exact file structure, can you open main.py in TextEdit, delete the # from line 17 so that it goes from # logging.basicConfig(level=logging.DEBUG) to logging.basicConfig(level=logging.DEBUG) (so from image to image ) then save the file, run the script again and copy paste everything from the Terminal? This will output more information that will make it easier to debug.

Thank you for your patience!

swagdakies commented 1 year ago

Did that and got:

@.*** ~ % python3 /Users/swagdakies/Desktop/SnapchatMemoriesMetadataAdder-main/main.py

Traceback (most recent call last):

File "/Users/swagdakies/Desktop/SnapchatMemoriesMetadataAdder-main/main.py", line 81, in

main()

File "/Users/swagdakies/Desktop/SnapchatMemoriesMetadataAdder-main/main.py", line 18, in main

args = parse_args()

       ^^^^^^^^^^^^

File "/Users/swagdakies/Desktop/SnapchatMemoriesMetadataAdder-main/args.py", line 35, in parse_args

raise Exception(

Exception: input/memories_history.json is not a file! Please place it in the default location (input/memories_history.json) or specify the path with the --memories-history flag.

On Sat, Oct 21, 2023 at 5:35 PM Aidan @.***> wrote:

Just to provide a visual example, it should look something like this:

[image: image] https://user-images.githubusercontent.com/47428697/277136452-9a83f51e-e2bd-4c94-adb8-9182bcd6c27b.png

This is the folder with the code, with an input folder I've added. The name of the folder specifically needs to be input.

[image: image] https://user-images.githubusercontent.com/47428697/277136470-78663a33-d39b-45e9-b487-5d15193ed61a.png

This is what's inside the input folder: a memories folder and a memories_history.json folder.

If this is your exact file structure, can you open main.py in TextEdit, delete the # from line 17 so that it goes from # logging.basicConfig(level=logging.DEBUG) to logging.basicConfig(level=logging.DEBUG) (so from [image: image] https://user-images.githubusercontent.com/47428697/277136539-f5ac2b38-c98f-44d0-b39e-afa83bd2a027.png to [image: image] https://user-images.githubusercontent.com/47428697/277136545-9b9f62ee-c004-45ac-9465-6da4415e389b.png ) then save the file, run the script again and copy paste everything from the Terminal?

Thank you for your patience!

— Reply to this email directly, view it on GitHub https://github.com/aidandenlinger/SnapchatMemoriesMetadataAdder/issues/2#issuecomment-1773937634, or unsubscribe https://github.com/notifications/unsubscribe-auth/BDLMB3U27ZA5DJSFAEVBRX3YARE35AVCNFSM6AAAAAA6ESYHUOVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTONZTHEZTONRTGQ . You are receiving this because you authored the thread.Message ID: @.*** com>

aidandenlinger commented 1 year ago

Ah, okay I think I know why. You need to run the script from within the SnapchatMemoriesMetadataAdder folder so that it can find the input folder.

If you run cd ~/Desktop/SnapchatMemoriesMetadataAdder-main then run python3 main.py it should find the input folder. cd will change directory into the SnapchatMemoriesMetadataAdder-main folder. You need to do the cd command each time you open Terminal. We'll probably need to solve the AssertionError from there though :)

swagdakies commented 1 year ago

ah yes that's what i was missing, and now back to this error.

Handling images...

/Users/swagdakies/Downloads/SnapchatMemoriesMetadataAdder-main/main.py:34: TqdmWarning: Iterable length 3098 > 1000 but chunksize is not set. This may seriously degrade multiprocess performance. Set chunksize=1 or more.

images = process_map(

0%| | 0/3098 [00:00<?, ?it/s]

concurrent.futures.process._RemoteTraceback:

"""

Traceback (most recent call last):

File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/concurrent/futures/process.py", line 258, in _process_worker

r = call_item.fn(*call_item.args, **call_item.kwargs)

    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/concurrent/futures/process.py", line 207, in _process_chunk

return [fn(*args) for args in chunk]

        ^^^^^^^^^

File "/Users/swagdakies/Downloads/SnapchatMemoriesMetadataAdder-main/SnapchatMemoriesMetadataAdder/adder.py", line 48, in add_metadata

assert base.exists()

AssertionError

"""

The above exception was the direct cause of the following exception:

Traceback (most recent call last):

File "/Users/swagdakies/Downloads/SnapchatMemoriesMetadataAdder-main/main.py", line 81, in

main()

File "/Users/swagdakies/Downloads/SnapchatMemoriesMetadataAdder-main/main.py", line 34, in main

images = process_map(

         ^^^^^^^^^^^^

File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/tqdm/contrib/concurrent.py", line 105, in process_map

return _executor_map(ProcessPoolExecutor, fn, *iterables, **tqdm_kwargs)

       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/tqdm/contrib/concurrent.py", line 51, in _executor_map

return list(tqdm_class(ex.map(fn, *iterables, chunksize=chunksize),

**kwargs))

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/tqdm/std.py", line 1182, in iter

for obj in iterable:

File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/concurrent/futures/process.py", line 608, in _chain_from_iterable_of_lists

for element in iterable:

File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/concurrent/futures/_base.py", line 619, in result_iterator

yield _result_or_cancel(fs.pop())

      ^^^^^^^^^^^^^^^^^^^^^^^^^^^

File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/concurrent/futures/_base.py", line 317, in _result_or_cancel

return fut.result(timeout)

       ^^^^^^^^^^^^^^^^^^^

File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/concurrent/futures/_base.py", line 456, in result

return self.__get_result()

       ^^^^^^^^^^^^^^^^^^^

File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/concurrent/futures/_base.py", line 401, in __get_result

raise self._exception

AssertionError

@.*** SnapchatMemoriesMetadataAdder-main %

On Sun, Oct 22, 2023 at 2:43 PM Aidan @.***> wrote:

Ah, okay I think I know why. You need to run the script from within the SnapchatMemoriesMetadataAdder folder so that it can find the input folder.

If you run cd ~/Desktop/SnapchatMemoriesMetadataAdder-main then run python3 main.py it should find the input folder. cd will change directory into the SnapchatMemoriesMetadataAdder-main folder. You need to do the cd command each time you open Terminal. We'll probably need to solve the AssertionError from there though :)

— Reply to this email directly, view it on GitHub https://github.com/aidandenlinger/SnapchatMemoriesMetadataAdder/issues/2#issuecomment-1774181877, or unsubscribe https://github.com/notifications/unsubscribe-auth/BDLMB3TUYXTUWPWRWZZEY5LYAVZNVAVCNFSM6AAAAAA6ESYHUOVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTONZUGE4DCOBXG4 . You are receiving this because you authored the thread.Message ID: @.*** com>

aidandenlinger commented 1 year ago

Thank you! This is crashing because the memories_history.json file says there's an image with a specific name, but the memories folder doesn't actually have that image. I set the program to crash in this case, because with my data I didn't run into that case. I've now fixed this in 287e7bf, so the code will now ignore any situations like this and carry on with as many images as this can.

One reason this could be happening is that if Snapchat gives you several zip files when downloading your memories, you need to make sure all of the memories images are put into one memories folder. (For example, if you got two zip files and one of them had memories/1.jpg and the second one had memories/2.jpg, you need to make sure the folder given to this program is a memories folder that holds both 1.jpg and 2.jpg). The README is definitely unclear - the memories folder should hold only jpgs and overlays, it should not hold folders. Your input folder should have the same structure as the test folder.

Then, redownload the code which now has this fix and try running it. If you get several warnings about base images missing, we should debug, but hopefully this is just the case for a few images and most of them get converted.

swagdakies commented 1 year ago

Thanks so much, I was able to get a lot more downloaded. I do have all zip files combined into one memories folder. I did get a lot of base images missing errors but it did complete the script.

On Mon, Oct 23, 2023 at 11:52 AM Aidan @.***> wrote:

Thank you! This is crashing because the memories_history.json file says there's an image with a specific name, but the memories folder doesn't actually have that image. I set the program to crash in this case, because with my data I didn't run into it. I've now fixed this in ca1052e https://github.com/aidandenlinger/SnapchatMemoriesMetadataAdder/commit/ca1052e67ee5371c96bf2b215713bdce71269da9, so the code will now ignore any images like this.

One reason this could be happening is that if Snapchat gives you several zip files when downloading your memories, you need to make sure all of the memories images are put into one memories folder. (For example, if you got two zip files and one of them had memories/1.jpg and the second one had memories/2.jpg, you need to make sure the folder given to this program is a memories folder that holds both 1.jpg and 2.jpg). So make sure that's complete.

Then, redownload the code which now has this fix and try running it. If you get several warnings about base images missing, we should debug, but hopefully this is just the case for a few images.

— Reply to this email directly, view it on GitHub https://github.com/aidandenlinger/SnapchatMemoriesMetadataAdder/issues/2#issuecomment-1775613288, or unsubscribe https://github.com/notifications/unsubscribe-auth/BDLMB3TJO53D774DQB73VA3YA2OGJAVCNFSM6AAAAAA6ESYHUOVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTONZVGYYTGMRYHA . You are receiving this because you authored the thread.Message ID: @.*** com>

aidandenlinger commented 1 year ago

Really glad you were able to get a lot more images saved! This script definitely wasn't designed in a very user friendly way, thank you for your patience :)

One thing that would definitely cause the script to have this error is if there any images with names that end with -main but aren't .jpg or .mp4 files. In my exports, all the -main files were either jpgs or mp4s, and all the -overlay files were pngs, so the script assumes this is true. If this isn't the case for you let me know, that would explain the problem and I could fix it up.

If that isn't it, I'm not confident what the problem is. What this program ultimately does is read in information about images that are in memories_history.json (this includes the date the image was taken), find the corresponding image and overlay in the memories folder, and then combine the overlay, image, and the memories_history info into one final image/video. I'm not sure what would cause a memory to be in memories_history.json, but for the image to not actually be in the memories folder. If the script did convert all the images in the memories folder into their final versions though, then at least all the downloaded images were successfully transformed.

Let me know if you discover anything or if there's anything else I can help with :) Otherwise I'll close the issue.