from cgitb import handler
from distutils.filelist import findall
from unicodedata import name
from xml.etree.ElementPath import findtext
from bs4 import BeautifulSoup
import pandas as pd
import requests
import os
import time
import csv
import re

def fun1():
appcsv = pd.read_csv('/Users/jitendersingh/Documents/appcsv.csv', squeeze=True,usecols=["Link", "Name"])
newappcsv = appcsv.reset_index() # add index in new file / try to run this code when upload new file
mytitle = appcsv.loc[0, 'Link']
thumbname = appcsv.loc[0, 'Link'].replace(" ", "\n")

mykeyword = mytitle.capitalize()
url = ('https://play.google.com/store/search?q='+ mykeyword +'+apps+for+android&c=apps')
source = requests.get (url)

soup = BeautifulSoup(source.text,'html.parser')
single = soup.find('div', class_="fUEl2e")

data = {

'Question' : [""],
'A' : [""],
'Logo' : [""],
}
df = pd . DataFrame ( data )
df . to_csv ( '/Users/jitendersingh/Documents/test.csv' , mode = 'a' , index = False , header = True )
print ( "sheet created successfully." )

sheet = pd.read_csv( '/Users/jitendersingh/Documents/test.csv' , squeeze = True , usecols =[ "Question" , "A", "Logo"])

delete = sheet.drop(sheet.index [ [ 0 ]], axis = 0 , inplace = True ) #delete first row
save = sheet.to_csv( '/Users/jitendersingh/Documents/test2.csv' ) #save file but index also deletes
os.remove ('/Users/jitendersingh/Documents/test.csv')
link2 = pd.read_csv( '/Users/jitendersingh/Documents/test2.csv' , squeeze = True , usecols =[ "Question" , "A", "Logo"]) #again open file for correct index
save = link2.to_csv( '/Users/jitendersingh/Documents/test.csv' ) #save file with correct index
os.remove ( '/Users/jitendersingh/Documents/test2.csv' )
print ( sheet )


for singles in single:
mylist = singles.find('a', class_="Si6A0c Gy4nib")['href']
myappname = singles.find('div', class_="ubGTjb").text
myapplogo = singles.find('img', class_="T75of stzEZd")["src"]

data = {

'Question' : ["jiten"+ myappname + " :- " ],
'A' : ["https://play.google.com" + mylist + ""],
'Logo' : [myapplogo],
}

df = pd . DataFrame ( data )
df . to_csv ( '/Users/jitendersingh/Documents/test.csv' , mode = 'a' , index = True , header = False )
print ( "Data appended successfully." )


link = pd.read_csv('/Users/jitendersingh/Documents/test.csv', nrows=10, squeeze=True,usecols=["Question" , "A", "Logo"])
save = link.to_csv( '/Users/jitendersingh/Documents/test.csv' ) #save file with correct index
dlink = pd.read_csv('/Users/jitendersingh/Documents/test.csv', nrows=10, squeeze=True,usecols=["Question" , "A",])
save2 = dlink.to_csv( '/Users/jitendersingh/Documents/'+mytitle+'.csv', index = False , header = False ) #save file with correct index

#Article-----------------------------------------

textfile = open("/Users/jitendersingh/Documents/"+mytitle+" article.txt", "w")
L = ["Hey guys, Today in this article, I am going to share the list of "+mytitle+". There are too many apps available in the play store like"]
textfile.writelines(L)
textfile.close()

link = pd.read_csv('/Users/jitendersingh/Documents/test.csv', nrows=10, squeeze=True,usecols=["Question" , "A", "Logo"])
appname1 = link.loc[0, 'Question'].replace(" :- ", ",").replace("jiten", " ")
textfile = open("/Users/jitendersingh/Documents/"+mytitle+" article.txt", "a")
textfile.write(appname1)
textfile.close()

appname2 = link.loc[1, 'Question'].replace(" :- ", ",").replace("jiten", " ")
textfile = open("/Users/jitendersingh/Documents/"+mytitle+" article.txt", "a")
textfile.write(appname2)
textfile.close()

appname3 = link.loc[2, 'Question'].replace(" :- ", ",").replace("jiten", " ")
textfile = open("/Users/jitendersingh/Documents/"+mytitle+" article.txt", "a")
textfile.write(appname3)
textfile.close()

appname4 = link.loc[3, 'Question'].replace(" :- ", ",").replace("jiten", " ")
textfile = open("/Users/jitendersingh/Documents/"+mytitle+" article.txt", "a")
textfile.write(appname4)
textfile.close()

appname5 = link.loc[4, 'Question'].replace(" :- ", ",").replace("jiten", " ")
textfile = open("/Users/jitendersingh/Documents/"+mytitle+" article.txt", "a")
textfile.write(appname5)
textfile.close()

appname6 = link.loc[5, 'Question'].replace(" :- ", ",").replace("jiten", " ")
textfile = open("/Users/jitendersingh/Documents/"+mytitle+" article.txt", "a")
textfile.write(appname6)
textfile.close()

appname7 = link.loc[6, 'Question'].replace(" :- ", ",").replace("jiten", " ")
textfile = open("/Users/jitendersingh/Documents/"+mytitle+" article.txt", "a")
textfile.write(appname7)
textfile.close()

appname8 = link.loc[7, 'Question'].replace(" :- ", ",").replace("jiten", " ")
textfile = open("/Users/jitendersingh/Documents/"+mytitle+" article.txt", "a")
textfile.write(appname8)
textfile.close()

appname9 = link.loc[8, 'Question'].replace(" :- ", ",").replace("jiten", " ")
textfile = open("/Users/jitendersingh/Documents/"+mytitle+" article.txt", "a")
textfile.write(appname9)
textfile.close()

appname10 = link.loc[9, 'Question'].replace(" :- ", ",").replace("jiten", " ")
textfile = open("/Users/jitendersingh/Documents/"+mytitle+" article.txt", "a")
textfile.write(appname10)
textfile.close()

