snobu / destreamer

Save Microsoft Stream videos for offline enjoyment.
MIT License
2.36k stars 440 forks source link

Using a title template for destreamer, calling it from python (in windows) #245

Closed FraH90 closed 3 years ago

FraH90 commented 3 years ago

Hi guys, I'm trying to automate things a little bit, so I can download more subject just clicking on a python script.

This is some piece of the code I've written:

outputFormat = r' -t {publishDate} - {publishTime} - {title} - {author} - {duration} - {uniqueId}'

def destream(groupURL, outputFolder):
    os.system('destreamer -u ' + emLogin + ' -i ' + groupURL + ' -o ' +  outputFolder + outputFormat + '-k --skip -x')

obviously I call destream with the proper parameters. It all works, I'm able to download programmatically a lot of subjects, however the problem is that the title template doesn't work: the file name has only the publishDate, but not all the other parameters.

I know that this is probably a problem with how python does handle strings.. question is: what can I do to make it work as I desire? Specifically, what should look like the outputFormat variable here?

Thanks

PS: I dont know why the python code I've written here isn't stored in a "code" section

PPS: the reason because I want this very specific format title is because with this all the lesson will be ordered in the folder by the time they've been recorded: if in the same day someone record two lessons, in the folder you'll have first the lesson recorded at 11.00 for example, and then the lesson recorderd at 12.00

FraH90 commented 3 years ago

Update:

If I use this syntax for the outputFormat variable, using escape chars

outputFormat = ' -t \'{publishDate} - {publishTime} - {title} - {author} - {duration} - {uniqueId}\' '

to make it look the parameters like you've written in the readme, I get this as output name:

'2020-10-05

Practically it ignores the ' characters as part of the command, and it puts it in the file-title. What I'm getting wrong?

lukaarma commented 3 years ago

outputFormat = ' -t '{publishDate} - {publishTime} - {title} - {author} - {duration} - {uniqueId}' '

try with outputFormat = ' -t "{publishDate} - {publishTime} - {title} - {author} - {duration} - {uniqueId}" '

FraH90 commented 3 years ago

outputFormat = ' -t '{publishDate} - {publishTime} - {title} - {author} - {duration} - {uniqueId}' '

try with outputFormat = ' -t "{publishDate} - {publishTime} - {title} - {author} - {duration} - {uniqueId}" '

YES! Thats exactly what I just did, before reading your comment!

Practically in windows the parameters in brackets must be encolsed between "" otherwise it doesn't take them right!!! Thank you man