Posts: 5
Threads: 2
Joined: Jul 2019
This codes is working on Raspberry, how can I work this codes in Windows?
bashCommand = ['mkvpropedit','{}'.format(dosyatam),'--edit','info','--set','title={}'.format(title)]
process = subprocess.Popen(bashCommand, stdout=subprocess.PIPE)
output, error = process.communicate()
print(output)
Posts: 7,313
Threads: 123
Joined: Sep 2016
You need mkvpropedit.exe for Windows
It's in MKVToolNix
>>> dosyatam = 'movie.mkv'
>>> title = 'somemovie'
>>> bashCommand = ['mkvpropedit','{}'.format(dosyatam),'--edit','info','--set','title={}'.format(title)]
>>> bashCommand
['mkvpropedit', 'movie.mkv', '--edit', 'info', '--set', 'title=somemovie']
>>> ' '.join(bashCommand)
'mkvpropedit movie.mkv --edit info --set title=somemovie' Test first that command work from command line(cmd).
mkvpropedit movie.mkv --edit info --set title=somemovie Test with mkvpropedit.exe and your_sub_code.py in same folder.
Posts: 5
Threads: 2
Joined: Jul 2019
This is my py file:
#!/usr/bin python3
# -*- coding: utf-8 -*-
import os
import subprocess
import re
neredebu='K:\\İnenler\\filmler\\mkvler'
for kokdizin, altdizinler, dosyalar in os.walk(neredebu):
for dosya in dosyalar:
if dosya.endswith('.mkv'):
#dosya = os.sep.join([kokdizin, dosya])
isim=re.findall('([\w\d.]*)\.[\d]{4}\.',dosya)[0]
isim=isim.replace(".", " ")
yil=re.split('[\w\d.]*\.([\d]{4})\.',dosya)[1]
title=isim+" - "+yil+" _ netmanyağı"
dosyayolu=kokdizin
dosyatam=dosyayolu+"\\"+dosya
print(isim)
print(yil)
print(title)
print(dosyayolu)
print(dosyatam)
print(dosya)
bashCommand = ['C:\Program Files\MKVToolNix\mkvpropedit.exe','{}'.format(dosyatam),'--edit','info','--set','title={}'.format(title)]
#bashCommand=['C:\Program Files\MKVToolNix\mkvpropedit.exe',dosya, '--edit', 'info', '--set', 'title='+title]
bc=' '.join(bashCommand)
process = subprocess.Popen(bc, stdout=subprocess.PIPE)
output, error = process.communicate()
print(output) py file and mkv files is same folder(neredebu).
out:
>>> %Run mkvBilgi.py
Acts of Violence
2018
Acts of Violence - 2018 _ netmanyağı
K:\İnenler\filmler\mkvler
K:\İnenler\filmler\mkvler\Acts.of.Violence.2018.m1080p.BluRay.x264-DUAL.TR.ENG.mkv
Acts.of.Violence.2018.m1080p.BluRay.x264-DUAL.TR.ENG.mkv
b"Error: More than one file name has been given ('K:\\\xc4\xb0nenler\\filmler\\mkvler\\Acts.of.Violence.2018.m1080p.BluRay.x264-DUAL.TR.ENG.mkv' and 'of').\r\n"
1
Traceback (most recent call last):
File "K:\İnenler\filmler\mkvBilgi.py", line 49, in <module>
processs = subprocess.Popen(bashCommandd, stdout=subprocess.PIPE)
File "C:\Program Files\Python37-32\lib\subprocess.py", line 775, in __init__
restore_signals, start_new_session)
File "C:\Program Files\Python37-32\lib\subprocess.py", line 1178, in _execute_child
startupinfo)
FileNotFoundError: [WinError 2] The system cannot find the file specified
Posts: 7,313
Threads: 123
Joined: Sep 2016
Jul-06-2019, 09:29 PM
(This post was last modified: Jul-06-2019, 09:29 PM by snippsat.)
Test to see if it work.
import subprocess
moive_to_edit = 'jelly.mkv'
movie_title = 'Swimming jelly fish'
output = subprocess.run(['mkvpropedit', moive_to_edit, '--edit', 'info', '--set', f'title={movie_title}'], capture_output=True)
print(output.stdout.decode()) Output: E:\div_code\bat
λ python ajelly.py
The file is being analyzed.
The changes are written to the file.
Done.
Work,movie have new title Swimming jelly fish
Try to simplify down(also name of movie) as i do here to get to work outside of script,i use cmder so ls work in cmd is dir .
E:\div_code\bat
λ ls
ajelly.py mkvpropedit.exe* jelly.mkv Now you get two errors mkvpropedit command don't work and FileNotFoundError.
Do not use singel \ in path string,other way / or put and r in front.
>>> r'C:\Program Files\MKVToolNix\mkvpropedit.exe'
'C:\\Program Files\\MKVToolNix\\mkvpropedit.exe'
Posts: 5
Threads: 2
Joined: Jul 2019
Jul-07-2019, 06:16 PM
(This post was last modified: Jul-07-2019, 07:02 PM by herace.)
(Jul-06-2019, 09:29 PM)snippsat Wrote: Test to see if it work.
output = subprocess.run(['mkvpropedit', moive_to_edit, '--edit', 'info', '--set', f'title={movie_title}'], capture_output=True)
print(output.stdout.decode())
Thank you, this is work; my codes:
#!/usr/bin python3
# -*- coding: utf-8 -*-
import os
import subprocess
import re
neredebu=r'K:\İnenler\filmler\mkvler'
mkvpeexe=r'C:\Program Files\MKVToolNix\mkvpropedit.exe'
tname="netmanyağı"
for kokdizin, altdizinler, dosyalar in os.walk(neredebu):
for dosya in dosyalar:
if dosya.endswith('.mkv'):
#dosya = os.sep.join([kokdizin, dosya])
isim=re.findall('([\w\d.]*)\.[\d]{4}\.',dosya)[0]
isim=isim.replace(".", " ")
yil=re.split('[\w\d.]*\.([\d]{4})\.',dosya)[1]
title=isim+" - "+yil+" _ netmanyağı"
dosyayolu=kokdizin
dosyatam=dosyayolu+"\\"+dosya
print(isim)
print(yil)
print(title)
print(dosyayolu)
print(dosyatam)
print(dosya)
output = subprocess.run([mkvpeexe, dosyatam, '--edit', 'info', '--set', 'title={}'.format(title)], capture_output=True)
print(output.stdout.decode())
output = subprocess.run([mkvpeexe, dosyatam, '--edit','track:a1','--set','name={}'.format(tname)], capture_output=True)
print(output.stdout.decode())
#!/usr/bin python3 Edit to for Windows:
#!C:\Program Files\Python37-32\python.exe
|