textfile = open("/Users/jitendersingh/Documents/"+mytitle+" article.txt", "a")
L = [" etc. Below is the "+mytitle+".\n<h2>"+mytitle+"</h2>\n"]
textfile.writelines(L)
textfile.close()

#Article------------------Links--------------

id1 = link.loc[0, 'A'].replace("https://play.google.com/store/apps/details?id=", "[appbox googleplay ")
Articlelist1 = ("\n<h3>1. "+appname1.replace(",", "")+"</h3>\n"+id1+" screenshots]")
textfile = open("/Users/jitendersingh/Documents/"+mytitle+" article.txt", "a")
textfile.write(Articlelist1)
textfile.close()

id2 = link.loc[1, 'A'].replace("https://play.google.com/store/apps/details?id=", "[appbox googleplay ")
Articlelist2 = ("\n<h3>2. "+appname2.replace(",", "")+"</h3>\n"+id2+" screenshots]")
textfile = open("/Users/jitendersingh/Documents/"+mytitle+" article.txt", "a")
textfile.write(Articlelist2)
textfile.close()

id3 = link.loc[2, 'A'].replace("https://play.google.com/store/apps/details?id=", "[appbox googleplay ")
Articlelist3 = ("\n<h3>3. "+appname3.replace(",", "")+"</h3>\n"+id3+" screenshots]")
textfile = open("/Users/jitendersingh/Documents/"+mytitle+" article.txt", "a")
textfile.write(Articlelist3)
textfile.close()


id4 = link.loc[3, 'A'].replace("https://play.google.com/store/apps/details?id=", "[appbox googleplay ")
Articlelist4 = ("\n<h3>4. "+appname4.replace(",", "")+"</h3>\n"+id4+" screenshots]")
textfile = open("/Users/jitendersingh/Documents/"+mytitle+" article.txt", "a")
textfile.write(Articlelist4)
textfile.close()


id5 = link.loc[4, 'A'].replace("https://play.google.com/store/apps/details?id=", "[appbox googleplay ")
Articlelist5 = ("\n<h3>5. "+appname5.replace(",", "")+"</h3>\n"+id5+" screenshots]")
textfile = open("/Users/jitendersingh/Documents/"+mytitle+" article.txt", "a")
textfile.write(Articlelist5)
textfile.close()


id6 = link.loc[5, 'A'].replace("https://play.google.com/store/apps/details?id=", "[appbox googleplay ")
Articlelist6 = ("\n<h3>6. "+appname6.replace(",", "")+"</h3>\n"+id6+" screenshots]")
textfile = open("/Users/jitendersingh/Documents/"+mytitle+" article.txt", "a")
textfile.write(Articlelist6)
textfile.close()


id7 = link.loc[6, 'A'].replace("https://play.google.com/store/apps/details?id=", "[appbox googleplay ")
Articlelist7 = ("\n<h3>7. "+appname7.replace(",", "")+"</h3>\n"+id7+" screenshots]")
textfile = open("/Users/jitendersingh/Documents/"+mytitle+" article.txt", "a")
textfile.write(Articlelist7)
textfile.close()


id8 = link.loc[7, 'A'].replace("https://play.google.com/store/apps/details?id=", "[appbox googleplay ")
Articlelist8 = ("\n<h3>8. "+appname8.replace(",", "")+"</h3>\n"+id8+" screenshots]")
textfile = open("/Users/jitendersingh/Documents/"+mytitle+" article.txt", "a")
textfile.write(Articlelist8)
textfile.close()


id9 = link.loc[8, 'A'].replace("https://play.google.com/store/apps/details?id=", "[appbox googleplay ")
Articlelist9 = ("\n<h3>9. "+appname9.replace(",", "")+"</h3>\n"+id9+" screenshots]")
textfile = open("/Users/jitendersingh/Documents/"+mytitle+" article.txt", "a")
textfile.write(Articlelist9)
textfile.close()


id10 = link.loc[9, 'A'].replace("https://play.google.com/store/apps/details?id=", "[appbox googleplay ")
Articlelist10 = ("\n<h3>10. "+appname10.replace(",", "")+"</h3>\n"+id10+" screenshots]")
textfile = open("/Users/jitendersingh/Documents/"+mytitle+" article.txt", "a")
textfile.write(Articlelist10)
textfile.close()

#Article end------------------------------------------------


#--------------------CSV to text------------------------------
csv_file = '/Users/jitendersingh/Documents/'+mytitle+'.csv'
txt_file = '/Users/jitendersingh/Documents/'+mytitle+'.txt'
with open(txt_file, "w") as my_output_file:
with open(csv_file, "r") as my_input_file:
[ my_output_file.write(" ".join(row)+'\n') for row in csv.reader(my_input_file)]
my_output_file.close()

#--------------------CSV to text end--------------------------

#--------------------txt file replacing--------------------------


with open(r'/Users/jitendersingh/Documents/'+mytitle+'.txt', 'r') as file:
data = file.read()
data = data.replace("jiten", "\n\n")
with open(r'/Users/jitendersingh/Documents/'+mytitle+'.txt', 'w') as file:
file.write(data)
file.flush()
file.close
print("Text replaced")
#--------------------txt file replacing end--------------------------


# #---------------------------------------Thumbnail------------------------------
homelogo1 = link.loc[0, 'Logo'].replace("s64", "s150")
homelogo2 = link.loc[1, 'Logo'].replace("s64", "s150")
homelogo3 = link.loc[2, 'Logo'].replace("s64", "s150")
homelogo4 = link.loc[3, 'Logo'].replace("s64", "s150")
homelogo5 = link.loc[4, 'Logo'].replace("s64", "s150")
homelogo6 = link.loc[5, 'Logo'].replace("s64", "s150")
homelogo7 = link.loc[6, 'Logo'].replace("s64", "s150")
homelogo8 = link.loc[7, 'Logo'].replace("s64", "s150")
homelogo9 = link.loc[8, 'Logo'].replace("s64", "s150")
homelogo10 = link.loc[9, 'Logo'].replace("s64", "s150")

