1
0
mirror of https://github.com/shimunn/aria2xspf.git synced 2023-11-17 09:27:54 +01:00

4 Commits

Author SHA1 Message Date
5ef68507b8 update image
All checks were successful
continuous-integration/drone/push Build is passing
2019-06-08 20:07:31 +02:00
f2972cc688 prevent user from overriding source file 2019-06-08 20:05:28 +02:00
8a1b718709 prevent user from overrriding source file 2019-06-08 20:04:24 +02:00
shimunn
35b01ba152 drone
Some checks are pending
continuous-integration/drone/push Build is passing
2019-06-02 01:17:29 +02:00
2 changed files with 68 additions and 6 deletions

54
.drone.yml Normal file
View File

@@ -0,0 +1,54 @@
kind: pipeline
name: default
steps:
- name: test
image: rust:1.35.0
environment:
CARGO_HOME: /drone/.cargo
commands:
- cargo test
- name: fmt
image: rust:1.35.0
environment:
CARGO_HOME: /drone/.cargo
commands:
- rustup component add rustfmt
- cargo fmt -- --check
- name: clippy
image: rust:1.35.0
environment:
CARGO_HOME: /drone/.cargo
commands:
- rustup component add clippy
- cargo clippy
- name: build_relase
image: rust:1.35.0
environment:
CARGO_HOME: /drone/.cargo
commands:
- mkdir bin
- export CARGO_INSTALL_ROOT=$PWD
- rustup target add x86_64-unknown-linux-musl
- cargo install --path . --target x86_64-unknown-linux-musl
- mkdir dist
- tar cvzf binary.tar.gz bin/*
when:
event:
- tag
- name: gitea_release
image: plugins/gitea-release
settings:
api_key:
from_secret: gitea_tkn
base_url:
from_secret: gitea_url
files:
- binary.tar.gz
checksum:
- md5
- sha512
when:
event:
- tag

View File

@@ -11,13 +11,13 @@ mod conf;
mod opts;
use conf::*;
use dirs;
use opts::*;
use std::env;
use std::fs::File;
use std::io::{self, Read, Write};
use std::io::{self, Read, Stdin, Write};
use std::io::{BufRead, BufReader};
use dirs;
use std::process::exit;
use xml::writer::{EmitterConfig, EventWriter, Result as XResult, XmlEvent};
#[derive(Builder, Debug)]
@@ -82,6 +82,14 @@ fn config() -> Option<Config> {
fn main() {
let opts = Opts::from_args();
if opts.input == opts.output {
eprintln!("Input and output are the same file! {:?}\nContinue(y/n): ", opts.input);
match io::stdin().bytes().next() {
Some(Ok(r)) if r as char == 'y' => (),
Some(Ok(_)) => exit(1),
_ => (), //Stdin closed, assume in == out is intentional
}
}
let file = File::open(opts.input).expect("Failed to open file!");
let mut out = File::create(opts.output).expect("Failed to open OUTPUT file!");
let mut writer = EmitterConfig::new().perform_indent(true).create_writer(&mut out);
@@ -108,8 +116,8 @@ fn convert<I: Iterator<Item = Track>, W: Write>(html: bool, tracks: I, w: &mut E
.attr("type", "text/javascript")
.attr("src", url),
)?;
w.write(XmlEvent::characters(""))?;
w.write(XmlEvent::end_element())?;
w.write(XmlEvent::characters(""))?;
w.write(XmlEvent::end_element())?;
}
for url in CONFIG.include.css.iter() {
w.write(
@@ -118,7 +126,7 @@ fn convert<I: Iterator<Item = Track>, W: Write>(html: bool, tracks: I, w: &mut E
.attr("href", url),
)?;
w.write(XmlEvent::characters(""))?;
w.write(XmlEvent::end_element())?;
w.write(XmlEvent::end_element())?;
}
w.write(XmlEvent::end_element())?;
}