File size: 1,681 Bytes
405af5a
 
 
a76224c
 
63666cb
71e0f1f
6c587ce
d98e25b
63666cb
405af5a
 
73d7f93
405af5a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
abf12fd
b2345a8
abf12fd
d98e25b
405af5a
c6f2109
405af5a
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import gradio as gr
from bs4 import BeautifulSoup
import requests
#from python_actr import *
from cogscidighum import Celsci


class myCelSci(Celsci):
    pass
    
def greet(link):
    HEADER = {"User-Agent": 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.102 Safari/537.36'}
    link = "https://youtu.be/vQUCSHUlN-k?si=FfIsODGjJDzIHOAS"
    response = requests.get(link) #, headers=HEADER)
    soup = BeautifulSoup(response.text, "html.parser")  
    #print (soup.prettify())

    titleSoupMeta = soup.find("meta", property="og:title")
    videoTitle = titleSoupMeta["content"] if titleSoupMeta else "NotFound"
    result = {}
    result["views"] = soup.find("meta", itemprop="interactionCount")['content']

    #soup=soup.prettify()
    #viewSoupMeta = [line for line in soup.split('viewCount') if "views" in line]
    
    response2=response.text[response.text.find("viewCount"):].split('"')[2]
    # Store JSON data in API_Data
    #for key in API_Data:{
    #	print(key,":", API_Data[key])
    #}
    #viewSoupMeta=viewSoupMeta[19:25]
    ##videoViews = viewSoupMeta["content"] if titleSoupMeta else "NotFound"
    '''
    if soup.find(attrs={"viewCount": "3363"}) == None:
        viewSoupMeta =  "3363" #soup.find(attrs={"class": "watch-view-count"}).text
    else:
        viewSoupMeta=  soup
    '''
    #viewSoupMeta = API_Data #str(response).find("viewCount")
    
    celsci1=Celsci()
    
    response3= celsci1.celscilist["dd"]['x']['followers'] #celsci1.fame(300) #checkfame("dd")

    return  response3 #result #soup.prettify()


iface = gr.Interface(fn=greet, inputs="text", outputs="text")
iface.launch()