mainlogo1 = requests.get(homelogo1).content
with open('/Users/jitendersingh/Documents/logo1.webp', 'wb') as handler:
handler.write(mainlogo1)
os.system("ffmpeg -i /Users/jitendersingh/Documents/logo1.webp /Users/jitendersingh/Documents/logo1.png")
os.remove('/Users/jitendersingh/Documents/logo1.webp')

mainlogo2 = requests.get(homelogo2).content
with open('/Users/jitendersingh/Documents/logo2.webp', 'wb') as handler:
handler.write(mainlogo2)
os.system("ffmpeg -i /Users/jitendersingh/Documents/logo2.webp /Users/jitendersingh/Documents/logo2.png")
os.remove('/Users/jitendersingh/Documents/logo2.webp')

mainlogo3 = requests.get(homelogo3).content
with open('/Users/jitendersingh/Documents/logo3.webp', 'wb') as handler:
handler.write(mainlogo3)
os.system("ffmpeg -i /Users/jitendersingh/Documents/logo3.webp /Users/jitendersingh/Documents/logo3.png")
os.remove('/Users/jitendersingh/Documents/logo3.webp')

mainlogo4 = requests.get(homelogo4).content
with open('/Users/jitendersingh/Documents/logo4.webp', 'wb') as handler:
handler.write(mainlogo4)
os.system("ffmpeg -i /Users/jitendersingh/Documents/logo4.webp /Users/jitendersingh/Documents/logo4.png")
os.remove('/Users/jitendersingh/Documents/logo4.webp')

mainlogo5 = requests.get(homelogo5).content
with open('/Users/jitendersingh/Documents/logo5.webp', 'wb') as handler:
handler.write(mainlogo5)
os.system("ffmpeg -i /Users/jitendersingh/Documents/logo5.webp /Users/jitendersingh/Documents/logo5.png")
os.remove('/Users/jitendersingh/Documents/logo5.webp')

mainlogo6 = requests.get(homelogo6).content
with open('/Users/jitendersingh/Documents/logo6.webp', 'wb') as handler:
handler.write(mainlogo6)
os.system("ffmpeg -i /Users/jitendersingh/Documents/logo6.webp /Users/jitendersingh/Documents/logo6.png")
os.remove('/Users/jitendersingh/Documents/logo6.webp')

mainlogo7 = requests.get(homelogo7).content
with open('/Users/jitendersingh/Documents/logo7.webp', 'wb') as handler:
handler.write(mainlogo7)
os.system("ffmpeg -i /Users/jitendersingh/Documents/logo7.webp /Users/jitendersingh/Documents/logo7.png")
os.remove('/Users/jitendersingh/Documents/logo7.webp')

mainlogo8 = requests.get(homelogo8).content
with open('/Users/jitendersingh/Documents/logo8.webp', 'wb') as handler:
handler.write(mainlogo8)
os.system("ffmpeg -i /Users/jitendersingh/Documents/logo8.webp /Users/jitendersingh/Documents/logo8.png")
os.remove('/Users/jitendersingh/Documents/logo8.webp')

mainlogo9 = requests.get(homelogo9).content
with open('/Users/jitendersingh/Documents/logo9.webp', 'wb') as handler:
handler.write(mainlogo9)
os.system("ffmpeg -i /Users/jitendersingh/Documents/logo9.webp /Users/jitendersingh/Documents/logo9.png")
os.remove('/Users/jitendersingh/Documents/logo9.webp')

mainlogo10 = requests.get(homelogo10).content
with open('/Users/jitendersingh/Documents/logo10.webp', 'wb') as handler:
handler.write(mainlogo10)
if len(mytitle) >=11:
#agar text leanth km hai jo number likha hai usse to niche wali command chlayega... jyada hai to uper wali
thumbfont = "90"
else:
thumbfont = "110"

def splitTextonWords(Text, numberOfWords=1):
if (numberOfWords > 1):
text = Text.lstrip()
pattern = '(?:\S+\s*){1,'+str(numberOfWords-1)+'}\S+(?!=\s*)'
x =re.findall(pattern,text)
elif (numberOfWords == 1):
x = Text.split()
else:
x = None
return x

myword = mytitle

thumbfile =open("/Users/jitendersingh/Documents/thumbtext.txt", "w")
thumbfile.write(str(splitTextonWords(myword, 11)))
thumbfile.flush()
thumbfile.close

search_text = "', '"
replace_text = "\n"
with open(r'/Users/jitendersingh/Documents/thumbtext.txt', 'r') as thumbfile:
thumbdata = thumbfile.read()
thumbdata = thumbdata.replace(search_text, replace_text)

with open(r'/Users/jitendersingh/Documents/thumbtext.txt', 'w') as thumbfile:
thumbfile.write(thumbdata)
thumbfile.flush()
thumbfile.close
#---------------------------------
search_text = "['"
replace_text = ""
with open(r'/Users/jitendersingh/Documents/thumbtext.txt', 'r') as thumbfile:
thumbdata = thumbfile.read()
thumbdata = thumbdata.replace(search_text, replace_text)

with open(r'/Users/jitendersingh/Documents/thumbtext.txt', 'w') as thumbfile:
thumbfile.write(thumbdata)
thumbfile.flush()
thumbfile.close
#---------------------------------------
search_text = "']"
replace_text = ""
with open(r'/Users/jitendersingh/Documents/thumbtext.txt', 'r') as thumbfile:
thumbdata = thumbfile.read()
thumbdata = thumbdata.replace(search_text, replace_text)

with open(r'/Users/jitendersingh/Documents/thumbtext.txt', 'w') as thumbfile:
thumbfile.write(thumbdata)
thumbfile.flush()
thumbfile.close
#------------------------------------------

os.system("ffmpeg -i /Users/jitendersingh/Documents/logo10.webp /Users/jitendersingh/Documents/logo10.png")
os.remove('/Users/jitendersingh/Documents/logo10.webp')

