Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Read YouTube links/numbers
#1
Hey,

Im a new user to QM and dont have so much coding experience, so please be gentle Smile

What I would like to have is a macro that will read out all the link (twitter, facebook) on the /about page on youtube.
Then pastes them to a .txt file and opens them in a new tab.

The macro Ive got here already does that but there is a problem when a website is used twice.
See here for e.g. youtube.com/user/M3RKMUS1C/about
The user has put 2 twitter links, now I will only get the first one. How can I get both links?

Macro Youtube links
Code:
Copy      Help
int w=act(win("" "Chrome_WidgetWin_1"))
lef 141 9 w 1 ;;Text ''
Acc a.Find(w "DOCUMENT" "" "" 0x3010 2)
ARRAY(Acc) aa; int i
a.GetChildObjects(aa -1 "LINK" "Facebook")
for i 0 aa.len
,Acc& r=aa[i]
,str name=r.Name
,str url=r.Value
,out "%-35s %s" aa[i].Name aa[i].Value

a.GetChildObjects(aa -1 "LINK" "Twitter")
for i 0 aa.len
,Acc& b=aa[i]
,str url2=b.Value
for i 0 aa.len
,Acc& b2=aa[i]
,str url22=b.Value

a.GetChildObjects(aa -1 "LINK" "Twitch")
for i 0 aa.len
,Acc& d=aa[i]
,str url4=d.Value

a.GetChildObjects(aa -1 "LINK" "Instagram")
for i 0 aa.len
,Acc& c=aa[i]
,str url3=c.Value

int w1=act(win("test - Editor" "Notepad"))
lef 313 17 w1 ;;Titelleiste
paste (url)
' Y
paste (url2)
' Y
paste (url3)
' Y
paste (url22)
run (url)
run (url2)
run (url3)
run (url4)


Another thing I would like to do is to get the subscriber / total views number.
Problematic here is that its not always the same amount of numbers (e.g. 10.000 vs 1.000.000 subscribers).
How can I get started here?

Thanks!
#2
Macro Macro2816
Code:
Copy      Help
int w=act(win("" "Chrome_WidgetWin_1"))
lef 141 9 w 1 ;;Text ''
Acc a.Find(w "DOCUMENT" "" "" 0x3010 2)
ARRAY(Acc) aa; int i
ARRAY(str) aURL
a.GetChildObjects(aa -1 "LINK" "Facebook|Twitter|Twitch|Instagram" "" 2)
for i 0 aa.len
,Acc& r=aa[i]
,str name=r.Name
,str url=r.Value
,out "%-35s %s" aa[i].Name aa[i].Value
,aURL[]=url

int w1=act(win("test - Editor" "Notepad"))
paste aURL

for i 0 aURL.len
,run aURL[i]

Quote:Another thing I would like to do is to get the subscriber / total views number.
Problematic here is that its not always the same amount of numbers (e.g. 10.000 vs 1.000.000 subscribers).
How can I get started here?
Macro Macro2818
Code:
Copy      Help
int w=wait(3 WV win(" - YouTube - Google Chrome" "Chrome_WidgetWin_1"))
Acc a.FindFF(w "span" "" "class=yt-subscription-button*" 0x1004 3|4)
str s=a.Description
s.findreplace("."); s.findreplace(",") ;;remove thousand separators
int n=val(s)
out n
#3
Thank you very much! Smile

It works now. One question, is there a way to read out for the URL not the description/name of a link?
Because sometimes users will define the link to their stream either as "Twitch", "Livestream" or something else.
It would be more bullet proof if it can search for the URL. I'm also getting a lot of links twice.

As for the numbers, I cant get it to work. I have FF installed but it says
Error (RT) failed to get object. This function works with Chrome only if Firefox is installed.

And when I try it in FF it says
Error (RT) failed to get object. If using portable Firefox, look here

Im using the normal FF afaik, maybe I have to restart the pc.
#4
Macro Macro2822
Code:
Copy      Help
int w=wait(3 WV win(" - YouTube - Google Chrome" "Chrome_WidgetWin_1"))

;find the nearest common ancestor object, not DOCUMENT
Acc aParent.Find(w "STATICTEXT" "Links" "" 0x3001 3 0 "parent next")

