I would like to be able to write some metadata to a video, media file in Windows 10 using python3. Doing some searching online I figured out how to read the metadata with the code below. Nowhere online could I find any information about writing the data. I wonder if this is even possible with Python.
Any help would be appreciated.
from win32com.propsys import propsys, pscon
filename = "Video.mp4"
properties = propsys.SHGetPropertyStoreFromParsingName(filename)
title = properties.GetValue(pscon.PKEY_Title).GetValue()
print (title)
Related
I am trying to upload documents to a Alfresco CMIS site using Python code
from cmislib.model import CmisClient
file_to_upload = open(file_full_path, 'r')
doc_in_Alfresco = archive_folder_2.createDocument(file_name, \
contentFile=file_to_upload)
Have taken the example from this help document - https://chemistry.apache.org/python/docs/examples.html
i have .txt, .rtf, . pdf, .docx documents etc.
Except for txt documents, rest of the upload is failing and the common error is
LookupError: 'base64' is not a text encoding; use codecs.encode() to handle arbitrary codecs
The error will differ in codec name depending on the file extension.
With limited documentation help, can someone hint what can be the possible solution. I am using cmislib in Python 3 in MacOS and the code in run in Jupyter Notebook.
Any hints will be highly appreciated.
Thanks
It worked for me with the following changes in place
file_to_upload.read()
file_data = base64.b64encode(content_file.read())
doc_in_Alfresco = archive_folder_2.createDocument(file_name, \
contentFile=file_to_upload)
I have been searching the web for hours trying to find something that might help me convert a file that was saved in the ppt file type to the pptx file type using python. I found "python-pptx" and was planning on using it to save the files, however this was not possible due to the continuous error:
Package not found at 'FileName.ppt'
I discovered another post (Convert ppt file to pptx in Python) which did not help me at all. I assume it is because my python version might be too high. (3.9) After reading up on getting the win32com.client to work and installing multiple pip and pip3 commands, it is still not working. If anyone could assist me with this manner I would be very thankful. My Current Code:
from pptx import *
prs = Presentation("FileName.ppt")
prs.save("FileName.pptx")
You can use Aspose.Slides for .NET and Python.NET package for converting PPT to PPTX as shown below:
import clr
clr.AddReference('Aspose.Slides')
from Aspose.Slides import Presentation
from Aspose.Slides.Export import SaveFormat
# Instantiate a Presentation object that represents a PPT file
presentation = Presentation("presentation.ppt")
# Save the presentation as PPTX
presentation.Save("presentation.pptx", SaveFormat.Pptx)
Our web applications use our libraries and you can see conversion results here.
I work at Aspose.
I doubt python-pptx can parse a .ppt file. (It's a completely different file format.) You're better off automating PowerPoint itself - somehow - to read one and write the other.
The "somehow" depends on the platform you're running on - and the automation capabilities available to you.
Hope you'll are doing good. I am new to python. I am trying to use audio.scikits library in python3 verion. I have a working code version in 2.7(with audio.scikits) . While I am running with python3 version I am getting the Import Error: No Module Named 'Version' error. I get to know that python3 is not anymore supporting audio.scikits(If I am not wrong). Can anyone suggest me replacing library for audio.scikits where I can use all the functionalities like audio.scikits do OR any other solution which might helps me. Thanks in advance.
2.7 Version Code :
from scikits.audiolab import Format, Sndfile
from scipy.signal import firwin, lfilter
array = np.array(all)
fmt = Format('flac', 'pcm16')
nchannels = 1
cd, FileNameTmp = mkstemp('TmpSpeechFile.wav')
# making the file .flac
afile = Sndfile(FileNameTmp, 'w', fmt, nchannels, RawRate)
#writing in the file
afile.write_frames(array)
SendSpeech(FileNameTmp)
To check entire code please visit :Google Asterisk Reference Code(modifying based on this code)
I want to modify this code with python3 supported libraries. Here I am doing this for Asterisk-Microsoft-Speech To Text SDK.
Firstly the link code you paste is Asterisk-Google-Speech-Recognition, it's not the Microsoft-Speech-To-Text, if you want get a sample about Microsoft-Speech-To-Text you could refer to the official doc:Recognize speech from an audio file.
And about your problem you said, yes it's not completely compatible, in the github issue there is a solution for it, you could refer to this comment.
I'm trying to read the exif data from a .JPG image. I've tried differents solutions found here and there (PIL, piexif, exifread...) and none of them worked for this set of images. It worked for other images taken from another camera but not for this one, all these different methods returning empty dictionaries. It seems that there is no exif data but (I apologies for my newbyness) when I RIGHT-click + properties (I use windows), I do see what is exif data to me : date of creation, etc...
Here is one image :
image.JPG
If another of the thousands of anonymous heroes could help me on this one, I would be very grateful...
Alright so I found a solution which I share now.
The problem is that the libraries that open metadata are not taking all possible configurations for the image file and therefore, they can handle some and some others they cannot. I finally made it using exiftool, an executable that I dowloaded on my windows on this link :
https://sno.phy.queensu.ca/~phil/exiftool/
Then I paste the executable in a folder and I add exiftool.py in that folder, that I got from :
https://github.com/smarnach/pyexiftool/find/master
Then, using this small piece of code (for example):
import exiftool
with exiftool.ExifTool("exiftool.exe") as et:
metadata = et.get_metadata_batch(files)
for d in metadata:
print("{:20.20} {:20.20}".format(d["SourceFile"],
d["File:FileCreateDate"]))
Of course, this is just to show that you indeed can access the metadata, then you can do whatever you want with that. Here is the documentation of the library exiftool : http://smarnach.github.io/pyexiftool/
Cheers, JM
I'm trying to download an excel file which is uploaded on a Sharepoint 2013 site.
My code is as follows:
import requests
url='https://<sharepoint_site>/<document_name>.xlsx?Web=0'
author = HttpNtlmAuth('<username>','<passsword>')
response=requests.get(url,auth=author,verify=False)
print(response.status_code)
print(response.content)
This gives me a long output which is something like:
x00docProps/core.xmlPK\x01\x02-\x00\x14\x00\x06\x00\x08\x00\x00\x00!\x00\x7f\x8bC\xc3\xc1\x00\x00\x00"\x01\x00\x00\x13\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xb8\xb9\x01\x00customXml/item1.xmlPK\x05\x06\x00\x00\x00\x00\x1a\x00\x1a\x00\x12\x07\x00\x00\xd2\xba\x01\x00\x00\x00'
I did something like this before for another site and I got xml as output which was acceptable for me but I'm not sure how to handle this data.
Any ideas to process this to be like xlsx or xml?
Or maybe to download the xlsx another way?(I tried doing it through the wget library and the excel seems to get corrupted)
Any ideas would be really helpful.
Regards,
Karan
Its too late but i got similar issue... thought it might help someone else.
try writing the output to a file or apply some encoding while printing.
writing to a file:
file=open("./temp.xls", 'wb')
file.write(response.content)
file.close()
or
file=open("./temp.xls", 'wb')
file.write(response.text)
file.close()
printing with encoding
print ( resp.text.encode("utf-8") )
or
print ( resp.content.encode("utf-8") )
!Make appropriate imports.
!try 'w' or 'wb' for file write.
Hope this helps.
It seems that the file is encrypted and request can't handle this.
Maybe the web service provides an API for downloading and secure decoding.