os.system("ffmpeg -y -i /Users/jitendersingh/Documents/thumb-bg.png -i /Users/jitendersingh/Documents/logo1.png -filter_complex \"[1:v]scale=130:-1[top]; [0:v][top]overlay=100:100\" /Users/jitendersingh/Documents/appthumb1.jpg")

os.system("ffmpeg -y -i /Users/jitendersingh/Documents/appthumb1.jpg -i /Users/jitendersingh/Documents/logo2.png -filter_complex \"[1:v]scale=130:-1[top]; [0:v][top]overlay=300:100\" /Users/jitendersingh/Documents/appthumb2.jpg")
os.system("ffmpeg -y -i /Users/jitendersingh/Documents/appthumb2.jpg -i /Users/jitendersingh/Documents/logo3.png -filter_complex \"[1:v]scale=130:-1[top]; [0:v][top]overlay=300:250\" /Users/jitendersingh/Documents/appthumb3.jpg")
os.system("ffmpeg -y -i /Users/jitendersingh/Documents/appthumb3.jpg -i /Users/jitendersingh/Documents/logo4.png -filter_complex \"[1:v]scale=130:-1[top]; [0:v][top]overlay=300:400\" /Users/jitendersingh/Documents/appthumb4.jpg")
os.system("ffmpeg -y -i /Users/jitendersingh/Documents/appthumb4.jpg -i /Users/jitendersingh/Documents/logo5.png -filter_complex \"[1:v]scale=130:-1[top]; [0:v][top]overlay=300:550\" /Users/jitendersingh/Documents/appthumb5.jpg")

os.system("ffmpeg -y -i /Users/jitendersingh/Documents/appthumb5.jpg -i /Users/jitendersingh/Documents/logo6.png -filter_complex \"[1:v]scale=130:-1[top]; [0:v][top]overlay=100:250\" /Users/jitendersingh/Documents/appthumb6.jpg")
os.system("ffmpeg -y -i /Users/jitendersingh/Documents/appthumb6.jpg -i /Users/jitendersingh/Documents/logo7.png -filter_complex \"[1:v]scale=130:-1[top]; [0:v][top]overlay=100:400\" /Users/jitendersingh/Documents/appthumb7.jpg")

os.system("ffmpeg -y -i /Users/jitendersingh/Documents/appthumb7.jpg -i /Users/jitendersingh/Documents/logo8.png -filter_complex \"[1:v]scale=130:-1[top]; [0:v][top]overlay=500:100\" /Users/jitendersingh/Documents/appthumb8.jpg")
os.system("ffmpeg -y -i /Users/jitendersingh/Documents/appthumb8.jpg -i /Users/jitendersingh/Documents/logo9.png -filter_complex \"[1:v]scale=130:-1[top]; [0:v][top]overlay=500:250\" /Users/jitendersingh/Documents/appthumb9.jpg")
os.system("ffmpeg -y -i /Users/jitendersingh/Documents/appthumb9.jpg -i /Users/jitendersingh/Documents/logo10.png -filter_complex \"[1:v]scale=130:-1[top]; [0:v][top]overlay=500:400\" /Users/jitendersingh/Documents/appthumb10.jpg")

os.system("ffmpeg -i /Users/jitendersingh/Documents/appthumb10.jpg -vf drawtext=\"fontfile=/Users/jitendersingh/Library/Fonts/Tabloid Scuzzball.otf: text=Top 10\n"+thumbname+"\nApps\nFor Android: line_spacing=10: fontcolor=black: fontsize="+thumbfont+": shadowcolor=white: shadowx=5: shadowy=5: box=0: boxcolor=black: boxborderw=0: x=700:y=(h-text_h)/2\" \"/Users/jitendersingh/Documents/"+mytitle+".jpg\"")

#---------------------------------------Thumbnail End-----------------------------

os.system("ffmpeg -i /Users/jitendersingh/Documents/titlebg.mp4 -vf drawtext=\"fontfile=/Users/jitendersingh/Library/Fonts/Tabloid Scuzzball.otf: text=Best "+mytitle+"\nApps For Android: line_spacing=10: fontcolor=white: fontsize=140: shadowcolor=black: shadowx=1: shadowy=1: box=0: boxcolor=black: boxborderw=20: x=(w-text_w)/2:y=(h-text_h)/2\" /Users/jitendersingh/Documents/intro.mp4")




def sscr():
# #-----------------------------------Actual Scraping---------------------------

link = pd.read_csv('/Users/jitendersingh/Documents/test.csv', nrows=10, squeeze=True,usecols=["Question" , "A", "Logo"])
save = link.to_csv( '/Users/jitendersingh/Documents/test.csv' ) #save file with correct index
appurl = link.loc[0, 'A']

appsource = requests.get (appurl)
finder = BeautifulSoup(appsource.text,'html.parser')


myname = finder.find('h1', itemprop="name").span.text.replace(":" , "-" ).replace("," , "-" )


myrating = finder.find('div', class_="TT9eCd").text
mydown = finder.find_all('div', class_="ClM7O")[1].text
mydev = finder.find('div', class_="Vbfug auoIOc").text

#---------------------------Logo Section-----------------------------------

try:
mylogo = finder.find_all('div', class_="Mqg6jb Mhrnjf")

for logo in mylogo:
finallogos = logo.find('img', class_='T75of nm4vBd arM4bb')["src"] #Picture
finallogo = finallogos.replace("=s48" , "=s250" )

logoimg = requests.get(finallogo).content
with open('/Users/jitendersingh/Documents/logo.webp', 'wb') as handler:
handler.write(logoimg)
print(mylogo)
except:
mylogo = finder.find_all('div', class_="l8YSdd")

for logo in mylogo:
finallogos2 = logo.find('img', class_='T75of QhHVZd')["src"] #Picture
finallogo = finallogos2.replace("=s48" , "=s250" )

