subzeroid / instagrapi

🔥 The fastest and powerful Python library for Instagram Private API 2024
https://hikerapi.com/p/bkXQlaVe
MIT License
4.38k stars 686 forks source link

[BUG] After Uploading Reels ,Unable to Move Or Delete the File #541

Closed adityaa-codes closed 2 years ago

adityaa-codes commented 2 years ago

After Uploading Reels, I'm Unable to Move/Delete the file, using the program or manually using the explorer this happens while the program is running , after the program is closed its seems to work, but sometimes i've to kill ffmpeg from task manager.

Error: Media:Reels Upload Failed With Error [WinError 32] The process cannot access the file because it is being used by another process: 'F:\Personal\Projects\InstagramCore\Content\Schedule\Wednesday\Reels\one.mp4' PS: Same Error While Moviing/Deleting From Explorer

Move File Code: shutil.move(src, dest)

Upload Code: login_instance = Client() login_instance.load_settings(Path('device_settings/' + PAGE_USERNAME + '.json')) login_instance.set_locale(LOCALE) login_instance.set_timezone_offset(TIMEZONE_OFFSET) login_instance.set_country(COUNTRY) login_instance.set_country_code(COUNTRY_CODE) login_instance.set_user_agent(USER_AGENT) login_instance.set_uuids(UUIDS) login_instance.set_device(DEVICE_SETTINGS) login_instance.login(PAGE_USERNAME, PAGE_PASSWORD) login_instance.inject_sessionid_to_public() media = login_instance.clip_upload(path=Path(PATH), caption=caption, thumbnail=None)

adw0rd commented 2 years ago

@adityaa-codes cannot reproduce:

In [5]: path = cl.clip_download(2732565620957896942)

In [6]: path
Out[6]: PosixPath('/home/adw0rd/instagrapi/adw0rd__2732565620957896942.mp4')

In [7]: path.exists()
Out[7]: True

In [8]: m = cl.clip_upload(path, "TEST")
Analizing CLIP file "/home/adw0rd/instagrapi/adw0rd__2732565620957896942.mp4"
Generating thumbnail "/home/adw0rd/instagrapi/adw0rd__2732565620957896942.mp4.jpg"...

In [9]: m.pk
Out[9]: '2761523359117974336'

In [10]: import shutil

In [11]: shutil.move(path, "/tmp/new.mp4")
Out[11]: '/tmp/new.mp4'

In [12]: path.exists()
Out[12]: False
adityaa-codes commented 2 years ago

Its happening in windows while program is still running

adw0rd commented 2 years ago

@adityaa-codes I haven't windows, can you fix it yourself?

adityaa-codes commented 2 years ago

Will Def try, in the near future, thank you

BlackPhoenix134 commented 1 year ago

Any updates on this? We have the same issue We got around it by starting reel upload in a subprocess, which removes the lock on the src files. result = subprocess.run([sys.executable, './uploadReelIg.py', ...)

BlackPhoenix134 commented 1 year ago

@adw0rd checking if https://github.com/adw0rd/instagrapi/commit/32e65c6047be1ed13ea7c3c58ed400b5e7a12c09 fixed it

BlackPhoenix134 commented 1 year ago

Can confirm, that commit fixed it