Jump to content

Reading tags from filesystem


kRyszard

Recommended Posts

kRyszard

I use emby as a server for large amount of pictures. I put all my pictures for emby to manage but I don't want some of them to be seen by my family so I tag my private folders with a tag named "priv" and I use the "block items with tags" to deny access (yes, I use parental control on my parents). However it would be more convenient for me if I could somehow add the tag from the filesystem level e.g. create a file named "folder.nfo" or similar and put the tags there. The advantage is that these files would be automatically backed up along with the content to some other drive. Other advantage: it's faster to copy a file than to click, scroll, type, click and click again in web client for every folder I want to exclude.

Link to comment
Share on other sites

Hi, there currently isn't a folder.nfo I'm afraid, although it's not a bad idea. So currently you would have to do this inside Emby with the metadata editor.

Link to comment
Share on other sites

  • 5 weeks later...
kRyszard

Decided to write a script that crawls inside my filesystem, reads files with tags and uses emby rest interface to set/unset tags.

Link to comment
Share on other sites

mastrmind11

Decided to write a script that crawls inside my filesystem, reads files with tags and uses emby rest interface to set/unset tags.

Perhaps you can clean it up and share it for others that might find it useful?

Link to comment
Share on other sites

  • 1 month later...
kRyszard

Hello, I have finished the program I mentioned. This prog crawls the Emby repositories and for every folder it visits it checks for a presence of a special file that causes a tag called "priv" to be put on the folder. This tag is then used for parental control for some users i.e. blocks access to the folders containing a special file.

 

Github: https://github.com/mr-rycho/embian

Bin: http://kryszard.vot.pl/embian/embian.01.zip

Link to comment
Share on other sites

  • 2 weeks later...

Oh great @@kRyszard it seems that this is exactly what I want. Can I write other tags? And how to use it? I'm on pure linux debian...
 
Can I mass write tags? Like for all episodes of a tvseries?
 
EDIT: Ok got it, but can't login:

java -jar embian.jar --host "http://192.168.177.98" --pass xxx --user xxx browse
Exception in thread "main" javax.ws.rs.ProcessingException: java.net.UnknownHostException: 192.168.177.98Users
        at org.glassfish.jersey.client.internal.HttpUrlConnector.apply(HttpUrlConnector.java:287)
        at org.glassfish.jersey.client.ClientRuntime.invoke(ClientRuntime.java:253)
        at org.glassfish.jersey.client.JerseyInvocation$1.call(JerseyInvocation.java:759)
        at org.glassfish.jersey.client.JerseyInvocation$1.call(JerseyInvocation.java:756)
        at org.glassfish.jersey.internal.Errors.process(Errors.java:315)
        at org.glassfish.jersey.internal.Errors.process(Errors.java:297)
        at org.glassfish.jersey.internal.Errors.process(Errors.java:228)
        at org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:407)
        at org.glassfish.jersey.client.JerseyInvocation.invoke(JerseyInvocation.java:756)
        at org.glassfish.jersey.client.JerseyInvocation$Builder.method(JerseyInvocation.java:443)
        at org.glassfish.jersey.client.JerseyInvocation$Builder.post(JerseyInvocation.java:349)
        at pl.rychu.embian.emby.EmbyClientFactory.authenticate(EmbyClientFactory.java:35)
        at pl.rychu.embian.Main.lambda$main$0(Main.java:63)
        at pl.rychu.embian.browse.Browse.exec(Browse.java:35)
        at pl.rychu.embian.Main.main(Main.java:79)
