WingTillDie / youtube-video-length

Searches YouTube video with specified duration by YouTube Data API
Apache License 2.0
25 stars 5 forks source link

not working #1

Open Zzerr0r opened 1 year ago

Zzerr0r commented 1 year ago

im writing this while feeding freaking worms to my bird in password game. the output is empty for me for any number but 14:07 (same as with -t option). i even changed the behaviour of -t option to be the length that i wanted (36:14) but again empty output. idk why. otherwise great program and thanks for the effort!

WingTillDie commented 1 year ago

You can try changing your search query with -q option e.g. python youtube-video-length.py -i PT36M14S -q "36:14" has output: Video Title: Bill Holter: Global Depression Imminent - Could Gold Reach $800,000oz? Video ID: 7JSuMED9lt0 Video Duration (ISO): PT36M14S Video Duration (s): 2174 seconds image

Video Title: シビックのような動き【ホンダ ZR-V e:HEV】土屋圭市と藤木由貴が運転を楽しむ!工藤貴宏が群サイ試乗の感想まで解説 Video ID: w-5NA69TKZs Video Duration (ISO): PT36M14S Video Duration (s): 2174 seconds

Video Title: キルレを取り戻そう大作戦を決行するブライアンの「COD:WW2」スペシャル【11日目】 Video ID: IDY459Tm8dw Video Duration (ISO): PT36M14S Video Duration (s): 2174 seconds

Video Title: ボディの内側塗装とパネル類の取付で遂に車の形に!【#29 MR2 Video ID: 5KVmvef25zM Video Duration (ISO): PT36M14S Video Duration (s): 2174 seconds

WingTillDie commented 1 year ago

I fixed the bug that causes the program to crash when it encounter videos that spans days, e.g. P9DT7H36M40S by ./youtube-video-length.py -q "Youtube longest video ever 223 hours" -l

Please git pull to get the latest code that fixed the bug

Alexare8 commented 1 year ago

I think I'm having the same issue of only returning nothing, though strangely copying your exact example above does return results. But when I change only the digits to reflect the duration I'm searching for it no longer returns anything. I am using latest version.

PS C:\Users\Duncan\Desktop> python youtube-video-length.py -i PT36M14S -q "36:14"
Video Title: Bill Holter: Global Depression Imminent - Could Gold Reach $800,000oz?
Video ID: 7JSuMED9lt0
Video Duration (ISO): PT36M14S
Video Duration (s): 2174 seconds

Video Title: Why the U.S. is failing at public bathrooms | Hasanabi Reacts to AJ+ ft. BoyBoy and i did a thing
Video ID: ndxdvr-rxwE
Video Duration (ISO): PT36M14S
Video Duration (s): 2174 seconds

Video Title: 坪井勇磨(東京アート)VS 渡辺裕介(協和キリン) 2ndNov@日本卓球リーグ
Video ID: ciRQnzKmh9Q
Video Duration (ISO): PT36M14S
Video Duration (s): 2174 seconds

Video Title: キルレを取り戻そう大作戦を決行するブライアンの「COD:WW2」スペシャル【11日目】
Video ID: IDY459Tm8dw
Video Duration (ISO): PT36M14S
Video Duration (s): 2174 seconds

Video Title: Prisoner Transport Ambush vs Air One | GTA 5 OCRP
Video ID: NNK-_CbOygo
Video Duration (ISO): PT36M14S
Video Duration (s): 2174 seconds

PS C:\Users\Duncan\Desktop> python youtube-video-length.py -i PT27M17S -q "27:17"
PS C:\Users\Duncan\Desktop>
m0d1nst4ll3r commented 7 months ago

I don't know how you guys are getting these results with "36:14" as a search query, but as I understand it the query is simply the info sent to youtube's servers as to what query to search for in its dabase.

The results I do get with queries that are simply digits representing video length (e.g "36:14") have these digits in their titles, mostly. Probably because whoever uploaded it copy/pasted some encoding info that had video duration in there, as a title.

The vids you're getting don't show the digits in the titles, so idk how youtube gets those back from its database. However the fact that "27:17" for you doesn't return anything seems to indicate that youtube didn't find any videos satisfying your search terms, simply.

That means: no luck, and try something else. I found videos by searching tons of different terms (e.g "b" "k" "j" "to" "like" "instagram"), and when these terms got me results they would usually show in the title, indicating that the query does mostly work like what you'd put into youtube's searchbox when using it casually.

I guess a cool feature for this program would be not having to input anything as a query and still get 100+ results, but then probably the program would have to try its own search terms by itself, and potentially burn through your API key pretty fast. Better than doing it manually, at least.

E.g instead of a -q option, an exclusive option (-a ?) to automatically iterate through a premade list of queries until there are -m results (default 100). Not sure how to quickly populate a list of queries... maybe a list of most used english words (most used words in video titles on youtube would defo work better though).

WingTillDie commented 3 days ago

@m0d1nst4ll3r Thanks for your great explanation
If no result, the user should change the search query string to the ones that are likely to return the desired video with specified length
About your suggestion about the premade list, the list may populate strings that returns YouTube videos with diverse video length to increase the probability of satisfying the video length requirement

WingTillDie commented 3 days ago

@Zzerr0r @Alexare8 Thanks for your question
I improved the program output when no match to guide user on how to solve it
And added a flowchat on README.md

$ ./youtube-video-length.py -i PT27M17S -q "27:17"
ERROR: No match with specified filter time. Try change -q, -m arguments, or use -l to list search results without filtering by time
A search result without applying time filter:
Video Title: ჩცდ - სერია 27 (სეზონი 17)
Video ID: pN7HmdzR_po
Video Duration (ISO): PT34M35S
Video Duration (s): 2075 seconds
flowchart TD
    Query[Search String: cat funny<br>-q #34;cat funny#34;]
    Top[Top 100 Search Results<br>-m 100]
    Query --> Top
    Top --> Is_Filter
    Is_Filter{Enable Filter by Video Length?}
    Is_Filter -->|No| list[/--list/]
    Is_Filter -->|Yes| Time_Format
    Time_Format{Filter Time Format}
    Time_Format -->|seconds| Seconds
    Seconds[/--seconds/]
    Time_Format -->|ISO 8601| ISO_8601
    ISO_8601[/--iso-8601/]