top of page

Youtube Cite Version 2.1 Download Link & Source Code To The Final Update

  • Writer: Brian Clark
    Brian Clark
  • Oct 3, 2022
  • 4 min read

It has been an exciting journey into python and creating citations. I'm going to leave a link to YouTube Cite Version 2.1. The latest version allows you to copy a citation directly from the program and paste it where you want.


Download Link: here


Here is the source code:



'''//...........................................................................................................................................
//.YYYY....YYYY......................uTTTTTTTTTTT.........uub......................CCCCCC....CCii...tt...............22222..........00000....
//.YYYY....YYY.......................uTTTTTTTTTTT.........uub.....................CCCCCCCCC..CCii.iitt.............ee222222.........000000...
//..YYYY..YYYY.......................uTTTTTTTTTTT.........uub....................eCCCCCCCCC.......iitt.............ee2..2222........00.000...
//...YYY..YYY.....ooooo...ouuu..uuuu.....TTTT..TTu...uuuu.uubbbbbb.....eeeee....eeCC...CCCCC.CCiiiiitttt..eeeee....ee2...222........0..0000..
//...YYYYYYYY...oooooooo..ouuu..uuuu.....TTTT..TTu...uuuu.uubbbbbbb...beeeeee...eeCC....CCC..CCiiiiitttt.teeeeee........2222........0...000..
//....YYYYYY....ooo..oooo.ouuu..uuuu.....TTTT..TTu...uuuu.uubb..bbbb.bbe..eeee..eeC..........CCii.iitt..tte..eeee.......2222........0...000..
//.....YYYY....Yooo...ooo.ouuu..uuuu.....TTTT..TTu...uuuu.uub....bbb.bbe...eee..eeC..........CCii.iitt..tte...eee......2222.........0...000..
//.....YYYY....Yoo....ooo.ouuu..uuuu.....TTTT..TTu...uuuu.uub....bbb.bbeeeeeee..eeC..........CCii.iitt..tteeeeeee.....2222..........0...000..
//.....YYYY....Yoo....ooo.ouuu..uuuu.....TTTT..TTu...uuuu.uub....bbb.bbeeeeeee..eeCC....CCC..CCii.iitt..tteeeeeee....2222...........0...000..
//.....YYYY....Yooo...ooo.ouuu..uuuu.....TTTT..TTu...uuuu.uub....bbb.bbe........eeCC...CCCCC.CCii.iitt..tte.........e222............0..0000..
//.....YYYY....Yooo..oooo.ouuu..uuuu.....TTTT..TTuu.uuuuu.uubb..bbbb.bbe..eeee...eCCCCCCCCC..CCii.iitt..tte..eeee..ee22......22.....00.000...
//.....YYYY.....oooooooo...uuuuuuuuu.....TTTT..TTuuuuuuuu.uubbbbbbb...beeeeee.....CCCCCCCCC..CCii..itttt.teeeeee...ee2222222.22.....000000...
//.....YYYY.......ooooo.....uuuuuuuu.....TTTT...Tuuuuuuuu.uubbbbbb.....eeeee.......CCCCCC....CCii..itttt..eeeee...eee2222222.22.....00000....
//...........................................................................................................................................'''
'''Version 2.1: Output citation to a box and easily copy it.  '''
from distutils.cmd import Command
from distutils.util import execute
from encodings import utf_8
from hashlib import new
from calendar import c
from msilib.schema import ComboBox
import pprint as pp
import re
from tkinter import Y
from turtle import width
from bs4 import BeautifulSoup
import requests
import sqlite3
import os.path
import keyboard 
import tkinter
import customtkinter
import tkinter.messagebox
import customtkinter
import csv
import webbrowser
from tkinter.ttk import *


# _____ SET APPEARANCE ______________________ 

customtkinter.set_appearance_mode("dark")  # Modes: "System" (standard), "Dark", "Light"
customtkinter.set_default_color_theme("blue")  # Themes: "blue" (standard), "green", "dark-blue"


# ____ GRABS THE URL DATA ___________________
# If TEXT File is selected Execute 

def button_callback():
        
                 
          page = requests.get(entry_1.get()) #URL INPUT Box  
          soup = BeautifulSoup(page.content, "html.parser")
          channel_name = soup.find("span", itemprop="author").next.next['content']
          result = soup.find("meta", itemprop="datePublished")['content']

          channel_title = soup.title.string
          channel_title_two = soup.find("meta", itemprop="name")["content"]
          channel_url = soup.find("span", itemprop="author").next['href']
          website = "YouTube"   
            
          text_file = open("TextCite.txt", "a", encoding='utf-8', newline='')# added encoding 
          text_file.write(channel_name+". ("+result+"). " +
                                channel_title_two+". "+website+". "+channel_url+".\n\n\n")                
         