logoimg = requests.get(finallogo).content
with open('/Users/jitendersingh/Documents/logo.webp', 'wb') as handler:
handler.write(logoimg)
print(mylogo)

os.system("ffmpeg -i /Users/jitendersingh/Documents/logo.webp /Users/jitendersingh/Documents/logo.png")
#-------------------------Screenshot section-------------------------------------

ssdata = {
'Link' : [""],
'Status' : [""],
}
df = pd.DataFrame (ssdata)
df . to_csv ( '/Users/jitendersingh/Documents/ss.csv' , mode = 'a' , index = False , header = True )
print ( "ss sheet created successfully." )

myss = finder.find_all('div', class_="ULeU3b Utde2e")

for ss in myss:
newss = ss.find('img', class_='T75of B5GQxf')["src"] #Picture
newss2 = newss.replace("=w526-h296" , "=w1120-h780-rw" )
ssdata = {

'Link' : [newss2],
'Status' : ["hello"],
}

df = pd.DataFrame ( ssdata )
df.to_csv ( '/Users/jitendersingh/Documents/ss.csv', mode = 'a' , index = False , header = False )
print ( "ss file created successfully." )

#-------------ss csv to images---------------------
sscsv = pd.read_csv('/Users/jitendersingh/Documents/ss.csv', nrows=6, squeeze=True,usecols=["Link", "Status"])
savereset = sscsv.to_csv('/Users/jitendersingh/Documents/ss.csv')

img1 = sscsv.loc[2, 'Link']
img2 = sscsv.loc[3, 'Link']
try:
img3 = sscsv.loc[4, 'Link']
except:
time.sleep(1)

ssimg = requests.get(img1).content
with open('/Users/jitendersingh/Documents/my0001.webp', 'wb') as handler:
handler.write(ssimg)

ssimg = requests.get(img2).content
with open('/Users/jitendersingh/Documents/my0002.webp', 'wb') as handler:
handler.write(ssimg)
try:
ssimg = requests.get(img3).content
with open('/Users/jitendersingh/Documents/my0003.webp', 'wb') as handler:
handler.write(ssimg)
except:
time.sleep(1)

#-------------ffmpeg code-------------------------

os.system("ffmpeg -i /Users/jitendersingh/Documents/my0001.webp /Users/jitendersingh/Documents/my0001.png")
os.system("ffmpeg -i /Users/jitendersingh/Documents/my0002.webp /Users/jitendersingh/Documents/my0002.png")
try:
os.system("ffmpeg -i /Users/jitendersingh/Documents/my0003.webp /Users/jitendersingh/Documents/my0003.png")
except:
time.sleep(1)

os.system("ffmpeg -f image2 -framerate 1/5 -i '/Users/jitendersingh/Documents/my%04d.png' -r 25 '/Users/jitendersingh/Documents/output01.mp4'")
os.system("ffmpeg -y -i /Users/jitendersingh/Documents/1280.mp4 -i /Users/jitendersingh/Documents/output01.mp4 -filter_complex \"[1:v]scale=0:-1[top]; [0:v][top]overlay=(W-w)/2:200\" /Users/jitendersingh/Documents/output02.mp4")

os.system("ffmpeg -y -i /Users/jitendersingh/Documents/black.mp4 -i /Users/jitendersingh/Documents/output02.mp4 -filter_complex \"[1:v]scale=00:-1[top]; [0:v][top]overlay=640:0\" /Users/jitendersingh/Documents/output03.mp4")
os.system("ffmpeg -i /Users/jitendersingh/Documents/640.mp4 -i \"/Users/jitendersingh/Documents/logo.png\" -filter_complex \"[0:v] scale=0:-10 [top]; [1:v]loop=-1:size=5000, format=yuva420p[bottom]; [top][bottom]overlay=shortest=1:x=(W-w)/2:y=200, format=yuv420p\" /Users/jitendersingh/Documents/output04.mp4")
os.system("ffmpeg -i /Users/jitendersingh/Documents/output04.mp4 -vf drawtext=\"fontfile=/Users/jitendersingh/Library/Fonts/Tabloid Scuzzball.otf: text="+mydown+" Downloads: fontcolor=white: fontsize=80: shadowcolor=white: shadowx=1: shadowy=1: box=1: boxcolor=black: boxborderw=20: x=(w-text_w)/2:y=500\" /Users/jitendersingh/Documents/output05.mp4")
os.system("ffmpeg -i /Users/jitendersingh/Documents/output05.mp4 -vf drawtext=\"fontfile=/Users/jitendersingh/Library/Fonts/Tabloid Scuzzball.otf: text=Rating "+myrating+": fontcolor=white: fontsize=80: shadowcolor=white: shadowx=1: shadowy=1: box=1: boxcolor=black: boxborderw=20: x=(w-text_w)/2:y=650\" /Users/jitendersingh/Documents/output06.mp4")
os.system("ffmpeg -i /Users/jitendersingh/Documents/output06.mp4 -vf drawtext=\"fontfile=/Users/jitendersingh/Library/Fonts/Tabloid Scuzzball.otf: text=Download Link\nin Description: line_spacing=10: fontcolor=white: fontsize=80: shadowcolor=white: shadowx=1: shadowy=1: box=1: boxcolor=#DC2700: boxborderw=20: x=(w-text_w)/2:y=800\" /Users/jitendersingh/Documents/output07.mp4")
os.system("ffmpeg -y -i /Users/jitendersingh/Documents/output03.mp4 -i /Users/jitendersingh/Documents/output07.mp4 -filter_complex \"[1:v]scale=00:-1[top]; [0:v][top]overlay=0:0\" /Users/jitendersingh/Documents/output08.mp4")
os.system("ffmpeg -i /Users/jitendersingh/Documents/output08.mp4 -vf drawtext=\"fontfile=/Users/jitendersingh/Library/Fonts/Tabloid Scuzzball.otf: text="+myname+": fontcolor=white: fontsize=90: shadowcolor=white: shadowx=1: shadowy=1: box=1: boxcolor=black: boxborderw=20: x=(w-text_w)/2:y=70\" /Users/jitendersingh/Documents/title.mp4")
ssdl()

