Giter VIP home page Giter VIP logo

Comments (10)

cybardev avatar cybardev commented on July 20, 2024 5

Does anybody know on how to get peertube api? Or we can scrape the site just like youtube.

I think we can just scrape it.

Edit: Sepia search is a search engine for peertube, so I assume we can definitely scrape it like YouTube.

That being said I'd also like support for:

Maybe there can be a flag that brings up a menu that lists different video sources like YT, LBRY, etc. and when the user selects one of them, it presents a prompt where user enters search string and presses Enter and then ytfzf will behave just as it is now, but for the chosen site.

from ytfzf.

hp77-creator avatar hp77-creator commented on July 20, 2024 3

Yea flag will keep the logic modular for diff. websites. and also break less as new sites are added.

from ytfzf.

qoheniac avatar qoheniac commented on July 20, 2024 3

Actually, Sepia Search has a JSON API that can be used like this:

https://sepiasearch.org/api/v1/search/videos?search=stallman

I don't know where this is documented, but I found it in NewPipe’s code.

Edit: I was told that Sepia Search uses an empty PeerTube instance as a search backend. So the API is documented here.

from ytfzf.

Toasterbirb avatar Toasterbirb commented on July 20, 2024 2

Also invidious would be nice to be supported as an alternative source for youtube videos. It should work without javascript as well, so getting the results should be fairly simple.

from ytfzf.

pystardust avatar pystardust commented on July 20, 2024 1

Noted. We will add this to the TODO's and add sites one by one

from ytfzf.

Euro20179 avatar Euro20179 commented on July 20, 2024 1

wow, nice, I will be trying to implement this.

from ytfzf.

pystardust avatar pystardust commented on July 20, 2024

Sounds interesting, just found out that you can play peertube videos with mpv and ytdl. I will need to go throught the peertube api.
Does anybody know on how to get peertube api? Or we can scrape the site just like youtube.

from ytfzf.

pystardust avatar pystardust commented on July 20, 2024

The current script relies on the json file from youtube's search result page.
A browser would run the javascript and render the search results.
ytfzf scrapes the contents of the java script's json, and instead of running any java script, it uses jq to parse the json object and render the video results.

from ytfzf.

qoheniac avatar qoheniac commented on July 20, 2024

I just had a few minutes to think about this an wrote a few lines to produce videos_json data like in Ytfzf's code but for Sepia Search instead of YouTube.

# query string for testing
search_query="Hello World"

scrape_pt() {
     #gets a list of videos
     videos_json=$(
     curl \
         -s "https://sepiasearch.org/api/v1/search/videos" \
         -G --data-urlencode "search=$*" |
     jq '[ .data | .[] |
         {
              title: .name,
              channel: .channel.displayName,
              duration: .duration,
              views: .views,
              date: .publishedAt,
              videoID: .uuid,
              thumbs: .thumbnailUrl
          }
     ]')
}

scrape_pt "$search_query"

# print first three entries
printf "%s" "$videos_json" | jq '[.[]][:3]'

The output of the above looks like this:

[
  {
    "title": "Hello World",
    "channel": "Main requiem channel",
    "duration": 58,
    "views": 7,
    "date": "2019-12-30T18:12:19.662Z",
    "videoID": "e3fbacb5-2add-4f45-8bec-7ee565dddc8f",
    "thumbs": "https://video.hackers.town/static/thumbnails/e3fbacb5-2add-4f45-8bec-7ee565dddc8f.jpg"
  },
  {
    "title": "Hello World",
    "channel": "Main programmingfish channel",
    "duration": 6,
    "views": 16,
    "date": "2019-07-07T13:26:01.663Z",
    "videoID": "7cf70066-7775-4d2f-a9c2-44c83fd73955",
    "thumbs": "https://tube.piweb.be/static/thumbnails/7cf70066-7775-4d2f-a9c2-44c83fd73955.jpg"
  },
  {
    "title": "4- Hello World",
    "channel": "LearnAsYouLike",
    "duration": 325,
    "views": 0,
    "date": "2020-11-15T04:00:21.357Z",
    "videoID": "a2576ad6-1efb-4f06-917b-b32bc3f44fdf",
    "thumbs": "https://diode.zone/static/thumbnails/a2576ad6-1efb-4f06-917b-b32bc3f44fdf.jpg"
  }
]

from ytfzf.

pystardust avatar pystardust commented on July 20, 2024

Thanks to @Euro20179 this has been implemented in #281 (not yet merged to master,
to use development branch ytfzf --update-unstable)
Search peertube with -P flag

from ytfzf.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.