#___________________________________________________________
# ___________________ DATABASE INSERT ______________________

def insert_Db():
   
     '''' __________________________________
          ________ Create Database _________
          NOTE: YOU HAVE TO CLOSE ONE OF THE DATABASE FILES 
          FOR IT TO INSERT NEW DATA INTO THE DATABASE
     '''
     #setup a connection to the database 
     conn = sqlite3.connect('DBCite.db')

     #Cursor allows us to execute commands to the db
     cur = conn.cursor()
     #execute our query
     cur.execute('''CREATE TABLE IF NOT EXISTS elements
                    (Channel text PRIMARY KEY, Date text, Title text, Url text, Website real  )''')
  
     page = requests.get(entry_1.get())
     soup = BeautifulSoup(page.content, "html.parser")

     # Print the channel name of the youtube channel
     # Variables
     # ______________________________________________________________________
     # ____________________ STORE WEBSITE DATA INTO VARIABLES _______________ 
     channel_name = soup.find("span", itemprop="author").next.next['content']
     result = soup.find("meta", itemprop="datePublished")['content']

     channel_title = soup.title.string
     channel_url = soup.find("span", itemprop="author").next['href']
     channel_title_two = soup.find("meta", itemprop="name")["content"]
     website = "YouTube"

     channel_info =[]
     channel_info.append((channel_name, result,
                    channel_title_two, channel_url, website))

     #__________________INSERT CHANNEL DATA INTO CSV FILE__________________________           
     
     cur.executemany("INSERT OR IGNORE INTO elements VALUES (?,?,?,?,?)", channel_info)
     conn.commit()
     cur.close()
   #________________________________________________________________
     ''' ______________________ CSV OUTPUT FILE ________________________'''
def Csv_output():
   
   # Pull the data from youtube and 
   page = requests.get(entry_1.get())
   soup = BeautifulSoup(page.content, "html.parser")
   
   channel_name = soup.find("span", itemprop="author").next.next['content']
   result = soup.find("meta", itemprop="datePublished")['content']

   channel_title = soup.title.string
   channel_url = soup.find("span", itemprop="author").next['href']
   channel_title_two = soup.find("meta", itemprop="name")["content"]
   website = "YouTube"
   # store the data into a list 
   channel_info =[]
   channel_info.append((channel_name, result,
                    channel_title_two, channel_url, website))
          
   # Open a new .csv file and create the fieled names
   with open('CiteCSV.csv', 'a+', newline='') as csv_file:    #a+ appends the data to the next line 
         
        fieldnames =['Channel', 'Date', 'Title', 'URL', 'Website'] #Head of the csv files
        thewriter = csv.writer(csv_file) #
        #channel_info = csv.DictWriter(f, channel_info) #write the channel info to the .csv file
        
        #thewriter.writeheader() 
        #thewriter = csv.writer(f)     
        
         #_________________ Assign the header columns to the variables ________________
        thewriter.writerow([channel_name, result,
                           channel_title_two, channel_url, website])
      #for i in range(1.100):Loop 100 lines 
        #channel_info.writerow({channel_name, result, channel_title_two, channel_url, website})
           

def Insert_Ct():
#___________________________________________________________
# ___________________  INSERT CITATION INTO ENTRY BOX ______________________
     
     page = requests.get(entry_1.get()) #URL INPUT Box  
     soup = BeautifulSoup(page.content, "html.parser")
     channel_name = soup.find("span", itemprop="author").next.next['content']
     result = soup.find("meta", itemprop="datePublished")['content']

     channel_title = soup.title.string
     channel_title_two = soup.find("meta", itemprop="name")["content"]
     channel_url = soup.find("span", itemprop="author").next['href']
     website = "YouTube"   
          
      
     elements = (channel_name+". ("+result+"). " + "\n"+
                              channel_title_two+". "+website+". "+channel_url+".\n\n\n")      
     print(elements)
     Copy_cite.insert(0, elements)
     #text = Copy_cite.get()
     #print(text)
     return None

     
# Step 1: # Select The TEXT FIle Option then pull URL done
#       a. Pull The URL from youtube   
# Step 2: Select DATABASE and output to a .db file 
    
    # Successfully pulled the youtube URL and paced it into text file



# _____ SIZE OF THE APP WINDOW _____

WIDTH = 700 
HIEGHT =700

# ______________________  APP SETUP   _____________________________

