11#flag=imp
22
33'''
4- An Cross-platform opensource Metadata Remover using exiftool and ffmpeg to sanitize your images before posting on internet.
4+ A Cross-platform opensource Metadata Remover using exiftool and ffmpeg to sanitize your images before posting on internet.
55'''
66
7+ import os , time
8+ import metadata_remover .commons as c
9+
710# Function to write given message to file named log in append mode.
811def w (msg ,file = 'log' ):
912 with open (file ,'a+' ) as f :
@@ -12,7 +15,7 @@ def w(msg,file='log'):
1215# Function to read and display metadata of a file.
1316def meta (file ):
1417 os .system ('exiftool ' + file + ' >meta.txt' )
15- display ('meta.txt' )
18+ c . c . display ('meta.txt' )
1619 os .remove ('meta.txt' )
1720
1821# Function to rename exiftool(-k).exe as exiftool.exe in windows.
@@ -30,7 +33,7 @@ def img(x):
3033
3134# Function to remove metadata from video file.
3235def vid (x ):
33- ffmpeg ()
36+ c . ffmpeg ()
3437 count = - 1
3538 for i in x :
3639 count += 1
@@ -40,18 +43,15 @@ def vid(x):
4043 ext = x [count :]
4144 y = file + '_clean' + ext
4245 os .system ('ffmpeg -i ' + x + ' -map_metadata -1 -c:v copy -c:a copy ' + y )
43- if platform .system ().lower ()== 'windows' :
44- os .system ('cls' )
45- else :
46- os .system ('clear' )
46+ c .cls ()
4747 os .system ('exiftool ' + y + '>output.txt' )
48- copy ('output.txt' ,'output_log.txt' )
48+ c . copy ('output.txt' ,'output_log.txt' )
4949
5050# Function to remove metadata from single image or video file. It uses img() and vid() internally.
5151# x denotes file given as input , y can be either i for images or v for videos , mode can be n for normal mode, or b for bulk processing mode.
5252def singly (x ,y ,mode = 'n' ):
5353 autoexif ()
54- exiftool ()
54+ c . exiftool ()
5555 flag = 0
5656
5757 if os .path .exists (x )== False :
@@ -65,19 +65,19 @@ def singly(x,y,mode='n'):
6565 for i in v :
6666 if x .lower ().endswith (i ):
6767 os .system ("exiftool " + x + ">input.txt" )
68- copy ('input.txt' ,'input_log.txt' )
68+ c . copy ('input.txt' ,'input_log.txt' )
6969 img (x )
7070 flag = 1
7171 os .system ("exiftool " + x + ">output.txt" )
72- copy ('output.txt' ,'output_log.txt' )
72+ c . copy ('output.txt' ,'output_log.txt' )
7373
7474 elif y .lower ()== 'v' :
75- ffmpeg ()
75+ c . ffmpeg ()
7676 v = ('.mp4' ,'.mov' ,'.webm' ,'.ogv' ,'.flv' ,'.wmv' ,'.avi' ,'.mkv' ,'.vob' ,'.ogg' ,'.3gp' )
7777 for i in v :
7878 if x .lower ().endswith (i ):
7979 os .system ("exiftool " + x + ">input.txt" )
80- copy ('input.txt' ,'input_log.txt' )
80+ c . copy ('input.txt' ,'input_log.txt' )
8181 vid (x )
8282 flag = 1
8383
@@ -89,15 +89,12 @@ def singly(x,y,mode='n'):
8989
9090 if flag == 0 :
9191 print ("\n Invalid File for processing!" )
92- wait ()
92+ c . wait ()
9393 exit ()
9494
9595 if ((os .path .exists ('input.txt' )== True )and (os .path .exists ('output.txt' )== True )):
9696 if os .path .getsize ('output.txt' )== 0 :
97- if platform .system ().lower ()== 'windows' :
98- os .system ('cls' )
99- else :
100- os .system ('clear' )
97+ c .cls ()
10198 print (' Error Processing File!' )
10299 elif os .path .getsize ('input.txt' )> os .path .getsize ('output.txt' ):
103100 print (x + ': Metadata removed successfully!' )
@@ -113,60 +110,54 @@ def singly(x,y,mode='n'):
113110 os .remove ('output.txt' )
114111
115112 if mode == 'n' :
116- wait ()
113+ c . wait ()
117114 if os .path .exists ('log' ):
118115 os .remove ('log' )
119116
120117# Function to remove metadata of all images from folder.
121118def bulk ():
122- start ()
119+ c . start ()
123120 loc = input (' Enter Folder:' )
124- if platform . system (). lower () == 'windows' :
121+ if c . sys () == 'windows' :
125122 if os .path .exists ('exiftool.exe' ):
126- bcopy ('exiftool.exe' ,loc + '\\ exiftool.exe' )
123+ c . copy ('exiftool.exe' ,loc + '\\ exiftool.exe' )
127124 os .chdir (loc )
128125 for i in os .listdir ():
129126 singly (i ,'i' ,'b' )
130- if platform .system ().lower ()== 'windows' :
131- os .system ('cls' )
132- else :
133- os .system ('clear' )
127+ c .cls ()
134128
135129 print ('\n Output\n ' )
136- display ('log' )
130+ c . display ('log' )
137131 if os .path .exists ('log' ):
138132 os .remove ('log' )
139133 else :
140134 print ('No Image Files Detected!' )
141135 print ('Done' )
142- wait ()
143- end ()
136+ c . wait ()
137+ c . end ()
144138
145139# Function to remove metadata of all videos from folder.
146140def bulk1 ():
147- start ()
141+ c . start ()
148142 loc = input (' Enter Folder:' )
149- if platform . system (). lower () == 'windows' :
143+ if c . sys () == 'windows' :
150144 if os .path .exists ('exiftool.exe' ):
151- bcopy ('exiftool.exe' ,loc + '\\ exiftool.exe' )
145+ c . copy ('exiftool.exe' ,loc + '\\ exiftool.exe' )
152146 if os .path .exists ('ffmpeg.exe' ):
153- bcopy ('ffmpeg.exe' ,loc + '\\ ffmpeg.exe' )
147+ c . copy ('ffmpeg.exe' ,loc + '\\ ffmpeg.exe' )
154148 os .chdir (loc )
155149 for i in os .listdir ():
156150 singly (i ,'v' ,'b' )
157- if platform .system ().lower ()== 'windows' :
158- os .system ('cls' )
159- else :
160- os .system ('clear' )
151+ c .cls ()
161152 print ('\n Output\n ' )
162- display ('log' )
153+ c . display ('log' )
163154 if os .path .exists ('log' ):
164155 os .remove ('log' )
165156 else :
166157 print ('No Video Files Detected!' )
167- wait ()
168- end ()
158+ c . wait ()
159+ c . end ()
169160
170161if __name__ == '__main__' :
171162 print ('\n |----- MRT module stable release version 0.2.4 ----|' )
172- wait ()
163+ c . wait ()
0 commit comments