Skip to content

Instantly share code, notes, and snippets.

@Reino17
Reino17 / so_2611418.txt
Created September 7, 2023 14:07
Turn the "Men's records"-table into "|"-separated values and white-space aligned columns
Turn the "Men's records"-table into "|"-separated values:
$ xidel -s "https://en.wikipedia.org/wiki/List_of_Olympic_records_in_athletics" -e '
(//table)[1]/tbody/tr/join(
(td|th) ! normalize-space( (: For every text-node remove the :)
join(.//text() ! replace(.," ","")) (: no-break-spaces, string-join :)
), (: them together and remove :)
" | " (: excessive white-space. :)
)
'
@Reino17
Reino17 / ttml-to-srt_xidel.txt
Created November 15, 2021 22:08
Convert TTML examples from https://trac.ffmpeg.org/ticket/4859 to SRT with Xidel (in Bash)
$ xidel -s "https://trac.ffmpeg.org/ticket/4859" -e '//dt/a[@class="trac-rawlink"]/@href'
/raw-attachment/ticket/4859/MDR%20Exakt%2C%20die%20Story%20(20150617)%20-%20Das%20Kita-Versprechen--Anspruch%20und%20Wirklichkeit%20(720p%2C%20MDR).ttml
/raw-attachment/ticket/4859/Vorstadtweiber%20(Folge%2006%2C%20S01E06%2C%209.%20Feb.%202015)%20-%20Schamlos%20(720p%2C%20SRF).ttml
/raw-attachment/ticket/4859/narvestad_pC%25_tur_23_24-muhh59002316aw.ttml
/raw-attachment/ticket/4859/Still%20Open%20All%20Hours.ttml
$ xidel -s "https://trac.ffmpeg.org/ticket/4859" -e '//dt/a[@class="trac-rawlink"]/uri-decode(extract(@href,".+/(.+)",1))'
MDR Exakt, die Story (20150617) - Das Kita-Versprechen--Anspruch und Wirklichkeit (720p, MDR).ttml
Vorstadtweiber (Folge 06, S01E06, 9. Feb. 2015) - Schamlos (720p, SRF).ttml
narvestad_pC%_tur_23_24-muhh59002316aw.ttml
$ xidel -se 'json-doc("Input1.json")(),json-doc("Input2.json")()'
{
"A": "Name 1",
"B": "1.1",
"C": "2"
}
{
"A": "Name 2",
"B": "3.2",
"C": "4"
@Reino17
Reino17 / collegerama_xidel-ffmpeg.txt
Created May 14, 2021 16:29
Extract and download videos from Collegerama with Xidel and/or FFmpeg
SET url=https://collegerama.tudelft.nl/Mediasite/Play/585a43626e544bdd97aeb71a0ec907a01d?catalog=fd32fd35-6c99-466c-89d4-cd3c431bc8a4
------------------------------------------------------------------------------------------------
[JSON post data preparation]
"QueryString" is not really necessary.
xidel -se "('%url%',substring-before('%url%','?')) ! serialize({'getPlayerOptionsRequest':{'ResourceId':extract(.,'.+/([\da-z]+)',1),'QueryString':extract(.,'\?.+')}},{'method':'json'})"
{"getPlayerOptionsRequest":{"ResourceId":"585a43626e544bdd97aeb71a0ec907a01d","QueryString":"?catalog=fd32fd35-6c99-466c-89d4-cd3c431bc8a4"}}

Directory structure:

dir1\image.jpg
dir1\image.png
dir2\image.jpg
dir2\image.png
image.jpg
image.png

Let's say we have the following JSON...

{
  "a": "b",
  "c": [
    {
      "x": 1,
      "y": 2,
      "z": 3
 }
$ xidel -s so_24300508.csv -e '$raw'
Africa,Kenya,NAI,109
Africa,Kenya,NAA,160
Asia,India,NSI,100
Asia,India,BSE,60
Asia,Pakistan,ISE,120
Asia,Pakistan,ANO,433
European Union,United Kingdom,LSE,550
European Union,United Kingdom,PLU,123
'genesis.json':
{
"alloc": {
"0xca843569e3427144cead5e4d5999a3d0ccf92b8e": {
"balance": "1000000000000000000000000000"
},
"0x0fbdc686b912d7722dc86510934589e0aaf3b55a": {
"balance": "1000000000000000000000000000"
},
"0x9186eb3d20cbd1f5f992a950d808c4495153abd5": {
$ xidel -s https://www.anekalogam.co.id/id -e '$raw' > anekalogam.htm
$ xidel -s anekalogam.htm -e '//div[@class="product-box"]//span[@class="n-heading"]'
Rp 905.000
Rp 830.000
Rp 1.750.000
Rp 1.660.000
Rp 2.595.000
Rp 2.490.000
Rp 4.295.000