how to read a quicktime header with python - python

I want to get the original creation date of quicktime videos created on my Canon 60d for use in a python script I've written to help me sort my movies. How can I get at the information stored in quicktime headers with python?
If there's nothing existing in vanilla python to help me, I thought I might give this a whirl.

videoParser works well. I remember trying it out. If for any reason that does not satisfy your needs, try this http://pypi.python.org/pypi/hachoir-metadata/1.2.1

Related

Using Tenor API in Python for printing gifs

So, I am trying to print out gifs by using Tenor API.
I want it to only print one gif link but it prints out everything any Idea how to fix this?
Thank you.
https://i.stack.imgur.com/xf084.png
Sadly, I can not tell you the exact problem you are having, I replicated your code and used the official API Docs here
From what I can tell, this is one GIF just in a lot of different formats.
You can filter them like so:
print(top_8gifs['weburl'])
or
print(top_8gifs['results'][0])
EDIT: Looking at your .png (please embed it as code in the future) this should work for you, if you want the url:
print(top_8gifs[0]['url'])
A Python dict you can select using the key (like gifs['weburl'])
A Python list you have to select by index so gifs[0]
Using these techniques you can gather the data you need from that output.

How to get changing information from a webpage in Python

I am new with Python and am trying to create a program that will read in changing information from a webpage. I'm not sure if what I'm wanting to do is something simple or possible but in my head it seems do-able and relatively. Specifically I am interested in pulling in the song names from Pandora as they change. I have tried looking into just reading in information from a webpage using something like
import urllib
import re
page = urllib.urlopen("http://google.com").read()
re.findall("Shopping", page)
['Shopping']
page.find("Shopping")
However this isn't really what I'm wanting due to it getting information that doesn't change. Any advice or a link to helpful information about reading in changing info from a webpage would be greatly appreciated.
The only way this is possible (without some type of advanced algorithm) is if there are some elements of the page that do NOT change, which you can specify your program to look for. Otherwise, I believe you will need some sort of advanced logic. After all, computers can only do what we instruct them to do. Sorry :)

QGIS layer: import CSV and set 'Display HTML Map Tip' using python

My objective is to generate a python plug-in for QGIS that will open a CSV and define a field within the table to display as a map tip.
I'm trying to achieve this task and have got stuck on trying to set the layer properties using python, rather than opening the 'layer properties' dialog, selecting the Display tab and entering HTML expression...
the HTML expression I'm trying to insert into the layer properties is:
field1= '<b>\"title\"</b><br/>\n'+'[%CONCAT(\'<img src=\"\',\"file\",\'\" width=\"400\"></img>\')%]'
where "title" and "file" are fields within the CSV, giving rise to:
<b>"title"</b><br/>
[%CONCAT('<img src="',"file",'" width="400"></img>')%]
This gives me the right HTML to slot into a relevant place - and it works when I use this manually, but I'm now lost trying to find how to change the layer properties using python...
There seems to be a function called
setDisplayAttributes but I can't really follow the API description well enough to understand whether it is the correct function and I can't find any examples using this function.
Any help would be appreciated - I'm a toddler with Python but probably pre-pubescent with QGIS (Version 2.8 on Windows 10) so if you are able to work in words of less than 47 syllables that would be grand.
Many thanks in advance.
EDIT: I've realised this might not be the right place for this
question so have posted on GIS.stackexchange. My apologies and I will
update whichever one gets answered so that folk can find it. If you
choose to vote this down for my stupidity, so be it.
You can find the other version here:
https://gis.stackexchange.com/questions/169997/qgis-layer-import-csv-and-set-display-html-map-tip-using-python

Charts from Excel to PowerPoint with Python

I have an excel workbook that is created using an excellent "xlsxwriter" module. In this workbook, there about about 200 embedded charts. I am now trying to export all those charts into several power point presentations. Ideally, I want to preserve the original format and embedded data without linking to external excel work book.
I am sure there is a way to do this using VBA. But, I was wondering if there is a way to do this using Python. Is there a way to put xlsxwriter chart objects into powerpoints ?
I have looked at python-pptx and can't find anything about getting charts or data series from excel work book.
Any help is appreciated !
After spending hours of trying different things, I have found the solution to this problem. Hopefully,it will help someone save some time.The following code will copy all the charts from "workbook_with_charts.xlsx" to "Final_PowerPoint.pptx."
For some reason, that I am yet to understand, it works better when running this Python program from CMD terminal. It sometimes breaks down if you tried to run this several times, even though the first run is usually OK.
Another issue is that in the fifth line, if you make False using "presentation=PowerPoint.Presentations.Add(False)," it does not work with Microsoft Office 2013, even though both "True" and "False" will still work with Microsoft Office 2010.
It would be great if someone can clarify these about two issues.
# importing the necessary libraries
import win32com.client
from win32com.client import constants
PowerPoint=win32com.client.Dispatch("PowerPoint.Application")
Excel=win32com.client.Dispatch("Excel.Application")
presentation=PowerPoint.Presentations.Add(True)
workbook=Excel.Workbooks.Open(Filename="C:\\.........\\workbook_with_charts.xlsx",ReadOnly=1,UpdateLinks=False)
for ws in workbook.Worksheets:
for chart in ws.ChartObjects():
# Copying all the charts from excel
chart.Activate()
chart.Copy()
Slide=presentation.Slides.Add(presentation.Slides.Count+1,constants.ppLayoutBlank)
Slide.Shapes.PasteSpecial(constants.ppPasteShape)
# WE are going to make the title of slide the same chart title
# This is optional
textbox=Slide.Shapes.AddTextbox(1,100,100,200,300)
textbox.TextFrame.TextRange.Text=str(chart.Chart.ChartTitle.Text)
presentation.SaveAs("C:\\...........\\Final_PowerPoint.pptx")
presentation.Close()
workbook.Close()
print 'Charts Finished Copying to Powerpoint Presentation'
Excel.Quit()
PowerPoint.Quit()
The approach I'd be inclined toward with the current python-pptx version is to read the Excel sheets for their data and recreate the charts in python-pptx. That of course would require knowing what the chart formatting is, etc., so I could see why you might not want to do that.
Importing charts directly from Excel has been done in the past, see the pull request here on GitHub: https://github.com/scanny/python-pptx/pull/65
But it involved a large amount of surgery on python-pptx, and many versions back now, so at most it might be a good guide to what strategies might work. You'd need to want it pretty bad I suppose to go that route :)
I don't have enough reputation to comment but if you get the same issue as #R__raki__ then you can use the integer value defined by the VBA reference. For this case it would be 12.
So replace
Slide=presentation.Slides.Add(presentation.Slides.Count+1,constants.ppLayoutBlank)
with
Slide=presentation.Slides.Add(presentation.Slides.Count+1,12)
See here for more.

how do I use the facebook api to modify a video title or description?

How can I update the title/description of a previously updated video? I am using python and pyfacebook... but any starting point would be fine and I can write it in python.
I don't think it's possible to edit a Video object at all with the Graph API at the moment. You can't create objects through the API, therefore I don't think you can edit or modify existing ones either.

Categories

Resources