def ssdl():
os.remove('/Users/jitendersingh/Documents/my0001.webp')
os.remove('/Users/jitendersingh/Documents/my0002.webp')
try:
os.remove('/Users/jitendersingh/Documents/my0003.webp')
except:
time.sleep(1)
os.remove('/Users/jitendersingh/Documents/my0001.png')
os.remove('/Users/jitendersingh/Documents/my0002.png')
try:
os.remove('/Users/jitendersingh/Documents/my0003.png')
except:
time.sleep(1)
os.remove('/Users/jitendersingh/Documents/ss.csv')
os.remove('/Users/jitendersingh/Documents/output01.mp4')
os.remove('/Users/jitendersingh/Documents/output02.mp4')
os.remove('/Users/jitendersingh/Documents/output03.mp4')
os.remove('/Users/jitendersingh/Documents/output04.mp4')
os.remove('/Users/jitendersingh/Documents/output05.mp4')
os.remove('/Users/jitendersingh/Documents/output06.mp4')
os.remove('/Users/jitendersingh/Documents/output07.mp4')
os.remove('/Users/jitendersingh/Documents/output08.mp4')
os.remove('/Users/jitendersingh/Documents/logo.webp')
os.remove('/Users/jitendersingh/Documents/logo.png')

sscr()
os.system("ffmpeg -i /Users/jitendersingh/Documents/title.mp4 -vf drawtext=\"fontfile=/Users/jitendersingh/Library/Fonts/Tabloid Scuzzball.otf: text=01: fontcolor=white: fontsize=90: shadowcolor=white: shadowx=1: shadowy=1: box=1: boxcolor=black: boxborderw=20: x=20:y=20\" /Users/jitendersingh/Documents/1.mp4")
os.remove('/Users/jitendersingh/Documents/title.mp4')
link = pd.read_csv('/Users/jitendersingh/Documents/test.csv', squeeze=True,usecols=["Question" , "A", "Logo"])
delete = link.drop(link.index [ [ 0 ]], axis = 0 , inplace = True ) #delete first row
save = link.to_csv( '/Users/jitendersingh/Documents/test2.csv' ) #save file but index also deletes
os.remove ('/Users/jitendersingh/Documents/test.csv')
link2 = pd.read_csv( '/Users/jitendersingh/Documents/test2.csv' , squeeze = True , usecols =[ "Question" , "A", "Logo"]) #again open file for correct index
save = link2.to_csv( '/Users/jitendersingh/Documents/test.csv' ) #save file with correct index
os.remove ( '/Users/jitendersingh/Documents/test2.csv' )
print ( link )

sscr()
os.system("ffmpeg -i /Users/jitendersingh/Documents/title.mp4 -vf drawtext=\"fontfile=/Users/jitendersingh/Library/Fonts/Tabloid Scuzzball.otf: text=02: fontcolor=white: fontsize=90: shadowcolor=white: shadowx=1: shadowy=1: box=1: boxcolor=black: boxborderw=20: x=20:y=20\" /Users/jitendersingh/Documents/2.mp4")
os.remove('/Users/jitendersingh/Documents/title.mp4')
link = pd.read_csv('/Users/jitendersingh/Documents/test.csv', squeeze=True,usecols=["Question" , "A", "Logo"])
delete = link.drop(link.index [ [ 0 ]], axis = 0 , inplace = True ) #delete first row
save = link.to_csv( '/Users/jitendersingh/Documents/test2.csv' ) #save file but index also deletes
os.remove ('/Users/jitendersingh/Documents/test.csv')
link2 = pd.read_csv( '/Users/jitendersingh/Documents/test2.csv' , squeeze = True , usecols =[ "Question" , "A", "Logo"]) #again open file for correct index
save = link2.to_csv( '/Users/jitendersingh/Documents/test.csv' ) #save file with correct index
os.remove ( '/Users/jitendersingh/Documents/test2.csv' )
print ( link )

sscr()
os.system("ffmpeg -i /Users/jitendersingh/Documents/title.mp4 -vf drawtext=\"fontfile=/Users/jitendersingh/Library/Fonts/Tabloid Scuzzball.otf: text=03: fontcolor=white: fontsize=90: shadowcolor=white: shadowx=1: shadowy=1: box=1: boxcolor=black: boxborderw=20: x=20:y=20\" /Users/jitendersingh/Documents/3.mp4")
os.remove('/Users/jitendersingh/Documents/title.mp4')
link = pd.read_csv('/Users/jitendersingh/Documents/test.csv', squeeze=True,usecols=["Question" , "A", "Logo"])
delete = link.drop(link.index [ [ 0 ]], axis = 0 , inplace = True ) #delete first row
save = link.to_csv( '/Users/jitendersingh/Documents/test2.csv' ) #save file but index also deletes
os.remove ('/Users/jitendersingh/Documents/test.csv')
link2 = pd.read_csv( '/Users/jitendersingh/Documents/test2.csv' , squeeze = True , usecols =[ "Question" , "A", "Logo"]) #again open file for correct index
save = link2.to_csv( '/Users/jitendersingh/Documents/test.csv' ) #save file with correct index
os.remove ( '/Users/jitendersingh/Documents/test2.csv' )


sscr()
os.system("ffmpeg -i /Users/jitendersingh/Documents/title.mp4 -vf drawtext=\"fontfile=/Users/jitendersingh/Library/Fonts/Tabloid Scuzzball.otf: text=04: fontcolor=white: fontsize=90: shadowcolor=white: shadowx=1: shadowy=1: box=1: boxcolor=black: boxborderw=20: x=20:y=20\" /Users/jitendersingh/Documents/4.mp4")
os.remove('/Users/jitendersingh/Documents/title.mp4')
link = pd.read_csv('/Users/jitendersingh/Documents/test.csv', squeeze=True,usecols=["Question" , "A", "Logo"])
delete = link.drop(link.index [ [ 0 ]], axis = 0 , inplace = True ) #delete first row
save = link.to_csv( '/Users/jitendersingh/Documents/test2.csv' ) #save file but index also deletes
os.remove ('/Users/jitendersingh/Documents/test.csv')
link2 = pd.read_csv( '/Users/jitendersingh/Documents/test2.csv' , squeeze = True , usecols =[ "Question" , "A", "Logo"]) #again open file for correct index
save = link2.to_csv( '/Users/jitendersingh/Documents/test.csv' ) #save file with correct index
os.remove ( '/Users/jitendersingh/Documents/test2.csv' )