app = customtkinter.CTk()
app.geometry(f"{WIDTH}x{HIEGHT}")
app.title("YouTube Cite Version 2.0")
app.iconbitmap(r'favicon.ico')  
# Download icons from this link: https://www.flaticon.com/search?word=cite&order_by=4
# Convert the icons at this link: https://www.icoconverter.com/

#_______________________ ICON _____________________________________

blank = Entry(app)

# ______________________ FRAME OF APP _____________________________

frame_1 = customtkinter.CTkFrame(master=app)
frame_1.pack(pady=20, padx=60, fill="both", expand=True)


# ______________________ MAIN ENTRY  __________________________________

entry_1 = customtkinter.CTkEntry(master=frame_1, placeholder_text="PASTE YOUTUBE URL", width=400, height=50)
entry_1.pack(pady=12, padx=10)

# ________________________ TEXT FILE MAIN BUTTON  1__________________________________
 
button_1 = customtkinter.CTkButton(master=frame_1, text="TEXT FILE", text_font="Sans-sarif", width=400, height=50, command=button_callback)
button_1.pack(pady=12, padx=10)

# ________________________ DATABASE Second BUTTON 2 _____________________________________
button_2 = customtkinter.CTkButton(master=frame_1, text="DATABASE", text_font="Sans-sarif", width=400, height=50, command=insert_Db)
button_2.pack(pady=12, padx=10)


# _________________________   CSV Second BUTTON 3  _____________________________________
button_2 = customtkinter.CTkButton(master=frame_1, text="CSV", text_font="Sans-sarif", width=400, height=50, command=Csv_output)
button_2.pack(pady=12, padx=10)

# _________________________   CSV Second BUTTON 4  _____________________________________
button_2 = customtkinter.CTkButton(
    master=frame_1, text="DISPLAY", text_font="Sans-sarif", width=400, height=50, command=Insert_Ct)
button_2.pack(pady=12, padx=10)

#________________________ Informaiton Box_______________________________________
label = customtkinter.CTkLabel(master=frame_1, 
                               text="Author: Brian Clark \n Description: Citation tool that automatically \ncopies the URL of a youtube link and pastes the \nelements into TEXT File, CSV, and Database.\n https://linktr.ee/Bclarkcodes", width=100, height=100)
label.pack(pady=10, padx=10)

''' ______________________ Output The Entry Box________________________'''
Copy_cite = customtkinter.CTkEntry(master=frame_1, width=400, height=70)
Copy_cite.pack(pady=12, padx=10)


 
# List of options 
# combobox_1 = customtkinter.CTkComboBox(frame_1, values=["TEXT FILE", "CSV", "DATABASE"])
# combobox_1.pack(pady=12, padx=10)
# optionmenu_1.set("Export")




# checkbox_1 = customtkinter.CTkCheckBox(master=frame_1)
# checkbox_1.pack(pady=12, padx=10)



# def slider_callback(value):
#     progressbar_1.set(value)

# label_1 = customtkinter.CTkLabel(master=frame_1, justify=tkinter.LEFT)
# label_1.pack(pady=12, padx=10)


# progressbar_1 = customtkinter.CTkProgressBar(master=frame_1)
# progressbar_1.pack(pady=12, padx=10)

# radiobutton_var = tkinter.IntVar(value=1)

# radiobutton_1 = customtkinter.CTkRadioButton(master=frame_1, variable=radiobutton_var, value=1)
# radiobutton_1.pack(pady=12, padx=10)

# radiobutton_2 = customtkinter.CTkRadioButton(master=frame_1, variable=radiobutton_var, value=2)
# radiobutton_2.pack(pady=12, padx=10)

# switch_1 = customtkinter.CTkSwitch(master=frame_1)
# switch_1.pack(pady=12, padx=10)


# slider_1 = customtkinter.CTkSlider(master=frame_1, command=slider_callback, from_=0, to=1)
# slider_1.pack(pady=12, padx=10)
# slider_1.set(0.5)

#  page = requests.get(entry_1.get()) #URL INPUT Box  
#       soup = BeautifulSoup(page.content, "html.parser")
      
#       channel_name = soup.find("span", itemprop="author").next.next['content']
#       result = soup.find("meta", itemprop="datePublished")['content']

#       channel_title = soup.title.string
#       channel_url = soup.find("span", itemprop="author").next['href']
#       channel_title_two = soup.find("meta", itemprop="name")["content"]
#       website = "YouTube"  
                      
#       header = ['Channel','Date', 'Title', 'URL', 'Website']
#       data = []
#       data.append =(channel_name,result,
#                      channel_title_two, channel_url, website)
         
#       writer = csv.writer(f)

#       # write the header
#       writer.writerow(header)

#       # write multiple rows
#       writer.writerows(data)

app.mainloop()

Comments


bottom of page