Caused by: java.net.UnknownHostException: 192.168.177.98Users
        at java.net.AbstractPlainSocketImpl.connect(Unknown Source)
        at java.net.PlainSocketImpl.connect(Unknown Source)
        at java.net.SocksSocketImpl.connect(Unknown Source)
        at java.net.Socket.connect(Unknown Source)
        at sun.net.NetworkClient.doConnect(Unknown Source)
        at sun.net.www.http.HttpClient.openServer(Unknown Source)
        at sun.net.www.http.HttpClient.openServer(Unknown Source)
        at sun.net.www.http.HttpClient.<init>(Unknown Source)
        at sun.net.www.http.HttpClient.New(Unknown Source)
        at sun.net.www.http.HttpClient.New(Unknown Source)
        at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(Unknown Source)
        at sun.net.www.protocol.http.HttpURLConnection.plainConnect0(Unknown Source)
        at sun.net.www.protocol.http.HttpURLConnection.plainConnect(Unknown Source)
        at sun.net.www.protocol.http.HttpURLConnection.connect(Unknown Source)
        at sun.net.www.protocol.http.HttpURLConnection.getOutputStream0(Unknown Source)
        at sun.net.www.protocol.http.HttpURLConnection.getOutputStream(Unknown Source)
        at org.glassfish.jersey.client.internal.HttpUrlConnector$4.getOutputStream(HttpUrlConnector.java:390)
        at org.glassfish.jersey.message.internal.CommittingOutputStream.commitStream(CommittingOutputStream.java:200)
        at org.glassfish.jersey.message.internal.CommittingOutputStream.commitStream(CommittingOutputStream.java:194)
        at org.glassfish.jersey.message.internal.CommittingOutputStream.write(CommittingOutputStream.java:228)
        at org.glassfish.jersey.message.internal.WriterInterceptorExecutor$UnCloseableOutputStream.write(WriterInterceptorExecutor.java:299)
        at sun.nio.cs.StreamEncoder.writeBytes(Unknown Source)
        at sun.nio.cs.StreamEncoder.implFlushBuffer(Unknown Source)
        at sun.nio.cs.StreamEncoder.implFlush(Unknown Source)
        at sun.nio.cs.StreamEncoder.flush(Unknown Source)
        at java.io.OutputStreamWriter.flush(Unknown Source)
        at org.glassfish.jersey.message.internal.ReaderWriter.writeToAsString(ReaderWriter.java:193)
        at org.glassfish.jersey.message.internal.AbstractMessageReaderWriterProvider.writeToAsString(AbstractMessageReaderWriterProvider.java:130)
        at org.glassfish.jersey.message.internal.AbstractFormProvider.writeTo(AbstractFormProvider.java:116)
        at org.glassfish.jersey.message.internal.FormProvider.writeTo(FormProvider.java:112)
        at org.glassfish.jersey.message.internal.FormProvider.writeTo(FormProvider.java:66)
        at org.glassfish.jersey.message.internal.WriterInterceptorExecutor$TerminalWriterInterceptor.invokeWriteTo(WriterInterceptorExecutor.java:265)
        at org.glassfish.jersey.message.internal.WriterInterceptorExecutor$TerminalWriterInterceptor.aroundWriteTo(WriterInterceptorExecutor.java:250)
        at org.glassfish.jersey.message.internal.WriterInterceptorExecutor.proceed(WriterInterceptorExecutor.java:162)
        at org.glassfish.jersey.message.internal.MessageBodyFactory.writeTo(MessageBodyFactory.java:1126)
        at org.glassfish.jersey.client.ClientRequest.doWriteEntity(ClientRequest.java:517)
        at org.glassfish.jersey.client.ClientRequest.writeEntity(ClientRequest.java:499)
        at org.glassfish.jersey.client.internal.HttpUrlConnector._apply(HttpUrlConnector.java:393)
        at org.glassfish.jersey.client.internal.HttpUrlConnector.apply(HttpUrlConnector.java:285)
        ... 14 more

EDIT: Got it but now other error:

java -jar embian.jar --host "http://192.168.177.98/" --pass xxx --user xxx browse
Exception in thread "main" com.google.gson.JsonSyntaxException: java.lang.IllegalStateException: Expected BEGIN_OBJECT but was STRING at line 2 column 5 path $
        at com.google.gson.Gson.fromJson(Gson.java:939)
        at com.google.gson.Gson.fromJson(Gson.java:892)
        at com.google.gson.Gson.fromJson(Gson.java:841)
        at com.google.gson.Gson.fromJson(Gson.java:813)
        at pl.rychu.embian.emby.EmbyClientFactory.authenticate(EmbyClientFactory.java:39)
        at pl.rychu.embian.Main.lambda$main$0(Main.java:63)
        at pl.rychu.embian.browse.Browse.exec(Browse.java:35)
        at pl.rychu.embian.Main.main(Main.java:79)
Caused by: java.lang.IllegalStateException: Expected BEGIN_OBJECT but was STRING at line 2 column 5 path $
        at com.google.gson.stream.JsonReader.beginObject(JsonReader.java:385)
        at com.google.gson.internal.bind.MapTypeAdapterFactory$Adapter.read(MapTypeAdapterFactory.java:183)
        at com.google.gson.internal.bind.MapTypeAdapterFactory$Adapter.read(MapTypeAdapterFactory.java:145)
        at com.google.gson.Gson.fromJson(Gson.java:927)
        ... 7 more
Edited by bgx
Link to comment
Share on other sites

kRyszard

Dzieńdoberek :)

 

Regarding the exception:

  • one possibility is that you have some older emby server version that my client cannot talk to i.e. cannot recognize its answer. what emby version do you have?
  • are you sure the user and pass are correct? sorry, i'm not sure right now but the "host" parameter should probably also contain the appname and trainling slash i.e. "http://192.168.177.98/web/"(i'm not sure right now what is the correct app name because I have apache in front of emby and use some url mapping)
  • yes, the authentication part definitely lacks proper error handling and the documentation lack proper "host" param description

Regarding the tags: currently embian handles only the "priv" tag but I'm currently thinking of extending it. I think about two possibilities:

  • embian should handle only tags with prefix "priv" so for example when it finds "priv-all" and "priv-family" tags on emby folder and only ".emby.tag.priv-family" in the filesystem then embian should delete "priv-all" from the folder
  • embian should handle all tags so it will delete any tag for which there is no corresponding ".emby.tag.X" file in the filesystem

Please describe your usecase with these tv series i.e. do you want to sync tags with special tag files in filesystem or rather want to recursively add some tag i.e. in command line pass starting folder and tag name and make embian tag all files (and/or directiories) in all subdirectories.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...