Ruby gem for retrieving details/information on a torrent via info hash - ruby

Is there a ruby gem that I can use with Ruby or Ruby on Rails that accepts an info hash and returns information on the torrent? Like seeders, leachers, size, etc.?
If not is there any other way I can get this information using Ruby? Is there an API that I can easily digest?
Thanks in advance.

Take a look at the thepiratebay.
Although, it seems like it's not maintained actively anymore. But, should solve your problem.
You can find a torrent:
ThePirateBay::Torrent.find("123123123")
Also, you can get all the seeders, leechers and size:
ThePirateBay::SortBy::Size # Size, largest first
ThePirateBay::SortBy::Seeders # Most seeders first
ThePirateBay::SortBy::Leechers # Most leechers first
So, why not giving it a try?

It really depends what torrents you are talking about. Different torrent trackers have different APIs.
You might want to dig into specific tracker API (please be mindful these ones are not Ruby APIs):
https://getstrike.net/api/
https://www.npmjs.com/package/thepiratebay

Related

How do I use the Ruby twitter gem to get a list of followers for a given ID/handle?

I want to use v5.0 of the Twitter gem, and I can't figure out the documentation to understand how to get a list of followers, given a handle.
It looks like previous versions had a method that looked something like Twitter.follower_ids('ID to lookup'), but that doesn't work any more.
I don't know if there's some easier way to navigate the RDoc documentation but I had to first root around in the code, to notice the RDoc comments, to then realize that this is the page which documents some of the behavior I wanted.
# configure client with secrets and access keys
client.followers 'screen_name_of_interest'
This returns a certain number of followers - but I still can't figure out how to figure out how many followers, and how to use cursors to retrieve more.

Ruby: configure_with method

I occasionally see configure_with in Ruby code but can't find any documentation for this method despite several Google searches.
For an example of configure_with see
Where to place/access config file in gem?
Any suggestions?
Here are some references:
http://rubydoc.info/github/sferik/rails_admin/RailsAdmin/Config.configure_with
http://www.ruby-doc.org/gems/docs/r/rack_gyazo-0.1.2/Rack/Gyazo.html#method-c-configure_with
http://ruby-doc.org/gems/docs/h/heroku_mongo_watcher-0.3.0/HerokuMongoWatcher/Configuration.html
Since you didn't provide nearly enough information to narrow it down, it falls on you.

How to store and find records based on location?

I'm thinking of building an application that helps you find local businesses (just an example). You might enter your zip code (or GPS if this is on a phone) and find the closest business within 10 miles, etc. My question is how can I achieve this type of logic? Is there a library or service that I will need to use? Or can this be done with math? I'm not familiar with how this sort of thing usually works, so let me know how I need to store the records so I can query them later. Note: I will be using Ruby and MongoDB.
It should be easy to find the math to solve that, providing lat/long coordinates.
Or you could use some full featured gem to do that for you like Geocoder, that supports Mongoid or MongoMapper.
Next time you need some feature that might be a commun world problem, first check if there is a gem for that at ruby-toolbox, for this case here are some other gems for geocoding
One more solution here...
http://geokit.rubyforge.org/
I think, this topic is already discussed here..

Ruby XML Parsing with Nokogiri/XPath

I have a shopify store that I want to automatically update the product variants inventory levels with, using a live xml feed from the wholesaler I use.
I'm learning to program (Ruby) and this is my first project, but after researching here is how I think it should work.
Use Ruby/Nokugiri to parse the XML feed from the wholesaler, and then Xpath to locate both the unique product variant SKU code, and the stock level.
Somehow I need to use this SKU to refer back to my Shopify store product XML list, and pull out the variants unique ID using the SKU code.
Then use something like the builder gem to build the XML format that shopify needs, and then use curl to PUT the changes. I'm guessing I loop this process for every product?
I know Shopify only has a 300 call limit, so I've got the article on putting a delay in the script, but I get the feeling the above method isn't the easiest way to go about this?
With Shopify you need to apply the variant stock level update against unique variant xml files, so I need to build the unique xml file/code and PUT it against /admin/variants/#[thevariantid].xml
I'm looking forward to trying to put this together and learning in the process, but am I on the right track with this? Are there simpler gems I should be looking at?
n.b I've only recently started learning Ruby, and will head to Rails afterwards. I know a bit about XML and it's structure so should be ok finding what I need with XPath.
You’re on the right track, but I’d use the shopify_api gem to do the talking to Shopify instead of having to form the XML and URIs yourself: https://github.com/Shopify/shopify_api
There’s an article on our wiki that might also help you out with regards to the API call limit but just let me know if you need more space – we’re pretty flexible and the limit is really just there to keep scripts from going wild and affecting service for everyone else.
Your proposed path seems good, except that there's no need to use the 'builder' gem, as Nokogiri has some very nice XML-building built into it.

Using Rack::Session::Datamapper

mkristgan's rack_datamapper gem says that it "can be wrapped to be used in a specific environement, i.e. Rack::Session::Datamapper".
Unfortunately, I don't know quite enough about Ruby to accomplish this task yet –Modules/Classes in Ruby are still above my head (coming from PHP).
Can anyone offer assistance with using rack_datamapper to implement Rack::Session::Datamapper?
You probably don't want to do this anyway.
The answer below is great, but upon closer consideration, I realized I shouldn't do it anyway. Instead, I'm placing the user_id, ip and first name (for convenience) in a cookie and protecting it.
This gem should help:
In Sinatra just add:
use Rack::Session::Moneta,
store: Moneta.new(:DataMapper, setup: (ENV['DATABASE_URL'] || "sqlite://#{Dir.pwd}/development.db"))
and use session[] object at will.

Resources