sscr()
os.system("ffmpeg -i /Users/jitendersingh/Documents/title.mp4 -vf drawtext=\"fontfile=/Users/jitendersingh/Library/Fonts/Tabloid Scuzzball.otf: text=05: fontcolor=white: fontsize=90: shadowcolor=white: shadowx=1: shadowy=1: box=1: boxcolor=black: boxborderw=20: x=20:y=20\" /Users/jitendersingh/Documents/5.mp4")
os.remove('/Users/jitendersingh/Documents/title.mp4')
delete = link.drop(link.index [ [ 0 ]], axis = 0 , inplace = True ) #delete first row
save = link.to_csv( '/Users/jitendersingh/Documents/test2.csv' ) #save file but index also deletes
os.remove ('/Users/jitendersingh/Documents/test.csv')
link2 = pd.read_csv( '/Users/jitendersingh/Documents/test2.csv' , squeeze = True , usecols =[ "Question" , "A", "Logo"]) #again open file for correct index
save = link2.to_csv( '/Users/jitendersingh/Documents/test.csv' ) #save file with correct index
os.remove ( '/Users/jitendersingh/Documents/test2.csv' )
print ( link )

sscr()
os.system("ffmpeg -i /Users/jitendersingh/Documents/title.mp4 -vf drawtext=\"fontfile=/Users/jitendersingh/Library/Fonts/Tabloid Scuzzball.otf: text=06: fontcolor=white: fontsize=90: shadowcolor=white: shadowx=1: shadowy=1: box=1: boxcolor=black: boxborderw=20: x=20:y=20\" /Users/jitendersingh/Documents/6.mp4")
os.remove('/Users/jitendersingh/Documents/title.mp4')
delete = link.drop(link.index [ [ 0 ]], axis = 0 , inplace = True ) #delete first row
save = link.to_csv( '/Users/jitendersingh/Documents/test2.csv' ) #save file but index also deletes
os.remove ('/Users/jitendersingh/Documents/test.csv')
link2 = pd.read_csv( '/Users/jitendersingh/Documents/test2.csv' , squeeze = True , usecols =[ "Question" , "A", "Logo"]) #again open file for correct index
save = link2.to_csv( '/Users/jitendersingh/Documents/test.csv' ) #save file with correct index
os.remove ( '/Users/jitendersingh/Documents/test2.csv' )
print ( link )

sscr()
os.system("ffmpeg -i /Users/jitendersingh/Documents/title.mp4 -vf drawtext=\"fontfile=/Users/jitendersingh/Library/Fonts/Tabloid Scuzzball.otf: text=07: fontcolor=white: fontsize=90: shadowcolor=white: shadowx=1: shadowy=1: box=1: boxcolor=black: boxborderw=20: x=20:y=20\" /Users/jitendersingh/Documents/7.mp4")
os.remove('/Users/jitendersingh/Documents/title.mp4')
delete = link.drop(link.index [ [ 0 ]], axis = 0 , inplace = True ) #delete first row
save = link.to_csv( '/Users/jitendersingh/Documents/test2.csv' ) #save file but index also deletes
os.remove ('/Users/jitendersingh/Documents/test.csv')
link2 = pd.read_csv( '/Users/jitendersingh/Documents/test2.csv' , squeeze = True , usecols =[ "Question" , "A", "Logo"]) #again open file for correct index
save = link2.to_csv( '/Users/jitendersingh/Documents/test.csv' ) #save file with correct index
os.remove ( '/Users/jitendersingh/Documents/test2.csv' )
print ( link )

sscr()
os.system("ffmpeg -i /Users/jitendersingh/Documents/title.mp4 -vf drawtext=\"fontfile=/Users/jitendersingh/Library/Fonts/Tabloid Scuzzball.otf: text=08: fontcolor=white: fontsize=90: shadowcolor=white: shadowx=1: shadowy=1: box=1: boxcolor=black: boxborderw=20: x=20:y=20\" /Users/jitendersingh/Documents/8.mp4")
os.remove('/Users/jitendersingh/Documents/title.mp4')
delete = link.drop(link.index [ [ 0 ]], axis = 0 , inplace = True ) #delete first row
save = link.to_csv( '/Users/jitendersingh/Documents/test2.csv' ) #save file but index also deletes
os.remove ('/Users/jitendersingh/Documents/test.csv')
link2 = pd.read_csv( '/Users/jitendersingh/Documents/test2.csv' , squeeze = True , usecols =[ "Question" , "A", "Logo"]) #again open file for correct index
save = link2.to_csv( '/Users/jitendersingh/Documents/test.csv' ) #save file with correct index
os.remove ( '/Users/jitendersingh/Documents/test2.csv' )
print ( link )

sscr()
os.system("ffmpeg -i /Users/jitendersingh/Documents/title.mp4 -vf drawtext=\"fontfile=/Users/jitendersingh/Library/Fonts/Tabloid Scuzzball.otf: text=09: fontcolor=white: fontsize=90: shadowcolor=white: shadowx=1: shadowy=1: box=1: boxcolor=black: boxborderw=20: x=20:y=20\" /Users/jitendersingh/Documents/9.mp4")
os.remove('/Users/jitendersingh/Documents/title.mp4')
delete = link.drop(link.index [ [ 0 ]], axis = 0 , inplace = True ) #delete first row
save = link.to_csv( '/Users/jitendersingh/Documents/test2.csv' ) #save file but index also deletes
os.remove ('/Users/jitendersingh/Documents/test.csv')
link2 = pd.read_csv( '/Users/jitendersingh/Documents/test2.csv' , squeeze = True , usecols =[ "Question" , "A", "Logo"]) #again open file for correct index
save = link2.to_csv( '/Users/jitendersingh/Documents/test.csv' ) #save file with correct index
os.remove ( '/Users/jitendersingh/Documents/test2.csv' )
print ( link )

