only show first result of youtube-dl channel request - youtube-dl

I am trying to make a script that can view the latest video of a channel, my current method works but it keeps displaying all the videos.
Im wondering if it is possible to only get the first line of this youtube-dl channel request.
Input:
youtube-dl -i --get-filename -o "%(title)s, %(id)s" "youtube.com/user/pewdiepie/videos"
Current output:
WARNING: The url doesn't specify the protocol, trying with http
Saying goodbye is hard.., EOWP5Y7eErE
This illegal Swedish tradition is insane..., 8ch5LLc1z7s
My 12 Things I Can't LiveWithout., 7tB4jwvvuhQ
Lot of big changes lately.., https://www.youtube.com/watch?v=psHriqExm6U
Why I deleted the subreddit, https://www.youtube.com/watch?v=7yyjFudHYuw
Mr Beast passed me in subs.., https://www.youtube.com/watch?v=vHtqsuA8WJ4
Rating Liver Kings Apology, https://www.youtube.com/watch?v=tlNBB0jdL3w
'My mom fakes cancer', https://www.youtube.com/watch?v=wjPIcTU3AAM
Twitter Level Predator Exposed, https://www.youtube.com/watch?v=djr8j-4fS3A
Gordon Ramsey vs Fake Italian.., https://www.youtube.com/watch?v=X98VPQCE_WI
Twins wants to be Pregnant (At the same time...), https://www.youtube.com/watch?v=W27TjYZhytw
I Spent 12 Hours at a Japanese Arcade, It was weird. (Collab w_ #PewDiePie ), https://www.youtube.com/watch?v=eIbqhi5Ikq8
Dr Phil destroys Gamer boy, https://www.youtube.com/watch?v=s0d-AFtXtkM
too big waves for me.., https://www.youtube.com/watch?v=8XR9OzAeDqQ
She fell for it!, https://www.youtube.com/watch?v=LzCA5zHayyk
Does this mean Im cursed now, https://www.youtube.com/watch?v=UhjjjqmGAkI
I took my car off road ... (Oops), https://www.youtube.com/watch?v=cLFJjMokld8
^C ERROR: Interrupted by user
^ Each line for every uploaded video.
Wanted output: Saying goodbye is hard.., https://www.youtube.com/watch?v=EOWP5Y7eErE, One line and exited program
(I usually would resolve this just by placing a |head -1 at the end of the command. but the command stays active and my script is paused.)
Version: 2021.12.17
OS: debian

Related

Skip 1 second in play mp3 the first time

I'm using Rasp4 and I'm trying to let rasp speaks using gtts-cli. It works but the first time I play it skips 1 second.
I run this command:
gtts-cli -l en 'Good morning my dear friend' | mpg321 -q -
It works but the first time I run it, it misses the word Good, then if I run it again quickly after finished the first command it includes all the words, and sounds ok. If I wait for a minute and try again I get the same problem.
Then I try to create an mp3 from the gtts-cli command with this:
gtts-cli -l en 'Good morning my dear friend' --output test.mp3
Then if I play it with mpg321 I have the same problem, so it's not gtts-cli.
I try different players like play from sox but same issue.
RESOLVED: check this out:
https://raspberrypi.stackexchange.com/questions/132715/skip-1second-in-play-mp3-the-first-time/132722?noredirect=1#comment225721_132722

Twisted ssh - session execCommand implementation

Good day. I apologize for asking for obvious things because I'm writing in PHP and I know Python at the level "I started learning this yesterday". I've already spent a few days on this - but to no avail.
I downloaded twisted example of the SSH server for version 20.3 from here https://docs.twistedmatrix.com/en/twisted-20.3.0/conch/examples/. Line 162 has an execCommand method that I need to implement to make it work. Then I noticed a comment in this method "We don't support command execution sessions". Therefore, the question: Is this comment apply only to the example, or twisted library entirely. Ie, is it possible to implement this method to make the example server will work as I need?
More information. I don't think that this info is required to answer my questions above.
Why do I need it? I'm trying to compile an environment for writing functional (!) tests (there would be no such problems with the unit tests, I guess). Our API uses the SSH client (phpseclib / SSH2) by 30%+ of endpoints. Whatever I do, I had only 3 options of the results depending on how did I implement this method: (result: success, response: "" - empty; result: success, response: "1"; result: failed, response: "Unable to fulfill channel request at… SSH2.php:3853"). Those were for an SSH2 Client. If the error occurs (3rd case), the server shows logs in the terminal:
[SSHServerTransport, 0,127.0.0.1] Got remote error, code 11 reason: ""
[SSHServerTransport, 0,127.0.0.1] connection lost
I just found this works:
def execCommand(self, protocol, cmd):
protocol.write('Some text to return')
protocol.session.conn.sendEOF(protocol.session)
If I don't send EOF the client throws a timeout error.

Poloniex & websockets

===SIMPLE & SHORT===
Does anybody have working application that talks with Poloniex through WAMP in these days (January, 2018)?
===MORE SPECIFIC===
I used several info sources to make it work using combo: autobahn-cpp & C++. Windows 10 OS.
I was able to connect to wss://api.poloniex.com, realm1. Plus I was able to subscribe and get subscription ID. But I never got any events even when everything established.
===RESEARCH===
During research in the web I saw a lot of controversial information:
1. Claims, that wss://api2.poloniex.com should be used, and channels names are actually numbers - How to connect to poloniex.com websocket api using a python library
2. This answer gave me base code, but I am getting anything more than just connections, also by following this answer - wss://api.poloniex.com is correct address - Connecting to Poloniex Push-API
3. I saw post (sorry, lost the link), there were comments made that websockets implementation are basically broken on poloniex. They were posted 6 months ago.
===SPECS===
1. Windows 10
2. Autobahn-Cpp
3. wss://api.poloniex.com:443 ; realm1
4. Different subscriptions: ticker, BTC_ETH, 148, 1002, etc..
5. Source code I got from here
===WILL HELP AS WELL===
Is there any way to get all valid subscriptions or, probably, those, that have more than 0 subscribers? I mean, does WAMP have a way to do that?
Is there any known issues with Autobahn-Cpp and poloniex combo?
Is there any simpler way to test WAMP elsewhere to make sure Autobahn isn't a problem? Like any other well documented & supported online projects that accept WAMP websocket communication?
I can receive the correct tick order book data from wss://api2.poloniex.com use python3
but sometime The channel 1002 may stop sending the new tick info.
wss://api.poloniex.com:443 ; realm1
This may be the issue as I've been using api2 and here is the code that works, and has been working for the past 2 quarters non-stop. Its in python, but should be easy enough to port to C++.
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import websocket
import json
def on_error(ws, error):
print(error)
def on_close(ws):
print("### closed ###")
connection.close()
def on_open(ws):
print("ONOPEN")
ws.send(json.dumps({'command':'subscribe','channel':'BTC_ETH'}))
def on_message(ws, message):
message = json.loads(message)
print(message)
websocket.enableTrace(True)
ws = websocket.WebSocketApp("wss://api2.poloniex.com/",
on_message = on_message,
on_error = on_error,
on_close = on_close)
ws.on_open = on_open
ws.run_forever()
the code is pretty much self-explanatory (You can check all channels/pairs on Poloniex API website), just save it and run in terminal
python3 fileName.py
should provide You with BTCETH raw stream of orders and trades on console output.
Playing with the message/subscriptions You can then do as You please with it.
It seems that websockets in Poloniex are unstable. Therefore I can stop my attempts make Autobahn-Cpp work with it at least by now and move on.

Playing flv files from Cloudfront/S3 with Strobe Media Playback

I'm using the OSMF's Strobe Media Playback player to try and play files from AWS Cloudfront/S3
The bucket is called ct.recorder. The cloudfront distribution is called 1dm7svtk8jb00c.cloudfront.net, and it's origin is ct.recorder.
The video within the bucket is called vid_test001
I've tried initializing the player with rtmp://s34osaecrafusl.cloudfront.net/cfx/st/vid_test001
But that doesn't work.
I get Connection attempt rejected by FMS server. Connection failed.
I've also tried it with .flv at the end, but that doesn't work either.
Am I not linking to the file properly, or is it my player?
Well, I had an entire answer written up, speculating that it was related to bucket permissions, and now I'm scratching that answer and posting this, instead. :)
$ rtmpdump -r rtmp://s34osaecrafusl.cloudfront.net/cfx/st/vid_test001.flv -o testfile.flv
RTMPDump v2.4
(c) 2010 Andrej Stepanchuk, Howard Chu, The Flvstreamer Team; license: GPL
Connecting ...
WARNING: HandShake: client signature does not match!
INFO: Connected...
Starting download at: 0.000 kB
INFO: Metadata:
INFO: duration 13.82
INFO: videocodecid 2.00
INFO: audiocodecid 6.00
INFO: canSeekToEnd FALSE
INFO: createdby AMS 5
INFO: creationdate Tue Dec 03 13:41:46 2013
1190.238 kB / 13.82 sec (100.0%)
Download complete
This actually works for me... both with, and without, the .flv on the end, and the resulting file is a 7 second video of a guy looking at a webcam.
Using "smplayer" for Windows, I can connect to cloudfront with the rtmp:// url and stream the video, but it only works without the .flv on the end, using:
MPlayer Redxii-SVN-r36243-4.6.3 (C) 2000-2013 MPlayer Team
Custom build by Redxii, http://smplayer.sourceforge.net
Compiled against FFmpeg version N-52798-gf5846dc
Build date: Sun May 5 23:51:25 EDT 2013
This doesn't quite answer your question of why it isn't working, except to say that your player seems to be lying to you as far as "Connection attempt rejected by FMS server" because, at least from here, it's good, except for this part, and I don't know what it means.
WARNING: HandShake: client signature does not match!
However, that could just be a distraction.
It looks as if it's going to be your player... so trying other players would be worthwhile.
It is, of course, possible, that there's a regional issue involving the particular edge location inside cloudfront that you access from your location, which could be significantly different than the one I'm hitting, since it's geographically... but if another player works where you are, then you may have the answer you're looking for. Firing up wireshark and analyzing the protocol exchange could be an interesting exercise also.
Afterthought: the extra slash in your path could also be blowing something's mind, since an RTMP url apparently consists of two distinct components, "application"/"stream_name" and the point of delineation may be ambiguous at some level to some component in the chain. If cloudfront thinks the "application" is "cfx" and the stream is "st/vid_test001" but the client assumes the "application" is "cfx/st" with stream name "vid_test001" it seems like there could be some potential for interoperability trouble there. This is wild speculation, but perhaps worth experimentation, too.
The embed parameter urlIncludesFMSApplicationInstance needs to be set to true.

Bizarre Issue with Hash object returned from Koala

I am receiving Hash object of facebook feed using Koala gem, but I am encountering an issue.
The Hash object that is returned is as follows:
{"post_id"=>"19292868552_356643851019175", "message"=>"Tune in tomorrow, January 11 at 12 PM PST / 3 PM EST / 8 PM GMT to join Facebook Live from the Consumer Electronics Show. We will be discussing some of the best social applications and gadgets with people who built them. Watch the video and share your questions on Facebook Live - facebook.com/facebooklive.", "attachment"=>{"media"=>[{"href"=>"http://facebook.com/facebooklive", "alt"=>"", "type"=>"link", "src"=>"http://external.ak.fbcdn.net/safe_image.php?d=AQCkZ2fRUjE2ofi5&w=90&h=90&url=http%3A%2F%2Fprofile.ak.fbcdn.net%2Fhprofile-ak-snc4%2F195784_150984694912422_7311456_n.jpg"}], "name"=>"Facebook Live", "href"=>"http://facebook.com/facebooklive", "caption"=>"www.facebook.com", "description"=>"Facebook Live is Facebook’s official live video streaming channel, provide a deeper look into our...", "properties"=>[], "icon"=>"http://static.ak.fbcdn.net/rsrc.php/v1/yD/r/aS8ecmYRys0.gif", "fb_object_type"=>""}}
Now, when I try to access the Hash object's link as follows:
<hash-object>["attachment]["media"][0]["href"]
I get the following error:
undefined method []' for nil:NilClass
I tried to debug the error with the following observations:
<hash-object>["attachment]["media"][0].class # Hash (still it says undefined method[] for NilClass)
Also, when I run it in the command line it does not throw any error. I am confused with this issue as it does not make any sense(i.e. working in command line and not in Sinatra).
Things I have tried:
JSON.parse(<hash-object>.to_json) # to re-create the Hash Object
And I am able to fetch the objects before the following without any error:
post["attachment"]["media"][0] # it returns the output as it should be
Thanks in advance.