View Javadoc
1   /******************************************************************************
2    * LibraryClient.java - Call into plex
3    * $Id: LibraryClient.java,v 1.7 2014/11/13 06:23:33 dick Exp $
4    * 
5    * BuckoVidLib - The BuckoSoft Video Library
6    * Copyright(c) 2014 - Dick Balaska
7    * 
8    * $Log: LibraryClient.java,v $
9    * Revision 1.7  2014/11/13 06:23:33  dick
10   * Fetch tvShows() from a season.
11   *
12   * Revision 1.6  2014/10/20 01:10:37  dick
13   * tvSeasons() loads the seasons for a show.
14   *
15   * Revision 1.5  2014/10/19 01:43:56  dick
16   * Add recentlyAdded().
17   *
18   * Revision 1.4  2014/10/08 04:40:30  dick
19   * Add videosAll(key)
20   *
21   * Revision 1.3  2014/10/07 02:50:53  dick
22   * whitespace.
23   *
24   * Revision 1.2  2014/10/06 08:11:47  dick
25   * Add the sections() call.
26   *
27   * Revision 1.1  2014/10/04 16:17:40  dick
28   * Define a web client that can talk to the plex server.
29   */
30  package com.buckosoft.BuckoVidLib.web.plex.client;
31  
32  import javax.ws.rs.GET;
33  import javax.ws.rs.Path;
34  import javax.ws.rs.PathParam;
35  
36  import org.apache.commons.logging.Log;
37  import org.apache.commons.logging.LogFactory;
38  import org.apache.cxf.jaxrs.provider.JAXBElementProvider;
39  
40  import tv.plex.domain.MediaContainer;
41  
42  /** Call into plex.
43   * @author dick
44   * @since 2014-10-04
45   */
46  public class LibraryClient extends AbstractClient<LibraryService> implements LibraryService {
47  	private final Log log = LogFactory.getLog(getClass());
48  
49  	@SuppressWarnings("rawtypes")
50  	public LibraryClient(String endpointUrl) {
51  		super(endpointUrl);
52  		providers.add(new JAXBElementProvider());
53  	}
54  
55  	@Override
56  	@GET
57  	@Path("/")
58  	public MediaContainer root() {
59  		return(serviceProxy.root());
60  	}
61  	
62  	public MediaContainer sections() {
63  		return(serviceProxy.sections());
64  	}
65  	
66  	public MediaContainer videosAll(int key) {
67  		return(serviceProxy.videosAll(key));
68  	}
69  
70  	public MediaContainer recentlyAdded() {
71  		MediaContainer mc;
72  		try {
73  			mc = serviceProxy.recentlyAdded();
74  		} catch (Exception e) {
75  			log.warn("recentlyAdded call to Plex failed");
76  			return(null);
77  		}
78  		return(mc);
79  	}
80  
81  	/* (non-Javadoc)
82  	 * @see com.buckosoft.BuckoVidLib.web.plex.client.LibraryService#tvSeasons(int)
83  	 */
84  	@Override
85  	@GET
86  	@Path("/metadata/{key}/children")
87  	public MediaContainer tvSeasons(@PathParam("key") int key) {
88  		return(serviceProxy.tvSeasons(key));
89  	}
90  
91  	/* (non-Javadoc)
92  	 * @see com.buckosoft.BuckoVidLib.web.plex.client.LibraryService#tvShows(int)
93  	 */
94  	@Override
95  	@GET
96  	@Path("/metadata/{key}/children")
97  	public MediaContainer tvShows(@PathParam("key") int key) {
98  		return(serviceProxy.tvShows(key));
99  	}
100 
101 }
102