![]() |
#1 |
Junior Member
![]() Posts: 8
Karma: 10
Join Date: Aug 2020
Device: kobo libre h20
|
News export to Kobo with templates
I subscribe to 120+ news sites, so after four days, there are 500 articles in one directory.
If I want to read articles from today before moving on to yesterday's news, I have to scroll and scroll and scroll. You get the picture. :-) I fought with templates for a couple of hours today, before giving up and writing a shell script. This is what I wrote: Code:
#!/bin/bash # # take care of the news files in the kobo directory # NEWSPATH="/media/rob/KOBOeReader/News/" function findNewsDir() { path=${1} if [[ -e "${path}" ]] then REPLY="yes" else REPLY="no" fi } function main() { # newsDir=findNewsDir ${NEWSPATH} findNewsDir ${NEWSPATH} if [[ ${REPLY} == "yes" ]] then echo "Found the news directory" echo "It is ${NEWSPATH}" echo "getting dates now" for date in $(ls "${NEWSPATH}" | rev | cut -f 3- -d "." | cut -f 1 -d "_" | rev | sort -u) do { echo "Date : ${date}" if [[ ! -e "${NEWSPATH}${date}" ]] then echo "date dir for ${date} does not exist" printf "making directory - %s" "${NEWSPATH}${date}/" mkdir "${NEWSPATH}${date}/" fi echo "date dir for ${date} exists" OLDIFS="${IFS}" IFS=$'\n' for article in $(ls "${NEWSPATH}" | grep ${date}.kepub.epub$) do { printf "article - %s\n" "${article}" echo "I want to move article : \"${article}\"" echo "to" echo "${NEWSPATH}${date}/" echo mv "${NEWSPATH}${article}" "${NEWSPATH}${date}/" } done IFS="${OLDIFS}" } done else echo "Cannot find the news directory, exiting" exit 1 fi } main 1. news_date : {date:'test($, strcat(format_date($,'yyyy'), '_',format_date($,'MM'), '_',format_date($,'dd')), '')'} 2. test_date : {authors:contains(calibre, {#news_date},)} I figured I would use a device template that had /{#test_date} in it, but that never seemed to work. I'm guessing at this point that there is different code paths for exporting News/ articles and other things. Thanks, Rob |
![]() |
![]() |
![]() |
#2 |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 24,905
Karma: 47303824
Join Date: Jul 2011
Location: Sydney, Australia
Device: Kobo:Touch,Glo, AuraH2O, GloHD,AuraONE, ClaraHD, Libra H2O; tolinoepos
|
What exactly are you trying to achieve? Are you trying to build a directory structure on the device? If so, that won't help if you are using the Kobo software to read the book. It doesn't use the directory structure in the interface. If you are using KOReader or Plato or something else, it might work.
For reading in the Kobo, you could create a collection for each day. When you have read all the new articles, you can remove the collection. You could do this with a custom column with the template: Code:
program: news_date = format_date(raw_field('timestamp'),'yyyy-MM-dd'); contains(field('authors'), 'calibre', news_date, ''); If you do the above, you would add the column the the "Collections columns" in the driver configuration. That should create collections for each day as you send the news articles to the device. |
![]() |
![]() |
Advert | |
|
![]() |
#3 |
Junior Member
![]() Posts: 8
Karma: 10
Join Date: Aug 2020
Device: kobo libre h20
|
I'm sorry, I wasn't clear. I am using KOReader, so one of my main interfaces to my collection is the filesystem. I am trying to make a different directory for each days' worth of news that is on the reader.
News/ News/2020-08-19/ News/2020-08-20/ News/2020-08-21/ and so on, and so forth. I run my script after the calibre sync, it creates the directories and moves everything in News/ into the appropriate subdirectory. Thank you. Last edited by biffhero; 08-21-2020 at 08:25 AM. |
![]() |
![]() |
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
News: Libre Office 6.0 - export to epub | kacir | ePub | 1 | 02-01-2018 04:39 AM |
Export single article epub from a news source | rozen | Library Management | 1 | 08-14-2016 02:55 AM |
How to send news to News and Magazines section (Kobo Glo) | gianfri | Calibre | 1 | 12-25-2012 09:21 PM |
How to export Highlights /w Kobo | ereaderundecided | Kobo Reader | 1 | 09-07-2012 03:20 AM |
how do I export my Kobo books | Zepherious | Kobo Reader | 4 | 05-29-2010 02:43 PM |