CognitiveScience commited on
Commit
1cb4f86
·
1 Parent(s): 444917c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -37
app.py CHANGED
@@ -1,48 +1,18 @@
1
  import gradio as gr
2
  from bs4 import BeautifulSoup
3
  import requests
4
- from python_actr import *
 
5
  #from cogscidighum import *
6
 
7
 
8
- class myCelSci(Model):
9
- pass
10
 
11
- def greet(link):
12
- 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'}
13
- #link = "https://youtu.be/vQUCSHUlN-k?si=FfIsODGjJDzIHOAS"
14
- response = requests.get(link) #, headers=HEADER)
15
- soup = BeautifulSoup(response.text, "html.parser")
16
- #print (soup.prettify())
17
 
18
- titleSoupMeta = soup.find("meta", property="og:title")
19
- videoTitle = titleSoupMeta["content"] if titleSoupMeta else "NotFound"
20
- result = {}
21
- result["views"] = soup.find("meta", itemprop="interactionCount")['content']
22
-
23
- #soup=soup.prettify()
24
- #viewSoupMeta = [line for line in soup.split('viewCount') if "views" in line]
25
-
26
- response2=response.text[response.text.find("viewCount"):].split('"')[2]
27
- # Store JSON data in API_Data
28
- #for key in API_Data:{
29
- # print(key,":", API_Data[key])
30
- #}
31
- #viewSoupMeta=viewSoupMeta[19:25]
32
- ##videoViews = viewSoupMeta["content"] if titleSoupMeta else "NotFound"
33
- '''
34
- if soup.find(attrs={"viewCount": "3363"}) == None:
35
- viewSoupMeta = "3363" #soup.find(attrs={"class": "watch-view-count"}).text
36
- else:
37
- viewSoupMeta= soup
38
- '''
39
- #viewSoupMeta = API_Data #str(response).find("viewCount")
40
-
41
- celsci1=myCelSci()
42
-
43
- response3= response2 #celsci1.ax1 #celsci1.fame(300) #checkfame("dd")
44
-
45
- return response3 #result #soup.prettify()
46
 
47
 
48
  iface = gr.Interface(fn=greet, inputs="text", outputs="text")
 
1
  import gradio as gr
2
  from bs4 import BeautifulSoup
3
  import requests
4
+ import youtube1 as youtuby
5
+ #from python_actr import *
6
  #from cogscidighum import *
7
 
8
 
9
+ #class myCelSci(Model):
10
+ # pass
11
 
12
+ def main(link):
13
+ response=getviews(link)
 
 
 
 
14
 
15
+ return response #result #soup.prettify()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
16
 
17
 
18
  iface = gr.Interface(fn=greet, inputs="text", outputs="text")