mega.py icon indicating copy to clipboard operation
mega.py copied to clipboard

Rename issue

Open maciejbak85 opened this issue 3 years ago • 1 comments

hi,

thanks for this library! I wanted to ask what I am doing wrong, or maybe there is some bug:

files = m.get_files()

for file in files:
    file_details = files[file]
    file_name = str(file_details['a']['n'])
    if (file_name.endswith(".mp4")):
        date_time = time.strftime(
            ' %Y-%m-%d', time.localtime(file_details['ts']))
        new_name = str(file_details['ts']) + "_" + file_name
        print(file_details['k'])
        m.rename(file, new_name)

gives me:

(4095499236, 4227643941, 3790350449, 3961640328)
Traceback (most recent call last):
  File "/home/abc/Dev/xyz/MegaVideosRename/main.py", line 22, in <module>
    m.rename(file, new_name)
  File "/home/abc/Dev/xyz/MegaVideosRename/environments/my_env/lib/python3.8/site-packages/mega/mega.py", line 906, in rename
    encrypt_attribs = base64_url_encode(encrypt_attr(attribs, file['k']))
TypeError: string indices must be integers

any idea why ? looks like under 'k' there are integers..

maciejbak85 avatar Aug 09 '21 13:08 maciejbak85

btw.

files = m.get_files()

for file in files:
    file_details = files[file]
    # print(file_details)
    file_name = str(file_details['a']['n'])
    if (file_name.endswith(".mp4")):
        date_time = time.strftime(
            ' %Y-%m-%d', time.localtime(file_details['ts']))
        new_name = str(file_details['ts']) + "_" + file_name
        found_file = m.find(file_name)
        m.rename(found_file, new_name)

this works fine, I have to find it again, not from the list.

maciejbak85 avatar Aug 10 '21 05:08 maciejbak85