ARRAY(Acc) aa; int i
ARRAY(str) aURL
;aParent.GetChildObjects(aa -1 "LINK" "^\S+ (Facebook|Twitter|Twitch|Instagram)$" "" 2) ;;by link name
aParent.GetChildObjects(aa -1 "LINK" "^\w+://www\.(facebook|twitter|twitch)\." "" 2) ;;by URL. Here it works because URL is in object Name, which is rare, usually URL is Value.
for i 0 aa.len
,Acc& r=aa[i]
,str name=r.Name
,str url=r.Value
,out "%-35s %s" aa[i].Name aa[i].Value
,aURL[]=url

Quote:As for the numbers, I cant get it to work.
That part does not work with newest Chrome installations because now is installed Chrome 64-bit. Need 32-bit.
But it is only one of ways of finding objects. Try this:
Macro Macro2824
Code:
Copy      Help
int w=wait(3 WV win(" - YouTube - Google Chrome" "Chrome_WidgetWin_1"))
Acc a.Find(w "PUSHBUTTON" "Subscribe" "" 0x3001 3 0 "next first")
#5
Thanks again!

I used that and now I encountered another problem with getting the URLs.
Sometimes the link is no "www" in the URL (have some problems here posting URLS).
So it doesnt work with those URLs. I tried to modify the search but I failed miserably Smile
How can I change the code to get it to work with those shorter URLs?


As for the subscriber numbers, I always get this message
Error (RT) in <open ":1576: /77">Macro3: object not found.

I looked threw the page with the "Find accesible options, wait" tool and got this.

[Image: qhA6eKT.png]

So jackpot! But I couldnt find a way to search for this specific STATICTEXT.
When I click "OK" it copies the number in the parameters and searches for them.

Is there a way to target that specific object without having to know the exact numbers?
Maybe by finding an object just before this one and then "next first".
#6
In that code I used other object, near the top-right by the red Subscribe button, which probably does not exist if you are subscribed.

Find this object in the same way: find an adjacent object that has stable text and then use the Navigate field in the dialog. For example, capture "subscribers" and then use "previous" in Navigate.
#7
Hmm I cant seem to get it to work

Macro Macro2
Code:
Copy      Help
int w1=wait(3 WV win("" "Chrome_WidgetWin_1"))
Acc a.Find(w1 "STATICTEXT" " subscribers" "xy=119 508[]state=0x0 0[]level=0 1000" 0x3005 3 0 "previous")
str s=a.Description
str e=a.Value
int n=val(s)
int n1=val(e)
out n1
out n

It just gives out a "0". I tried to vary it a bit with adding a.Value but the result is the same.
Maybe it doesnt work because its not a Button? For the views there is no Button unfortunately
But I think he finds the object.

One other way that might be easier could be to ctr+a the page and then work with getsel.
But I dont know how I could then extract specific parts of that text?
#8
Macro Macro2701
Code:
Copy      Help
int w=wait(3 WV win("" "Chrome_WidgetWin_1"))
Acc a.Find(w "STATICTEXT" " subscribers" "" 0x3001 3 0 "previous")
str s=a.Name
out s ;;2,760,003
#9
Macro Get Subscribers and Viewers Chrome
Code:
Copy      Help
out
int w=wait(10 WV win("M3RKMUS1C - YouTube - Google Chrome" "Chrome_WidgetWin_1"))
Acc a.FindFF(w "div" "" "class=about-stats" 0x1004 3 0 "first")
out F"Subscribers = {a.Name}"
a.FindFF(w "div" "" "class=about-stats" 0x1004 3 0 "first next next next")
out F"Viewers = {a.Name}"
#10
Thanks very much! It works flawless now.

However there is one thing. Sometimes the /about page on youtube varies.
E.g. if the youtuber didnt enter an about text, the "Acc .Find" function cant find the views anymore.
I think the object is on a different position, so I get an error and the macro stops.

Is there a way to just ignore this and move on?
I tried with this:
Macro Macro3
Code:
Copy      Help
Acc a.Find(w2 "STATICTEXT" " subscribers" "" 0x3001 3 0 "previous"); err continue

But then the macro just started again. Instead what I want it to do, is to just skip this part,
Or even better search for a different object instead.

How can I do this?

@Start_Learning
Thanks! I cant use the FindFF function right now though.
#11
Acc a.Find(w2 "STATICTEXT" " subscribers" "" 0x2001 0 0 "previous")
if a.NotFound
,a.Find(w2 other object)


Forum Jump:


Users browsing this thread: 1 Guest(s)