sscr()
os.system("ffmpeg -i /Users/jitendersingh/Documents/title.mp4 -vf drawtext=\"fontfile=/Users/jitendersingh/Library/Fonts/Tabloid Scuzzball.otf: text=10: fontcolor=white: fontsize=90: shadowcolor=white: shadowx=1: shadowy=1: box=1: boxcolor=black: boxborderw=20: x=20:y=20\" /Users/jitendersingh/Documents/10.mp4")
os.remove('/Users/jitendersingh/Documents/title.mp4')
delete = link.drop(link.index [ [ 0 ]], axis = 0 , inplace = True ) #delete first row
save = link.to_csv( '/Users/jitendersingh/Documents/test2.csv' ) #save file but index also deletes
os.remove ('/Users/jitendersingh/Documents/test.csv')
link2 = pd.read_csv( '/Users/jitendersingh/Documents/test2.csv' , squeeze = True , usecols =[ "Question" , "A", "Logo"]) #again open file for correct index
save = link2.to_csv( '/Users/jitendersingh/Documents/test.csv' ) #save file with correct index
os.remove ( '/Users/jitendersingh/Documents/test2.csv' )
print ( link )

os.system("ffmpeg -f concat -safe 0 -i /Users/jitendersingh/Documents/default.txt -c copy /Users/jitendersingh/Documents/best.mp4")
os.system("ffmpeg -stream_loop -1 -i /Users/jitendersingh/Documents/best.mp4 -i /Users/jitendersingh/Documents/music.m4a -shortest -map 0:v:0 -map 1:a:0 -y -c copy -bsf:v h264_mp4toannexb -f mpegts /Users/jitendersingh/Documents/withmusic.ts")
os.system("ffmpeg -i \"concat:/Users/jitendersingh/Documents/withmusic.ts|/Users/jitendersingh/Documents/outro.ts\" \"/Users/jitendersingh/Documents/"+mytitle+".mp4\"")


os.remove('/Users/jitendersingh/Documents/logo1.png')
os.remove('/Users/jitendersingh/Documents/logo2.png')
os.remove('/Users/jitendersingh/Documents/logo3.png')
os.remove('/Users/jitendersingh/Documents/logo4.png')
os.remove('/Users/jitendersingh/Documents/logo5.png')
os.remove('/Users/jitendersingh/Documents/logo6.png')
os.remove('/Users/jitendersingh/Documents/logo7.png')
os.remove('/Users/jitendersingh/Documents/logo8.png')
os.remove('/Users/jitendersingh/Documents/logo9.png')
os.remove('/Users/jitendersingh/Documents/logo10.png')
os.remove('/Users/jitendersingh/Documents/appthumb1.jpg')
os.remove('/Users/jitendersingh/Documents/appthumb2.jpg')
os.remove('/Users/jitendersingh/Documents/appthumb3.jpg')
os.remove('/Users/jitendersingh/Documents/appthumb4.jpg')
os.remove('/Users/jitendersingh/Documents/appthumb5.jpg')
os.remove('/Users/jitendersingh/Documents/appthumb6.jpg')
os.remove('/Users/jitendersingh/Documents/appthumb7.jpg')
os.remove('/Users/jitendersingh/Documents/appthumb8.jpg')
os.remove('/Users/jitendersingh/Documents/appthumb9.jpg')
os.remove('/Users/jitendersingh/Documents/appthumb10.jpg')
os.remove('/Users/jitendersingh/Documents/1.mp4')
os.remove('/Users/jitendersingh/Documents/2.mp4')
os.remove('/Users/jitendersingh/Documents/3.mp4')
os.remove('/Users/jitendersingh/Documents/4.mp4')
os.remove('/Users/jitendersingh/Documents/5.mp4')
os.remove('/Users/jitendersingh/Documents/6.mp4')
os.remove('/Users/jitendersingh/Documents/7.mp4')
os.remove('/Users/jitendersingh/Documents/8.mp4')
os.remove('/Users/jitendersingh/Documents/9.mp4')
os.remove('/Users/jitendersingh/Documents/10.mp4')

os.remove('/Users/jitendersingh/Documents/test.csv')
os.remove('/Users/jitendersingh/Documents/withmusic.ts')
os.remove('/Users/jitendersingh/Documents/best.mp4')
os.remove('/Users/jitendersingh/Documents/intro.mp4')
os.remove('/Users/jitendersingh/Documents/'+mytitle+'.csv')

appcsv = pd.read_csv('/Users/jitendersingh/Documents/appcsv.csv', squeeze=True,usecols=["Link", "Name"])
newappcsv = appcsv.reset_index() # add index in new file / try to run this code when upload new file

deleteappcsv = appcsv.drop(appcsv.index[[0]],axis=0,inplace=True) #delete first row
saveappcsv = appcsv.to_csv('/Users/jitendersingh/Documents/appcsv2.csv') #save file but index also deletes
os.remove('/Users/jitendersingh/Documents/appcsv.csv')
appcsv2 = pd.read_csv('/Users/jitendersingh/Documents/appcsv2.csv', squeeze=True,usecols=["Link", "Name"]) #again open file for correct index
newappcsv = appcsv.reset_index() # correct index
saveappcsv = appcsv2.to_csv('/Users/jitendersingh/Documents/appcsv.csv') #save file with correct index
os.remove('/Users/jitendersingh/Documents/appcsv2.csv')
print (appcsv)

print("done")

for i in range(1):
fun1()

0 comments:

Post a Comment

 
Top