grastello / ytel

Youtube "front-end" for Emacs
GNU General Public License v3.0
48 stars 10 forks source link

Search for channels? #8

Open johnhamelink opened 4 years ago

johnhamelink commented 4 years ago

It'd be nice if this tool could be use to find and "subscribe" to channels by retrieving their channel ID and returning an RSS feed URL, ready to be pasted into - for example - org-elfeed.

pablobc-mx commented 4 years ago

I wrote a function to do this. I bound it to "Y", because I have another one to copy the url of the video. Here:

(defun ytel-yank-channel-feed (&optional arg)
    "Yank channel's Invidious RSS feed for the current video at point.
          If ARG is given, format it as a Youtube RSS feed."
    (interactive "P")
    (let* ((author (ytel-video-author (ytel-get-current-video)))
       (authorId (ytel-video-authorId (ytel-get-current-video)))
       (url (if arg
                    (concat "https://www.youtube.com/feeds/videos.xml?channel_id=" authorId)
                  (concat "https://invidio.us/feed/channel/" authorId))))
      (kill-new url)
      (message "Copied RSS feed for: %s -- %s" author url)))

I don't know if this functionality should be included by default, since it's meant to be minimalist, but it sure would be nice to add more to the base functionality.

johnhamelink commented 4 years ago

That looks great, I’ll try it out first thing in the morning, thanks! 👍🏻

grastello commented 4 years ago

I was indeed thinking about writing some sort of channel-searcher. Ideally it should give back the same buffer that you get by searching for videos but with channels in it. Then it should be possible to extract an rss feed from that buffer pretty much as @pablobc-mx did above. At that point it should also make sense to have some way to list all the videos of a selected channel.

Everything I described shouldn't be that hard to implement, but unfortunately I can't do it right now as I'm quite busy irl.

johnhamelink commented 4 years ago

@pablobc-mx, so I tried out your function and it works well - one question though, how would I trigger the arg with a keybinding?

I'm currently using:

(evil-define-key 'normal ytel-mode-map "y" #'ytel-yank-channel-feed)
pablobc-mx commented 4 years ago

@johnhamelink If you want to keep the function as it is, the you can wrap it inside a lambda like this:

(evil-define-key 'normal ytel-mode-map "y" #'(lambda ()
                           (interactive)
                           (ytel-yank-channel-feed t)))

But if you don't have a use for the Invidious style feed, or prefer the youtube style one, I'd suggest switching the if clauses around or dropping it from the function instead. The reason I prefer Invidious RSS feeds is because they add more content to each item in the feed, like video description and a thumbnail.

@gRastello

Everything I described shouldn't be that hard to implement, but unfortunately I can't do it right now as I'm quite busy irl.

I've been working on something similar on my fork, but it's still rough around the edges and missing a few features. I can work on some of the features you mentioned and you can just review everything is alright.

grastello commented 4 years ago

@pablobc-mx

Well if you're already working on it I'm all for a pull request when it will be ready!

johnhamelink commented 4 years ago

Thank you both! I look forward to pulling down that merged PR, no pressure :sweat_smile:

pablobc-mx commented 4 years ago

So I've made some progress, in regards to searching channels and playlists. You can choose what type of results you want: Playlists Screenshot_2020-06-30_00-34-56 Channels Screenshot_2020-06-30_00-35-12 Or all (this one doesn't look as good and I haven't found a way to make it better). Screenshot_2020-06-30_00-38-17 I've also made a few functions to change the type of results quickly, and a sorting function. Screenshot_2020-06-30_00-57-11

And as a little extra, I added the option to "prettify" the buffer using unicode icons. Screenshot_2020-06-30_00-39-44

I'm currently working on the option to "open" videos, playlists or channels inside ytel. For example, Pressing enter over a video should open a buffer with information about the video. Opening a playlist will show videos from it, and the same for a channel. I currently have the channel one, which looks like this. Screenshot_2020-06-30_01-04-43 Let me now what you think! I'll try to finish ASAP. In the meanwhile, you can find the code on my branch By the way @gRastello, can you review the PR I made a few days ago? It's a minor one that fixes a few issues with the page switching, plus some visual changes.

johnhamelink commented 4 years ago

@pablobc-mx wow, this looks fantastic! I'll check it out and let you know :)

grastello commented 4 years ago

@pablobc-mx

All seems pretty cool so far. I'll review that PR right now

johnhamelink commented 4 years ago

So I tried this out, and it works nicely :)

Here's the config I ended up with:

(defun ytel-watch ()
  "Stream video at point in mpv."
  (interactive)
  (let* ((video (ytel-get-current-video))
         (id    (ytel-video-id video))
         (video-api-url (start-process "ytel mpv" nil "mpv" (concat "https://invidio.us/watch?v=" id))))))

(evil-define-key 'normal ytel-mode-map "v" #'ytel-watch)

(evil-define-key 'normal ytel-mode-map "q" #'ytel-quit)
(evil-define-key 'normal ytel-mode-map "h" #'describe-mode)
(evil-define-key 'normal ytel-mode-map "s" #'ytel-search)
(evil-define-key 'normal ytel-mode-map ">" #'ytel-search-next-page)
(evil-define-key 'normal ytel-mode-map "<" #'ytel-search-previous-page)
(evil-define-key 'normal ytel-mode-map "t" #'ytel-search-type)
(evil-define-key 'normal ytel-mode-map "S" #'ytel-sort-videos)
(evil-define-key 'normal ytel-mode-map "C" #'ytel-show-channels)
(evil-define-key 'normal ytel-mode-map "P" #'ytel-show-playlists)
(evil-define-key 'normal ytel-mode-map "V" #'ytel-show-videos)
(evil-define-key 'normal ytel-mode-map "Y" #'(lambda () (interactive) (ytel-yank-channel-feed t)))
pablobc-mx commented 4 years ago

@gRastello, just made a PR for this, and I think it's ready. Let me now what you think!

johnhamelink commented 4 years ago

I just made this function to add to my ytel configuration. Hope it's useful :smile:

(defun ytel-yank-video ()
  "Yank video URL on point"
  (interactive)
  (let* ((video (ytel-get-current-video))
         (id (ytel-video-id video))
         (url (concat "https://invidio.us/watch?v=" id)))
  (kill-new url)
  (message "Yanked video: %s" url)))
(evil-define-key 'normal ytel-mode-map "y" #'ytel-yank-video)