Module: Tools::API
- Included in:
- Tools
- Defined in:
- lib/tools/api.rb
Constant Summary collapse
- CREATE_REQUIRED_KEYS =
i(announceURL source output pieceSize)
- TRANSCODE_REQUIRED_KEYS =
i(formats source output)
Instance Method Summary collapse
-
#create(config_path) ⇒ Object
Create .torrent files for each entry in the config manifest.
-
#transcode(config_path) ⇒ Object
Transcode all FLAC files to the desired formats.
Instance Method Details
#create(config_path) ⇒ Object
Create .torrent files for each entry in the config manifest
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/tools/api.rb', line 10 def create(config_path) # Get a Hash from the config JSON config = read_config(config_path, :create) # Get path for the manifest (secondary) file manifest = relative_config_path(config_path, config['manifest']) # Initialize .torrent Creator creator = Actions::Create.new( manifest: manifest, announce: config['announceURL'], source: config['source'], output: config['output'], piece_size: config['pieceSize'], privacy: config['private'] ) # Create torrents creator.execute end |
#transcode(config_path) ⇒ Object
Transcode all FLAC files to the desired formats
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/tools/api.rb', line 33 def transcode(config_path) config = read_config(config_path, :transcode) # Format keys and their manifest files format_configuration = config['formats'] # Relativize all paths relative_configuration = format_configuration.map do |key, manifest_path| [key, relative_config_path(config_path, manifest_path)] end.to_h # Format objects formats = Tools::Formats::Format.create_from_configuration(relative_configuration) # Initialize file transcoder transcoder = Actions::Transcode.new( manifests: formats, source: config['source'], output: config['source'] ) # Transcode all formats transcoder.execute end |