Untitled

 avatar
unknown
plain_text
2 years ago
3.5 kB
4
Indexable
[16/11, 00:13] Taneeshk: import json
import shutil
from wsgiref import headers
from aiohttp import request
from bs4 import BeautifulSoup
import requests
from selenium import webdriver
from time import sleep
from instascrape import Reel
import os
import json
import shutil

from webdriver_manager.chrome import ChromeDriverManager

browser = webdriver.Chrome(executable_path=ChromeDriverManager().install())

browser.implicitly_wait(1)

browser.get('https://www.instagram.com/')

sleep(5)

usernam3e_input = browser.find_element_by_css_selector("input[name='username']")
password_input = browser.find_element_by_css_selector("input[name='password']")

username_input.send_keys("myspam69okboy")
password_input.send_keys("passis69")

login_button = browser.find_element_by_xpath("//button[@type='submit']")
login_button.click()

sleep(3)





# session id
SESSIONID = "Paste session Id Here"

# Header with session id
headers = {
	"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64)\
	AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.74 \
	Safari/537.36 Edg/79.0.309.43",
	"cookie": f'sessionid={SESSIONID};'
}

# Passing Instagram reel link as argument in Reel Module
insta_reel = Reel(
	'')

# Using scrape function and passing the headers
insta_reel.scrape(headers=headers)

# Giving path where we want to download reel to the
# download function
insta_reel.download(fp=f".\\Desktop\\reel{int(time.time())}.mp4")

# printing success Message
print('Downloaded Successfully.')



headers = {
	"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64)\
	AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.74 \
	Safari/537.36 Edg/79.0.309.43",
	"cookie": f'sessionid={SESSIONID};'
}
INSTA_URL = "https://www.instagram.com/reel/Ck9fwq1M97f/"
TAIL = "?__a=1"

URL = INSTA_URL + TAIL

response = requests.get(URL,headers=headers).json()

video_location = response["graphq1"]["shortcode_media"]['video_url']

print(video_location)
[16/11, 00:15] Taneeshk: from moviepy.editor import *
  
   
# loading video dsa gfg intro video
clip = VideoFileClip("dsa_geek.mp4")
  
  

audioclip = AudioFileClip("allwell.mp3")
  
# adding audio to the video clip
videoclip = clip.set_audio(audioclip)
  
# showing video clip
videoclip.ipython_display()
[16/11, 00:15] Taneeshk: import datetime
from googleapiclient.http import MediaFileUpload

def uploadYtvid(VIDEO_FILE_NAME='',
                title='Intro Video!',
                description=':) ',
                tags=[],
                googleAPI=None):
    
    now = datetime.datetime.now()
    upload_date_time = datetime.datetime(now.year, now.month, now.day, now.hour, now.minute, int(now.second)).isoformat() + '.000Z'

    request_body = {
        'snippet': {
            'categoryId': 23,
            'title': title,
            'description': description,
            'tags': tags
        },
        'status': {
            'privacyStatus': 'public',
            'selfDeclaredMadeForKids': False, 
        },
        'notifySubscribers': False
    }

    mediaFile = MediaFileUpload(VIDEO_FILE_NAME, chunksize=-1, resumable=True)

    response_upload = googleAPI.videos().insert(
        part='snippet,status',
        body=request_body,
        media_body=mediaFile
    ).execute()

    """
    googleAPI.thumbnails().set(
        videoId=response_upload.get('id'),
        media_body=MediaFileUpload('thumbnail.png')
    ).execute()
    """

    print("Upload Successful!")

if __name__ == "__main__":
    uploadYtvid(VIDEO_FILE_NAME='./intro_vid.mp4')
Editor is loading...